| 1113 | } |
| 1114 | |
| 1115 | void Actor::Serialize(SerializeStream& stream, const void* otherObj) |
| 1116 | { |
| 1117 | // Base |
| 1118 | SceneObject::Serialize(stream, otherObj); |
| 1119 | |
| 1120 | SERIALIZE_GET_OTHER_OBJ(Actor); |
| 1121 | const bool isPrefabDiff = other && HasPrefabLink(); |
| 1122 | |
| 1123 | SERIALIZE_BIT_MEMBER(IsActive, _isActive); |
| 1124 | SERIALIZE_MEMBER(Name, _name); |
| 1125 | SERIALIZE_MEMBER(Transform, _localTransform); |
| 1126 | SERIALIZE_MEMBER(StaticFlags, _staticFlags); |
| 1127 | SERIALIZE(HideFlags); |
| 1128 | SERIALIZE_MEMBER(Layer, _layer); |
| 1129 | if (!other || Tags != other->Tags) |
| 1130 | { |
| 1131 | if (Tags.Count() == 1) |
| 1132 | { |
| 1133 | stream.JKEY("Tag"); |
| 1134 | stream.String(Tags.Get()->ToString()); |
| 1135 | } |
| 1136 | else |
| 1137 | { |
| 1138 | stream.JKEY("Tags"); |
| 1139 | stream.StartArray(); |
| 1140 | for (auto& tag : Tags) |
| 1141 | stream.String(tag.ToString()); |
| 1142 | stream.EndArray(); |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | if (isPrefabDiff) |
| 1147 | { |
| 1148 | // Prefab object instance may have removed child objects (actors/scripts) |
| 1149 | // Scene deserialization by default adds missing objects to synchronize changes applied to prefab but not applied to scene |
| 1150 | // In order to handle removed objects per instance we need to save the ids of the prefab object ids that are not used by this object |
| 1151 | |
| 1152 | bool hasRemovedObjects = false; |
| 1153 | for (int32 i = 0; i < other->Children.Count(); i++) |
| 1154 | { |
| 1155 | const Guid prefabObjectId = other->Children[i]->GetPrefabObjectID(); |
| 1156 | if (GetChildByPrefabObjectId(this, prefabObjectId) == nullptr) |
| 1157 | { |
| 1158 | if (!hasRemovedObjects) |
| 1159 | { |
| 1160 | hasRemovedObjects = true; |
| 1161 | stream.JKEY("RemovedObjects"); |
| 1162 | stream.StartArray(); |
| 1163 | } |
| 1164 | |
| 1165 | stream.Guid(prefabObjectId); |
| 1166 | } |
| 1167 | } |
| 1168 | for (int32 i = 0; i < other->Scripts.Count(); i++) |
| 1169 | { |
| 1170 | const Guid prefabObjectId = other->Scripts[i]->GetPrefabObjectID(); |
| 1171 | if (GetScriptByPrefabObjectId(this, prefabObjectId) == nullptr) |
| 1172 | { |
nothing calls this directly
no test coverage detected