Fix Script deserialization if ParentID is not specified in stream
This commit is contained in:
@@ -324,19 +324,32 @@ void Script::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier
|
|||||||
DESERIALIZE_BIT_MEMBER(Enabled, _enabled);
|
DESERIALIZE_BIT_MEMBER(Enabled, _enabled);
|
||||||
DESERIALIZE_MEMBER(PrefabID, _prefabID);
|
DESERIALIZE_MEMBER(PrefabID, _prefabID);
|
||||||
|
|
||||||
Guid parentId = Guid::Empty;
|
|
||||||
DESERIALIZE_MEMBER(ParentID, parentId);
|
|
||||||
const auto parent = Scripting::FindObject<Actor>(parentId);
|
|
||||||
if (_parent != parent)
|
|
||||||
{
|
{
|
||||||
if (_parent)
|
const auto member = SERIALIZE_FIND_MEMBER(stream, "ParentID");
|
||||||
_parent->Scripts.RemoveKeepOrder(this);
|
if (member != stream.MemberEnd())
|
||||||
_parent = parent;
|
{
|
||||||
if (_parent)
|
Guid parentId;
|
||||||
_parent->Scripts.Add(this);
|
Serialization::Deserialize(member->value, parentId, modifier);
|
||||||
}
|
const auto parent = Scripting::FindObject<Actor>(parentId);
|
||||||
else if (!parent && parentId.IsValid())
|
if (_parent != parent)
|
||||||
{
|
{
|
||||||
LOG(Warning, "Missing parent actor {0} for \'{1}\'", parentId, ToString());
|
if (IsDuringPlay())
|
||||||
|
{
|
||||||
|
SetParent(parent, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_parent)
|
||||||
|
_parent->Scripts.RemoveKeepOrder(this);
|
||||||
|
_parent = parent;
|
||||||
|
if (_parent)
|
||||||
|
_parent->Scripts.Add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!parent && parentId.IsValid())
|
||||||
|
{
|
||||||
|
LOG(Warning, "Missing parent actor {0} for \'{1}\'", parentId, ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user