Revert part of 9870d162e4 to support prefab variants creation

This commit is contained in:
Wojtek Figat
2024-11-25 22:39:02 +01:00
parent 0e13173119
commit ab78314a01

View File

@@ -336,8 +336,6 @@ bool PrefabManager::CreatePrefab(Actor* targetActor, const StringView& outputPat
// Serialize to json data
ASSERT(!IsCreatingPrefab);
IsCreatingPrefab = true;
const Guid targetPrefabId = targetActor->GetPrefabID();
const bool hasTargetPrefabId = targetPrefabId.IsValid();
rapidjson_flax::StringBuffer actorsDataBuffer;
{
CompactJsonWriter writerObj(actorsDataBuffer);
@@ -346,27 +344,7 @@ bool PrefabManager::CreatePrefab(Actor* targetActor, const StringView& outputPat
for (int32 i = 0; i < sceneObjects->Count(); i++)
{
SceneObject* obj = sceneObjects->At(i);
// Detect when creating prefab from object that is already part of prefab then serialize it as unlinked
const Guid prefabId = obj->GetPrefabID();
const Guid prefabObjectId = obj->GetPrefabObjectID();
bool isObjectFromPrefab = targetPrefabId == prefabId && prefabId.IsValid(); // Allow to use other nested prefabs properly (ignore only root object's prefab link)
if (isObjectFromPrefab)
{
//obj->BreakPrefabLink();
obj->_prefabID = Guid::Empty;
obj->_prefabObjectID = Guid::Empty;
}
writer.SceneObject(obj);
// Restore broken link
if (hasTargetPrefabId)
{
//obj->LinkPrefab(prefabId, prefabObjectId);
obj->_prefabID = prefabId;
obj->_prefabObjectID = prefabObjectId;
}
}
writer.EndArray();
}