Fixes for Visual Scripting in Editor
This commit is contained in:
@@ -57,8 +57,9 @@ void OnBinaryModuleLoaded(BinaryModule* module);
|
||||
|
||||
MonoReflectionType* CustomEditorsUtil::GetCustomEditor(MonoReflectionType* refType)
|
||||
{
|
||||
if (!refType)
|
||||
return nullptr;
|
||||
MonoType* type = mono_reflection_type_get_type(refType);
|
||||
|
||||
Entry result;
|
||||
if (Cache.TryGet(type, result))
|
||||
{
|
||||
@@ -68,7 +69,6 @@ MonoReflectionType* CustomEditorsUtil::GetCustomEditor(MonoReflectionType* refTy
|
||||
return MUtils::GetType(editor->GetNative());
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,8 @@ namespace FlaxEditor.CustomEditors
|
||||
|
||||
internal static CustomEditor CreateEditor(ScriptType targetType, bool canUseRefPicker = true)
|
||||
{
|
||||
if (targetType == ScriptType.Null)
|
||||
return new GenericEditor();
|
||||
if (targetType.IsArray)
|
||||
{
|
||||
return new ArrayEditor();
|
||||
|
||||
@@ -1121,7 +1121,7 @@ namespace FlaxEditor.Scripting
|
||||
return new ScriptType(_managed.MakeArrayType());
|
||||
if (_custom != null)
|
||||
return new ScriptType(new ScriptTypeArray(this));
|
||||
return Null;
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1130,6 +1130,8 @@ namespace FlaxEditor.Scripting
|
||||
/// <returns>A type object representing a dictionary of the key and value types.</returns>
|
||||
public static ScriptType MakeDictionaryType(ScriptType keyType, ScriptType valueType)
|
||||
{
|
||||
if (keyType == Null || valueType == Null)
|
||||
throw new ArgumentNullException();
|
||||
return new ScriptType(typeof(Dictionary<,>).MakeGenericType(TypeUtils.GetType(keyType), TypeUtils.GetType(valueType)));
|
||||
}
|
||||
|
||||
|
||||
@@ -327,16 +327,10 @@ namespace FlaxEditor.Scripting
|
||||
return ScriptType.Null;
|
||||
|
||||
// C#/C++ types
|
||||
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
for (int i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
var assembly = assemblies[i];
|
||||
if (assembly != null)
|
||||
{
|
||||
var type = assembly.GetType(typeName);
|
||||
if (type != null)
|
||||
return new ScriptType(type);
|
||||
}
|
||||
var type = Type.GetType(typeName);
|
||||
if (type != null)
|
||||
return new ScriptType(type);
|
||||
}
|
||||
|
||||
// Custom types
|
||||
@@ -348,6 +342,7 @@ namespace FlaxEditor.Scripting
|
||||
}
|
||||
if (typeName.EndsWith("[]"))
|
||||
{
|
||||
// Array of custom type
|
||||
if (typeName[0] == '.')
|
||||
typeName = typeName.Substring(1);
|
||||
typeName = typeName.Substring(0, typeName.Length - 2);
|
||||
@@ -359,6 +354,7 @@ namespace FlaxEditor.Scripting
|
||||
}
|
||||
}
|
||||
|
||||
Editor.LogWarning($"Failed to find type '{typeName}'.");
|
||||
return ScriptType.Null;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,12 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isArray)
|
||||
if (param.Type == ScriptType.Null)
|
||||
{
|
||||
b = cmType.ContextMenu.AddButton(window.Surface.GetTypeName(param.Type) + "...", () => OnChangeType(item => window.SetParamType(index, (ScriptType)item.Tag)));
|
||||
return;
|
||||
}
|
||||
else if (isArray)
|
||||
{
|
||||
singleValueType = param.Type.GetElementType();
|
||||
arrayType = param.Type;
|
||||
|
||||
Reference in New Issue
Block a user