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

Method LinkPrefab

Source/Engine/Level/Actor.cpp:939–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937}
938
939void Actor::LinkPrefab(const Guid& prefabId, const Guid& prefabObjectId)
940{
941 ASSERT(prefabId.IsValid());
942
943#if USE_EDITOR
944 if (_isPrefabRoot)
945 {
946 ScopeLock lock(PrefabManager::PrefabsReferencesLocker);
947 PrefabManager::PrefabsReferences[_prefabID].Remove(this);
948 }
949#endif
950
951 // Link
952 _prefabID = prefabId;
953 _prefabObjectID = prefabObjectId;
954 _isPrefabRoot = 0;
955
956 if (_prefabID.IsValid() && _prefabObjectID.IsValid())
957 {
958 auto prefab = Content::LoadAsync<Prefab>(_prefabID);
959 if (prefab == nullptr || prefab->WaitForLoaded())
960 {
961 _prefabID = Guid::Empty;
962 _prefabObjectID = Guid::Empty;
963 LOG(Warning, "Failed to load prefab linked to the actor.");
964 }
965 else if (prefab->GetRootObjectId() == _prefabObjectID)
966 {
967 _isPrefabRoot = 1;
968#if USE_EDITOR
969 ScopeLock lock(PrefabManager::PrefabsReferencesLocker);
970 PrefabManager::PrefabsReferences[_prefabID].Add(this);
971#endif
972 }
973 }
974}
975
976void Actor::BreakPrefabLink()
977{

Callers 8

CreatePrefabMethod · 0.45
LinkPrefabFunction · 0.45
FromBytesMethod · 0.45
ApplyAllInternalMethod · 0.45
SpawnPrefabMethod · 0.45
CreatePrefabMethod · 0.45

Calls 5

WaitForLoadedMethod · 0.80
GetRootObjectIdMethod · 0.80
IsValidMethod · 0.45
RemoveMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected