diff --git a/Runtime/Extension/ReflectionExtensions.cs b/Runtime/Extension/ReflectionExtensions.cs index 291753f..538a52f 100644 --- a/Runtime/Extension/ReflectionExtensions.cs +++ b/Runtime/Extension/ReflectionExtensions.cs @@ -22,6 +22,21 @@ public static bool IsArrayOrList(this Type listType) return false; } + public static object GetDefault(this Type type) + { + if (type.IsValueType) + { + return Activator.CreateInstance(type); + } + + if (type == typeof(string)) + { + return string.Empty; + } + + return null; + } + public static Type[] GetAllInheritedType(this Type baseType) { return AppDomain.CurrentDomain.GetAssemblies().SelectMany(s => s.GetTypes()).Where(p => ValidateType(baseType, p)).ToArray(); diff --git a/package.json b/package.json index d126022..66687c2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.uurha.betterextensions", "displayName": "Better Extensions", "description": "Unity extensions, serialize extension, async extension, string extension and UI extensions", - "version": "1.1.91", + "version": "1.1.92", "unity": "2020.1", "author": { "name": "Arcueid D'athemon",