static void CreateLevelTemplateAll() { ClearLevelTemplate(); GameObject[] allObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); //Store array of all root objects for (int x = 0; x < allObjects.Length; x++) //Loop through all objects { Object fileCheck = (Object)AssetDatabase.LoadAssetAtPath(levelPath + allObjects[x].name + ".prefab", typeof(Object)); //If the path already exists while (fileCheck) { allObjects[x].name = allObjects[x].name + "(clone)"; fileCheck = (Object)AssetDatabase.LoadAssetAtPath(levelPath + allObjects[x].name + ".prefab", typeof(Object)); } ObjectClipboard.MakePrefab(allObjects[x].transform.gameObject, levelPath); //Make prefab of individual object } }
static void CreateLevelTemplateSelected() { ClearLevelTemplate(); //SelectionHandler.DeselectChildren(); GameObject[] allObjects = Selection.gameObjects; for (int x = 0; x < allObjects.Length; x++) //Loop through all objects { Object fileCheck = (Object)AssetDatabase.LoadAssetAtPath(levelPath + allObjects[x].name + ".prefab", typeof(Object)); //If the path already exists while (fileCheck) { allObjects[x].name = allObjects[x].name + "(clone)"; fileCheck = (Object)AssetDatabase.LoadAssetAtPath(levelPath + allObjects[x].name + ".prefab", typeof(Object)); } ObjectClipboard.MakePrefab(allObjects[x].transform.gameObject, levelPath); //Make prefab of individual object } }
static void ModeChanged() { //In case you would like to use this tool to do more things, here are the different states // Scene is stopped : isPlayingOrWillChangePlaymode = false; isPlaying = false // Pressed Playback button : isPlayingOrWillChangePlaymode = true; isPlaying = false // Pressed Stop Button : isPlayingOrWillChangePlaymode = false; isPlaying = true // Scene is playing : isPlayingOrWillChangePlaymode = true; isPlaying = true if (EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying) //Scene is playing { } else if (!EditorApplication.isPlayingOrWillChangePlaymode && EditorApplication.isPlaying) //Pressed stop button { } else if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) //Pressed play button { } else if (!EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying) //Scene is stopped { ObjectClipboard.AfterExit(); } }
static void ClearClipboard() //Recursively delete object clipboard resource folder { ObjectClipboard.ClearClipboard(); AssetDatabase.Refresh(); }