Upd: Fixed C# script resolution bug, fixed object lookup for interfaces, fixed serialization bug.

This commit is contained in:
Andrei Gagua
2026-05-24 19:45:22 +03:00
parent 54a103d840
commit d6fb11cca3
4 changed files with 242 additions and 124 deletions
+8 -2
View File
@@ -717,6 +717,12 @@ DEFINE_INTERNAL_CALL(MString*) ObjectInternal_GetTypeName(ScriptingObject* obj)
return MUtils::ToString(obj->GetType().Fullname);
}
FORCE_INLINE bool ObjectInternal_MatchesType(ScriptingObject* obj, MClass* klass)
{
return !klass ||
(klass->IsInterface() ? obj->GetClass()->HasInterface(klass) : obj->Is(klass));
}
DEFINE_INTERNAL_CALL(MObject*) ObjectInternal_FindObject(Guid* id, MTypeObject* type, bool skipLog = false)
{
if (!id->IsValid())
@@ -732,7 +738,7 @@ DEFINE_INTERNAL_CALL(MObject*) ObjectInternal_FindObject(Guid* id, MTypeObject*
}
if (obj)
{
if (klass && !obj->Is(klass))
if (!ObjectInternal_MatchesType(obj, klass))
{
if (!skipLog)
{
@@ -762,7 +768,7 @@ DEFINE_INTERNAL_CALL(MObject*) ObjectInternal_FindObject(Guid* id, MTypeObject*
DEFINE_INTERNAL_CALL(MObject*) ObjectInternal_TryFindObject(Guid* id, MTypeObject* type)
{
ScriptingObject* obj = Scripting::TryFindObject(*id);
if (obj && !obj->Is(MUtils::GetClass(type)))
if (obj && !ObjectInternal_MatchesType(obj, MUtils::GetClass(type)))
obj = nullptr;
return obj ? obj->GetOrCreateManagedInstance() : nullptr;
}