public static void DisconnectPrefabInstance(UnityObject target) { #if UNITY_2018_3_OR_NEWER PrefabUtility.UnpackPrefabInstance(target.As <GameObject>(), PrefabUnpackMode.Completely, InteractionMode.UserAction); #else PrefabUtility.DisconnectPrefabInstance(target); #endif }
public void Setup(string path, UnityObject parent) { this.disabled = false; if (parent.Is <Component>()) { var component = parent.As <Component>(); this.path = component.GetPath() + "/" + path; this.parent = parent; if (!Application.isPlaying) { this.AddSpecial("[This]", component.gameObject); this.AddSpecial("[Self]", component.gameObject); this.AddSpecial("[Next]", component.gameObject.GetNextSibling(true)); this.AddSpecial("[Previous]", component.gameObject.GetPreviousSibling(true)); this.AddSpecial("[NextEnabled]", component.gameObject.GetNextSibling()); this.AddSpecial("[PreviousEnabled]", component.gameObject.GetPreviousSibling()); this.AddSpecial("[Root]", component.gameObject.GetPrefabRoot()); Events.Add("On Validate", this.Search, parent); Events.Add("On Components Changed", this.Search, parent); /*if(parent is StateBehaviour){ * var state = (StateBehaviour)parent; * GameObject stateObject = state.gameObject; * GameObject parentObject = state.gameObject; * if(state.controller != null){ * stateObject = state.controller.gameObject; * parentObject = state.controller.gameObject; * if(state.controller.controller != null){ * parentObject = state.controller.controller.gameObject; * } * } * this.AddSpecial("[ParentController]",parentObject); * this.AddSpecial("[Controller]",stateObject); * this.AddSpecial("[State]",state.gameObject); * }*/ this.SetFallback(Target.defaultSearch); if (this.searchObject.IsNull()) { this.Search(); } } } }
public static void Destroy(this UnityObject target, bool destroyAssets = false) { if (target.IsNull()) { return; } if (target is Component) { var component = target.As <Component>(); if (component.gameObject.IsNull()) { return; } } if (!Proxy.IsPlaying()) { UnityObject.DestroyImmediate(target, destroyAssets); } else { UnityObject.Destroy(target); } }