Fix raw scripting object pointers auto-serialization

This commit is contained in:
Wojtek Figat
2024-11-25 22:13:21 +01:00
parent 344595e171
commit a7061a7524
2 changed files with 21 additions and 0 deletions

View File

@@ -76,3 +76,18 @@ class ISerializeModifier;
if (e != stream.MemberEnd() && e->value.IsBool()) \
member = e->value.GetBool() ? 1 : 0; \
}
// Explicit auto-cast for object pointer
#define SERIALIZE_OBJ(name) \
if (Serialization::ShouldSerialize((const ScriptingObject*&)name, other ? &other->name : nullptr)) \
{ \
stream.JKEY(#name); \
Serialization::Serialize(stream, (const ScriptingObject*&)name, other ? &other->name : nullptr); \
}
#define DESERIALIZE_OBJ(name) \
{ \
const auto e = SERIALIZE_FIND_MEMBER(stream, #name); \
if (e != stream.MemberEnd()) \
Serialization::Deserialize(e->value, (ScriptingObject*&)name, modifier); \
}

View File

@@ -1799,6 +1799,12 @@ namespace Flax.Build.Bindings
{
if (memberType.IsBitField)
return "_BIT";
if (memberType.IsPtr)
{
var t = FindApiTypeInfo(buildData, memberType, caller);
if (t.IsScriptingObject)
return "_OBJ";
}
return string.Empty;
}