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

Method GetDefaultInstance

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

Source from the content-addressed store, hash-verified

51}
52
53Actor* Prefab::GetDefaultInstance()
54{
55 ScopeLock lock(Locker);
56
57 // Skip if already created (reuse cached result)
58 if (_defaultInstance)
59 return _defaultInstance;
60
61 // Skip if not loaded
62 if (!IsLoaded())
63 {
64 LOG(Warning, "Cannot instantiate object from not loaded prefab asset.");
65 return nullptr;
66 }
67
68 // Prevent recursive calls
69 if (_isCreatingDefaultInstance)
70 {
71 LOG(Warning, "Loop call to Prefab::GetDefaultInstance.");
72 return nullptr;
73 }
74 _isCreatingDefaultInstance = true;
75
76 // Instantiate objects from prefab (default spawning logic)
77 _defaultInstance = PrefabManager::SpawnPrefab(this, nullptr, &ObjectsCache);
78
79 _isCreatingDefaultInstance = false;
80 return _defaultInstance;
81}
82
83SceneObject* Prefab::GetDefaultInstance(const Guid& objectId)
84{

Callers 15

CloneObjectFunction · 0.45
CreatePrefabMethod · 0.45
loadMethod · 0.45
LinkPrefabFunction · 0.45
FromBytesMethod · 0.45
ApplyAllMethod · 0.45
ApplyAllMethod · 0.45
HasMinimumQualityMethod · 0.45
CanReimportMethod · 0.45
PrefabItemClass · 0.45

Calls 3

IsLoadedFunction · 0.50
IsValidMethod · 0.45
TryGetMethod · 0.45

Tested by

no test coverage detected