MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetRootObjectId

Method GetRootObjectId

Source/Engine/Level/Prefabs/Prefab.cpp:23–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23Guid Prefab::GetRootObjectId() const
24{
25 ASSERT(IsLoaded());
26 ScopeLock lock(Locker);
27
28 // Root is always the first but handle case when prefab root was reordered in the base prefab while the nested prefab has still the old state
29 // TODO: resave and force sync prefabs during game cooking so this step could be skipped in game
30 int32 objectIndex = 0;
31 if (NestedPrefabs.HasItems())
32 {
33 const auto& data = *Data;
34 const Guid basePrefabId = JsonTools::GetGuid(data[objectIndex], "PrefabID");
35 if (const auto basePrefab = Content::Load<Prefab>(basePrefabId))
36 {
37 const Guid basePrefabRootId = basePrefab->GetRootObjectId();
38 for (int32 i = 0; i < ObjectsCount; i++)
39 {
40 const Guid prefabObjectId = JsonTools::GetGuid(data[i], "PrefabObjectID");
41 if (prefabObjectId == basePrefabRootId)
42 {
43 objectIndex = i;
44 break;
45 }
46 }
47 }
48 }
49
50 return ObjectsIds[objectIndex];
51}
52
53Actor* Prefab::GetDefaultInstance()
54{

Callers 7

LinkPrefabMethod · 0.80
DeserializeMethod · 0.80
ApplyAllMethod · 0.80
SpawnPrefabMethod · 0.80
ApplyAllMethod · 0.80

Calls 3

GetGuidFunction · 0.85
IsLoadedFunction · 0.50
HasItemsMethod · 0.45

Tested by

no test coverage detected