Skip to content

Commit 39b3494

Browse files
committed
Don't copy transform components into linked prefab
1 parent 49f95dc commit 39b3494

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

com.unity.formats.fbx/Editor/ConvertToNestedPrefab.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ public static GameObject Convert(
450450
// replace hierarchy in the scene
451451
if (!isPrefabAsset && toConvert != null)
452452
{
453+
// keep the transform of the root of the prefab instance the same
454+
var jsonTransform = EditorJsonUtility.ToJson(toConvert.transform);
455+
EditorJsonUtility.FromJsonOverwrite(jsonTransform, fbxInstance.transform);
456+
453457
Undo.DestroyObjectImmediate(toConvert);
454458
Undo.RegisterCreatedObjectUndo(fbxInstance, UndoConversionCreateObject);
455459
SceneManagement.EditorSceneManager.MarkSceneDirty(fbxInstance.scene);
@@ -873,8 +877,12 @@ internal static void CopyComponents(GameObject to, GameObject from, GameObject r
873877
// ignore FbxPrefab (when converting LinkedPrefabs)
874878
// Also ignore RectTransform, since it is not currently possible to switch transforms
875879
// in a prefab.
880+
// Don't need to copy regular transform either as the values should already be correct in the FBX.
881+
// Furthermore, copying transform values may result in overrides in the prefab, which is undesired as if
882+
// the transform is updated in the FBX, it won't be in the prefab.
876883
if (fromComponent is UnityEngine.Formats.Fbx.Exporter.FbxPrefab ||
877-
fromComponent is RectTransform)
884+
fromComponent is RectTransform ||
885+
fromComponent is Transform)
878886
{
879887
continue;
880888
}

0 commit comments

Comments
 (0)