diff --git a/Source/Editor/Scripting/TypeUtils.cs b/Source/Editor/Scripting/TypeUtils.cs index cc763b9b8..b2b71d370 100644 --- a/Source/Editor/Scripting/TypeUtils.cs +++ b/Source/Editor/Scripting/TypeUtils.cs @@ -233,7 +233,18 @@ namespace FlaxEditor.Scripting { if (string.IsNullOrEmpty(typeName)) return null; - return Type.GetType(typeName); + 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 type; + } + } + return null; } /// @@ -247,10 +258,18 @@ namespace FlaxEditor.Scripting return ScriptType.Null; // C#/C++ types + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + for (int i = 0; i < assemblies.Length; i++) { - var type = Type.GetType(typeName); - if (type != null) - return new ScriptType(type); + var assembly = assemblies[i]; + if (assembly != null) + { + var type = assembly.GetType(typeName); + if (type != null) + { + return new ScriptType(type); + } + } } // Custom types @@ -258,7 +277,9 @@ namespace FlaxEditor.Scripting { var type = customTypesInfo.GetType(typeName); if (type) + { return type; + } } return ScriptType.Null; diff --git a/Source/Engine/Content/JsonAsset.cs b/Source/Engine/Content/JsonAsset.cs index 13c53f532..dda7bd879 100644 --- a/Source/Engine/Content/JsonAsset.cs +++ b/Source/Engine/Content/JsonAsset.cs @@ -34,31 +34,37 @@ namespace FlaxEngine if (WaitForLoaded()) return null; - object obj = null; var dataTypeName = DataTypeName; - var type = Type.GetType(dataTypeName); - if (type != null) + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + for (int i = 0; i < assemblies.Length; i++) { - try + var assembly = assemblies[i]; + if (assembly != null) { - // Create instance - obj = Activator.CreateInstance(type); + var type = assembly.GetType(dataTypeName); + if (type != null) + { + object obj = null; + try + { + // Create instance + obj = Activator.CreateInstance(type); - // Deserialize object - var data = Data; - JsonSerializer.Deserialize(obj, data); - } - catch (Exception ex) - { - Debug.LogException(ex, this); + // Deserialize object + var data = Data; + JsonSerializer.Deserialize(obj, data); + } + catch (Exception ex) + { + Debug.LogException(ex, this); + } + return obj; + } } } - else - { - Debug.LogError(string.Format("Missing type '{0}' to create Json Asset instance.", dataTypeName), this); - } - return obj; + Debug.LogError(string.Format("Missing type '{0}' to create Json Asset instance.", dataTypeName), this); + return null; } } }