private void OnGUI()
        {
            renamableCategories = CategoriesManagement.GetAllCategories(false, false);
            if (renamableCategories.Length > 0)
            {
                selectedCategoryValue = EditorGUILayout.Popup("Category To Rename", selectedCategoryValue, renamableCategories);
                newName = EditorGUILayout.TextField("New Category Name", newName);
                if (string.IsNullOrEmpty(newName))
                {
                    EditorGUILayout.HelpBox("New Name cannot be empty", MessageType.Error);
                }

                if (newName == renamableCategories[selectedCategoryValue])
                {
                    EditorGUILayout.HelpBox("Category Name Already Exists", MessageType.Error);
                }
            }

            if (string.IsNullOrEmpty(newName) == false && renamableCategories.Length > 0 && newName != renamableCategories[selectedCategoryValue])
            {
                if (GUILayout.Button("Rename Category"))
                {
                    CategoriesManagement.RenameCategory(renamableCategories[selectedCategoryValue], newName);
                    selectedCategoryValue = 0;
                }
            }
        }
예제 #2
0
        private void OnGUI()
        {
            newCategoryName = EditorGUILayout.TextField("New Category Name", newCategoryName);

            if (string.IsNullOrEmpty(newCategoryName))
            {
                EditorGUILayout.HelpBox("Category Name Cannot Be Empty", MessageType.Error);
            }

            //Check Does CategoryNameExist
            string[] allCategories           = CategoriesManagement.GetAllCategories(true, true);
            bool     doesCategoryAlreadExist = false;

            foreach (string item in allCategories)
            {
                if (item == newCategoryName)
                {
                    doesCategoryAlreadExist = true;
                    break;
                }
            }

            if (doesCategoryAlreadExist == true)
            {
                EditorGUILayout.HelpBox("Category Already Exists", MessageType.Error);
            }

            if (doesCategoryAlreadExist == false && !string.IsNullOrEmpty(newCategoryName))
            {
                if (GUILayout.Button("Create Category"))
                {
                    CategoriesManagement.CreateCategory(newCategoryName);
                }
            }
        }
예제 #3
0
        private void OnGUI()
        {
            List <string> levelsToString = new List <string>();

            if (levels.Length > 0)
            {
                foreach (GameLevel item in levels)
                {
                    levelsToString.Add(item.gameLevelName);
                }
                levelOptionsToLoad = levelsToString.ToArray();
                selectedValue      = EditorGUILayout.Popup("Level To Change", selectedValue, levelOptionsToLoad);
            }

            categories            = CategoriesManagement.GetAllCategories(false, true);
            selectedCategoryValue = EditorGUILayout.Popup("Target Category", selectedCategoryValue, categories);
            levels = gameLevelData.gameLevelsCreatedByUser.ToArray();

            if (levels[selectedValue].assignedCategory == categories[selectedCategoryValue])
            {
                EditorGUILayout.HelpBox("Category Is Already Assigned to Level", MessageType.Info);
            }
            else
            {
                if (GUILayout.Button("Change Levels Category"))
                {
                    levels[selectedValue].assignedCategory = categories[selectedCategoryValue];
                }
            }
        }
예제 #4
0
        private void OnGUI()
        {
            categories            = CategoriesManagement.GetAllCategories(true, true);
            selectedCategoryValue = EditorGUILayout.Popup("Selected Category", selectedCategoryValue, categories);
            levels = CategoriesManagement.GetGameLevelsBasedOnCategory(categories[selectedCategoryValue]);
            List <string> levelsToString = new List <string>();

            if (levels.Length > 0)
            {
                foreach (GameLevel item in levels)
                {
                    levelsToString.Add(item.gameLevelName);
                }
                levelOptionsToLoad = levelsToString.ToArray();
            }

            if (levels.Length > 0)
            {
                selectedValue       = EditorGUILayout.Popup("Level To Load", selectedValue, levelOptionsToLoad);
                includeMasterScene  = EditorGUILayout.Toggle("Load Master Scene", includeMasterScene);
                includeDependencies = EditorGUILayout.Toggle("Load Dependencies", includeDependencies);
                keepCurrentScenesThatAreOpenOpeneded = EditorGUILayout.Toggle("Keep Current Scenes", keepCurrentScenesThatAreOpenOpeneded);

                if (GUILayout.Button("Load Seleected Level"))
                {
                    // Get Target Level
                    selectedGameLevel = levels[selectedValue];

                    OpenLevel(selectedGameLevel, includeMasterScene, keepCurrentScenesThatAreOpenOpeneded, includeDependencies);
                    Close();
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Selected Category has no assigned levels", MessageType.Info);
            }
        }
        private void OnGUI()
        {
            bool doesLevelNameExist = false;

            for (int i = 0; i < gameLevelData.gameLevelsCreatedByUser.Count; i++)
            {
                if (gameLevelData.gameLevelsCreatedByUser[i].gameLevelName == gameLevelName)
                {
                    doesLevelNameExist = true;
                    break;
                }
                else
                {
                    doesLevelNameExist = false;
                }
            }

            gameLevelName = EditorGUILayout.TextField("New Level Name", gameLevelName);
            if (gameLevelName == null || gameLevelName == "")
            {
                EditorGUILayout.HelpBox("Game Level Name Cannot Be Empty", MessageType.Error);
            }
            if (doesLevelNameExist == true)
            {
                EditorGUILayout.HelpBox("Game Level Already Exists", MessageType.Error);
            }
            if (scenesToCreateInGameLevel.Count == 0)
            {
                EditorGUILayout.HelpBox("Levels Require at least one scene", MessageType.Error);
            }

            if (scenesToCreateInGameLevel.Count > 0)
            {
                for (int i = 0; i < scenesToCreateInGameLevel.Count; i++)
                {
                    if (scenesToCreateInGameLevel[i].sceneName == "" || scenesToCreateInGameLevel[i].sceneName == null)
                    {
                        hasEmptySceneName = true;
                        break;
                    }
                    else
                    {
                        hasEmptySceneName = false;
                    }
                }
            }
            else
            {
                hasEmptySceneName = false;
            }

            //Dependencies
            ScriptableObject   target = this;
            SerializedObject   so     = new SerializedObject(target);
            SerializedProperty dependenciesProperty = so.FindProperty("gameLevelDependencies");
            SerializedProperty scenesProperty       = so.FindProperty("scenesToCreateInGameLevel");

            EditorGUILayout.PropertyField(scenesProperty, true); // True means show children
            EditorGUILayout.PropertyField(dependenciesProperty, true);
            so.ApplyModifiedProperties();                        // Remember to apply modified properties

            if (hasEmptySceneName == true)
            {
                EditorGUILayout.HelpBox("Scene Names Cannot Be Empty", MessageType.Error);
            }

            if (gameLevelDependencies.Count > 0)
            {
                for (int i = 0; i < gameLevelDependencies.Count; i++)
                {
                    if (gameLevelDependencies[i] == null)
                    {
                        hasEmptyDependency = true;
                        break;
                    }
                    else
                    {
                        hasEmptyDependency = false;
                    }
                }
            }
            else
            {
                hasEmptyDependency = false;
            }

            if (hasEmptyDependency == true)
            {
                EditorGUILayout.HelpBox("Dependency value cannot be null", MessageType.Error);
            }

            addLevelToUnityBuildScenes = GUILayout.Toggle(addLevelToUnityBuildScenes, "Add Level To Project Scene Build Settings");

            categories            = CategoriesManagement.GetAllCategories(false, true);
            selectedCategoryValue = EditorGUILayout.Popup("Category To Assign Level Too", selectedCategoryValue, categories);

            if (gameLevelName != null && gameLevelName != "" && hasEmptySceneName == false && hasEmptyDependency == false && doesLevelNameExist == false && scenesToCreateInGameLevel.Count > 0)
            {
                if (GUILayout.Button("Create Level"))
                {
                    CreateLevel();
                }
            }
        }