Add skipping showing and applying changes to prefab root actor transform via Level

#2125
This commit is contained in:
Wojtek Figat
2024-02-26 22:29:43 +01:00
parent 6905382310
commit 7428ecfe63
2 changed files with 16 additions and 7 deletions

View File

@@ -225,8 +225,15 @@ namespace FlaxEditor.Modules
throw new ArgumentException("Missing prefab to apply.");
PrefabApplying?.Invoke(prefab, instance);
// When applying changes to prefab from actor in level ignore it's root transformation (see ActorEditor.ProcessDiff)
var originalTransform = instance.LocalTransform;
if (instance.IsPrefabRoot && instance.Scene != null)
instance.LocalTransform = prefab.GetDefaultInstance().Transform;
// Call backend
if (PrefabManager.Internal_ApplyAll(FlaxEngine.Object.GetUnmanagedPtr(instance)))
var failed = PrefabManager.Internal_ApplyAll(FlaxEngine.Object.GetUnmanagedPtr(instance));
instance.LocalTransform = originalTransform;
if (failed)
throw new Exception("Failed to apply the prefab. See log to learn more.");
PrefabApplied?.Invoke(prefab, instance);