Skip to content

Commit 4909dfb

Browse files
committed
Stopped trying to flatten the prefab hierarchy if the root game object is a folder
1 parent db31266 commit 4909dfb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Editor/Prefab Handling/PrefabFolderStripper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEditor.Build.Reporting;
1010
using UnityEditor.Callbacks;
1111
using UnityEngine;
12+
using Object = UnityEngine.Object;
1213

1314
[InitializeOnLoad]
1415
public class PrefabFolderStripper : IPreprocessBuildWithReport, IPostprocessBuildWithReport
@@ -125,7 +126,18 @@ private static void StripFoldersFromPrefab(string prefabPath, StrippingMode stri
125126

126127
foreach (Folder folder in folders)
127128
{
128-
folder.Flatten(strippingMode, StripSettings.CapitalizeName);
129+
if (folder.gameObject == temp.PrefabContentsRoot)
130+
{
131+
Debug.LogWarning(
132+
$"Hierarchy will not flatten for {prefabPath} because its root is a folder. " +
133+
"It's advised to make the root an empty game object.");
134+
135+
Object.DestroyImmediate(folder);
136+
}
137+
else
138+
{
139+
folder.Flatten(strippingMode, StripSettings.CapitalizeName);
140+
}
129141
}
130142
}
131143
}

0 commit comments

Comments
 (0)