Fix prefab apply bug when one of the prefabs in project is broken

This commit is contained in:
Wojtek Figat
2023-08-27 20:08:27 +02:00
parent 1292fa3f45
commit fa77a52a2c

View File

@@ -675,20 +675,12 @@ bool Prefab::ApplyAll(Actor* targetActor)
}
}
// Setup default instances
for (int32 i = 0; i < allPrefabs.Count(); i++)
// Setup default instances (skip invalid prefabs)
for (int32 i = allPrefabs.Count() - 1; i >= 0; i--)
{
Prefab* prefab = allPrefabs[i];
if (prefab->WaitForLoaded())
{
LOG(Warning, "Waiting for nesting prefab asset load failed.");
return true;
}
if (prefab->GetDefaultInstance() == nullptr)
{
LOG(Warning, "Failed to create default prefab instance for the nested prefab asset.");
return true;
}
if (prefab->WaitForLoaded() || prefab->GetDefaultInstance() == nullptr)
allPrefabs.RemoveAt(i);
}
}