From a1f985bc7d1b496ae2a1e24723089d7179f2c107 Mon Sep 17 00:00:00 2001 From: Crawcik Date: Thu, 3 Jun 2021 13:44:21 +0200 Subject: [PATCH] Adding NotNullItem --- Source/Editor/Scripting/TypeUtils.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Scripting/TypeUtils.cs b/Source/Editor/Scripting/TypeUtils.cs index 60f64ab8e..3d6362d5d 100644 --- a/Source/Editor/Scripting/TypeUtils.cs +++ b/Source/Editor/Scripting/TypeUtils.cs @@ -37,8 +37,9 @@ namespace FlaxEditor.Scripting /// Gets the default value for the given type (can be value type or reference type). /// /// The type. + /// Whether the value can be empty. If that's true, it can't. /// The created instance. - public static object GetDefaultValue(ScriptType type) + public static object GetDefaultValue(ScriptType type, bool notNull = false) { if (type.Type == typeof(string)) return string.Empty; @@ -64,7 +65,7 @@ namespace FlaxEditor.Scripting Utilities.Utils.InitDefaultValues(value); return value; } - if (new ScriptType(typeof(object)).IsAssignableFrom(type)) + if (!notNull && new ScriptType(typeof(object)).IsAssignableFrom(type)) return null; if (type.CanCreateInstance) {