mirror of https://github.com/godotengine/godot
Fix lookup of C# types by their engine name
This commit is contained in:
parent
a43db5afa4
commit
65d0d05fa7
|
|
@ -243,9 +243,33 @@ namespace Godot.Bridge
|
||||||
|
|
||||||
if (wrapperType == null)
|
if (wrapperType == null)
|
||||||
{
|
{
|
||||||
wrapperType = AppDomain.CurrentDomain.GetAssemblies()
|
wrapperType = GetTypeByGodotClassAttr(typeof(GodotObject).Assembly, nativeTypeNameStr);
|
||||||
.FirstOrDefault(a => a.GetName().Name == "GodotSharpEditor")?
|
}
|
||||||
.GetType("Godot." + nativeTypeNameStr);
|
|
||||||
|
if (wrapperType == null)
|
||||||
|
{
|
||||||
|
var editorAssembly = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
|
.FirstOrDefault(a => a.GetName().Name == "GodotSharpEditor");
|
||||||
|
wrapperType = editorAssembly?.GetType("Godot." + nativeTypeNameStr);
|
||||||
|
|
||||||
|
if (wrapperType == null)
|
||||||
|
{
|
||||||
|
wrapperType = GetTypeByGodotClassAttr(editorAssembly, nativeTypeNameStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Type? GetTypeByGodotClassAttr(Assembly assembly, string nativeTypeNameStr)
|
||||||
|
{
|
||||||
|
var types = assembly.GetTypes();
|
||||||
|
foreach (var type in types)
|
||||||
|
{
|
||||||
|
var attr = type.GetCustomAttribute<GodotClassNameAttribute>();
|
||||||
|
if (attr?.Name == nativeTypeNameStr)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsStatic(Type type) => type.IsAbstract && type.IsSealed;
|
static bool IsStatic(Type type) => type.IsAbstract && type.IsSealed;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue