/// <summary> /// Creates a new folder for the new LevelList, used for storing any levels that will be a part of that list. /// Creates a new LevelList scriptable object in order to store new levels pertaining to the involved list. /// Returns the user to the start menu upon sucessful completion. /// </summary> void CreateNewLevelListWthFolder(string nameForListAndFolder) { AssetDatabase.CreateFolder(LEVELS_FOLDER_DIRECTORY, nameForListAndFolder); var newList = TWEditorUtil.CreateScriptableAsset <LevelList>(LEVEL_LIST_FOLDER_DIRECTORY_INSIDE + nameForListAndFolder + ASSET_EXTENSION, true, true); if (EditorUtility.DisplayDialog("Complete", "The new level list and its respective folder have been created", "Ok")) { ActivateHomeButton(); } }
void OnGUI() { GUILayout.Label("Name of Asset", EditorStyles.boldLabel); assetName = EditorGUILayout.TextField("Text Field", assetName); if (assetName == null || assetName.Length == 0) { EditorGUILayout.HelpBox("Must name the AI Data before it can be created!", MessageType.Error); } else { if (GUILayout.Button("Create")) { TWEditorUtil.CreateScriptableAsset <AIData>("Assets/Main/Data/AI_Datas/" + assetName + ".asset"); } } }
/// <summary> /// Creates the new level. /// </summary> void CreateNewLevel(string levelName, string description) { // Reference to the new level list. // Used to store a reference to the List we will be adding to. LevelList levelList = AssetDatabase.LoadAssetAtPath(pathOfSelectedLevelList, typeof(LevelList)) as LevelList; // Concatanating a bunch of necessary strings to reduce line length. string directoryToAddNewLevelAndFab = LEVELS_FOLDER_DIRECTORY + FORWARD_SLASH + levelList.name + FORWARD_SLASH; // New level Scriptable object asset as well as a reference to it. // Created in the folder specific to the chosen level list. LevelData newLevel = TWEditorUtil.CreateScriptableAsset <LevelData>(directoryToAddNewLevelAndFab + levelName + ASSET_EXTENSION, true, true); // Grabbing a reference to the default level prefab. var defaultLevelFab = AssetDatabase.LoadAssetAtPath(DEFAULT_LEVEL_PREFAB_PATH, typeof(GameObject)); // Need to make an instance of the prefab in order to create a new one in another directory. GameObject tempObject = GameObject.Instantiate(defaultLevelFab) as GameObject; // Creation of a unique prefab to be used for the newly created level. // This also takes care of setting the new prefabs name to the name of the level. var newLevelFab = PrefabUtility.CreatePrefab(directoryToAddNewLevelAndFab + levelName + PREFAB_EXTENSION, tempObject as GameObject); // Store the newly created prefab in the new Level's public prefab slot. newLevel.Name = levelName; newLevel.Discription = description; newLevel.Prefab = newLevelFab; DestroyImmediate(tempObject); //Destroy the instance that we had originally created off of "DefaultLevelFab", which is in the scene. // Add the new level to the referenced LevelList above. if (newLevel != null) { levelList.Levels.Add(newLevel); EditorUtility.SetDirty(levelList); AssetDatabase.SaveAssets(); } else { Debug.LogError("The level you are trying to add to the level list is null."); } if (EditorUtility.DisplayDialog("Level Created", "A new level has been created!", "Ok")) { ActivateHomeButton(); } }
static void CreateLevelData() { TWEditorUtil.CreateScriptableAsset <LevelData>("Assets/Main/Data/Levels/Data/Level.asset"); }
static void CreateLevelList() { TWEditorUtil.CreateScriptableAsset <LevelList>("Assets/Main/Data/Levels/Lists/LevelList.asset"); }
static void CreateGlobalTowerInfo() { TWEditorUtil.CreateScriptableAsset <GlobalTowerInfo>("Assets/Main/Data/GlobalTowerInfo.asset", true, false); }