| 51 | } |
| 52 | |
| 53 | Actor* 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 | |
| 83 | SceneObject* Prefab::GetDefaultInstance(const Guid& objectId) |
| 84 | { |
no test coverage detected