//==================================== // Prefaber //==================================== public void DrawPrefaber() { GUILayout.BeginHorizontal("box"); EditorGUILayout.LabelField("Prefab", GUILayout.Width(60)); if (GUILayout.Button("Revert", GUILayout.Width(100))) { ProxyEditor.RegisterSceneUndo(this, "Revert Selected Prefabs"); foreach (GameObject current in Selection.gameObjects) { ProxyEditor.ReconnectToLastPrefab(current); } } if (GUILayout.Button("Apply", GUILayout.Width(100))) { ProxyEditor.RegisterSceneUndo(this, "Apply Selected Prefabs"); foreach (GameObject current in Selection.gameObjects) { GameObject root = ProxyEditor.GetPrefabRoot(current); ProxyEditor.ApplyPrefab(root, ProxyEditor.GetPrefab(root)); } } if (GUILayout.Button("Detach", GUILayout.Width(100))) { ProxyEditor.RegisterSceneUndo(this, "Apply Selected Prefabs"); foreach (GameObject current in Selection.gameObjects) { ProxyEditor.DisconnectPrefabInstance(current); } } GUILayout.EndHorizontal(); }
public static void ApplyPrefabTarget(GameObject target) { Events.Pause("On Hierarchy Changed"); target.PauseValidate(); ProxyEditor.ApplyPrefab(target); target.ResumeValidate(); Events.Resume("On Hierarchy Changed"); }
//==================================== // Replace //==================================== public void PerformReplace() { if (this.optionA.type == ReplaceOption.Prefab) { ProxyEditor.RegisterSceneUndo(this, "Replace Operation"); Object prefab = ProxyEditor.CreateEmptyPrefab(null, this.optionA.targetPath); ProxyEditor.ApplyPrefab(this.optionB.found.First(), prefab); } if (this.optionA.type == ReplaceOption.GameObject) { foreach (GameObject current in new List <GameObject>(this.optionA.found)) { GameObject newObject = (GameObject)ProxyEditor.InstantiatePrefab(this.optionB.found.First()); newObject.transform.parent = current.transform.parent; newObject.transform.position = current.transform.position; newObject.transform.rotation = current.transform.rotation; if (this.preserveScale) { newObject.transform.localScale = current.transform.localScale; } DestroyImmediate(current); } } }