Skip to content

Commit c48cdc2

Browse files
committed
erase exception when a uipanel in prefab is being destroyed in editor, since 2018.3
1 parent 71ac3c0 commit c48cdc2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Assets/Scripts/UI/UIPanel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using UnityEngine;
4+
#if UNITY_EDITOR
5+
using UnityEditor;
6+
#endif
47

58
namespace FairyGUI
69
{
@@ -157,7 +160,13 @@ void CreateContainer()
157160
{
158161
GameObject go = t.GetChild(cnt - 1).gameObject;
159162
if (go.name == "UI(AutoGenerated)")
163+
{
164+
#if UNITY_2018_3_OR_NEWER
165+
if (PrefabUtility.IsPartOfPrefabInstance(go))
166+
PrefabUtility.UnpackPrefabInstance(PrefabUtility.GetOutermostPrefabInstanceRoot(gameObject), PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
167+
#endif
160168
UnityEngine.Object.DestroyImmediate(go);
169+
}
161170
cnt--;
162171
}
163172
}

0 commit comments

Comments
 (0)