diff --git a/Source/Editor/CustomEditors/CustomEditorsUtil.cpp b/Source/Editor/CustomEditors/CustomEditorsUtil.cpp index 0542fa260..a02ad1c4a 100644 --- a/Source/Editor/CustomEditors/CustomEditorsUtil.cpp +++ b/Source/Editor/CustomEditors/CustomEditorsUtil.cpp @@ -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; } diff --git a/Source/Editor/CustomEditors/CustomEditorsUtil.cs b/Source/Editor/CustomEditors/CustomEditorsUtil.cs index debd43cba..6c20b4ed4 100644 --- a/Source/Editor/CustomEditors/CustomEditorsUtil.cs +++ b/Source/Editor/CustomEditors/CustomEditorsUtil.cs @@ -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(); diff --git a/Source/Editor/Scripting/ScriptType.cs b/Source/Editor/Scripting/ScriptType.cs index 8ddb2a514..c56d2b8d3 100644 --- a/Source/Editor/Scripting/ScriptType.cs +++ b/Source/Editor/Scripting/ScriptType.cs @@ -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(); } /// @@ -1130,6 +1130,8 @@ namespace FlaxEditor.Scripting /// A type object representing a dictionary of the key and value types. 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))); } diff --git a/Source/Editor/Scripting/TypeUtils.cs b/Source/Editor/Scripting/TypeUtils.cs index 9b4b0be5e..cc8f082f6 100644 --- a/Source/Editor/Scripting/TypeUtils.cs +++ b/Source/Editor/Scripting/TypeUtils.cs @@ -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; } diff --git a/Source/Editor/Windows/Assets/VisualScriptWindow.cs b/Source/Editor/Windows/Assets/VisualScriptWindow.cs index 2cb8fc0e8..378fe8e32 100644 --- a/Source/Editor/Windows/Assets/VisualScriptWindow.cs +++ b/Source/Editor/Windows/Assets/VisualScriptWindow.cs @@ -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;