Add ShouldSerialize to ISerializable to properly handle serialization of custom C++ types in prefabs

#3499
This commit is contained in:
Wojtek Figat
2026-02-03 22:09:41 +01:00
parent f3111e855d
commit 15771355cb
4 changed files with 48 additions and 8 deletions

View File

@@ -415,7 +415,7 @@ namespace Serialization
inline bool ShouldSerialize(const ISerializable& v, const void* otherObj)
{
return true;
return !otherObj || v.ShouldSerialize(otherObj);
}
inline void Serialize(ISerializable::SerializeStream& stream, const ISerializable& v, const void* otherObj)
{
@@ -431,7 +431,7 @@ namespace Serialization
template<typename T>
inline typename TEnableIf<TIsBaseOf<ISerializable, T>::Value, bool>::Type ShouldSerialize(const ISerializable& v, const void* otherObj)
{
return true;
return !otherObj || v.ShouldSerialize(otherObj);
}
template<typename T>
inline typename TEnableIf<TIsBaseOf<ISerializable, T>::Value>::Type Serialize(ISerializable::SerializeStream& stream, const ISerializable& v, const void* otherObj)