| 99 | } |
| 100 | |
| 101 | void SceneObjectsFactory::Context::SetupIdsMapping(const SceneObject* obj, ISerializeModifier* modifier) const |
| 102 | { |
| 103 | int32 instanceIndex; |
| 104 | const Guid id = obj->GetID(); |
| 105 | if (ObjectToInstance.TryGet(id, instanceIndex)) |
| 106 | { |
| 107 | // Apply the current prefab instance objects ids table to resolve references inside a prefab properly |
| 108 | const auto& instance = Instances[instanceIndex]; |
| 109 | if (instanceIndex != modifier->CurrentInstance) |
| 110 | { |
| 111 | modifier->CurrentInstance = instanceIndex; |
| 112 | for (const auto& e : instance.IdsMapping) |
| 113 | modifier->IdsMapping[e.Key] = e.Value; |
| 114 | } |
| 115 | int32 nestedIndex; |
| 116 | if (instance.ObjectToNested.TryGet(id, nestedIndex)) |
| 117 | { |
| 118 | // Each nested prefab has own object ids mapping that takes precedence |
| 119 | const auto& nested = instance.Nested[nestedIndex]; |
| 120 | for (const auto& e : nested.IdsMapping) |
| 121 | modifier->IdsMapping[e.Key] = e.Value; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | SceneObject* SceneObjectsFactory::Spawn(Context& context, const ISerializable::DeserializeStream& stream) |
| 127 | { |
no test coverage detected