diff --git a/Source/Editor/Content/Items/VisualScriptItem.cs b/Source/Editor/Content/Items/VisualScriptItem.cs index 8eea041ce..5b2f505d7 100644 --- a/Source/Editor/Content/Items/VisualScriptItem.cs +++ b/Source/Editor/Content/Items/VisualScriptItem.cs @@ -281,6 +281,13 @@ namespace FlaxEditor.Content private void CacheData() { + if (!_asset) + { + _parameters = Utils.GetEmptyArray(); + _methods = Utils.GetEmptyArray(); + _attributes = Utils.GetEmptyArray(); + return; + } if (_parameters != null) return; if (_asset.WaitForLoaded()) @@ -344,13 +351,13 @@ namespace FlaxEditor.Content } /// - public string Name => Path.GetFileNameWithoutExtension(_asset.Path); + public string Name => _asset ? Path.GetFileNameWithoutExtension(_asset.Path) : null; /// public string Namespace => string.Empty; /// - public string TypeName => JsonSerializer.GetStringID(_asset.ID); + public string TypeName => _asset ? JsonSerializer.GetStringID(_asset.ID) : null; /// public bool IsPublic => true; diff --git a/Source/Editor/Scripting/TypeUtils.cs b/Source/Editor/Scripting/TypeUtils.cs index 2451e1d87..3537b6218 100644 --- a/Source/Editor/Scripting/TypeUtils.cs +++ b/Source/Editor/Scripting/TypeUtils.cs @@ -406,6 +406,8 @@ namespace FlaxEngine.Utilities { if (type == ScriptType.Null) return null; + if (type.BaseType == null) + return type.Type; while (type.Type == null) type = type.BaseType; return type.Type; diff --git a/Source/Editor/Surface/SurfaceUtils.cs b/Source/Editor/Surface/SurfaceUtils.cs index d75efb5a0..7a19567fa 100644 --- a/Source/Editor/Surface/SurfaceUtils.cs +++ b/Source/Editor/Surface/SurfaceUtils.cs @@ -400,7 +400,7 @@ namespace FlaxEditor.Surface return scriptType.GetGenericTypeDefinition() == typeof(Dictionary<,>); } var managedType = TypeUtils.GetType(scriptType); - return !TypeUtils.IsDelegate(managedType); + return managedType != null && !TypeUtils.IsDelegate(managedType); } internal static bool IsValidVisualScriptFunctionType(ScriptType scriptType) @@ -408,7 +408,7 @@ namespace FlaxEditor.Surface if (scriptType.IsGenericType || scriptType.IsStatic || !scriptType.IsPublic || scriptType.HasAttribute(typeof(HideInEditorAttribute), true)) return false; var managedType = TypeUtils.GetType(scriptType); - return !TypeUtils.IsDelegate(managedType); + return managedType != null && !TypeUtils.IsDelegate(managedType); } internal static string GetVisualScriptTypeDescription(ScriptType type)