private void OnGUI() { int numberOfItems = 0; foreach (GameModeProperties gameModeProperties in Resources.LoadAll("Data/Game Mode Properties/")) { numberOfItems++; } scenesEnabled = numberOfItems > 0; EditorGUILayout.Space(); GUIStyle bannerStyle = new GUIStyle { alignment = TextAnchor.MiddleCenter, fontSize = 15, fontStyle = FontStyle.Bold }; EditorGUILayout.LabelField("Game Generator", bannerStyle); EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Game Mode configuration")) { GameModeGeneratorWindow.OpenWindow(); } EditorGUI.BeginDisabledGroup(!scenesEnabled); if (GUILayout.Button("Scene generator")) { SceneGeneratorWindow.OpenWindow(); } if (GUILayout.Button("Player configuration")) { PlayerGeneratorWindow.OpenWindow(); } if (GUILayout.Button("Level configuration")) { LevelConfigurationWindow.OpenWindow(); } EditorGUI.EndDisabledGroup(); }
void CreateScriptable() { //ACA TE TIRA UN CARTEL DE UNITY QUE NO TE DEJA HACER NADA if (EditorUtility.DisplayDialog("Attention", "Is this information ok? " + "\n" + "\n" + selectedPers + "\n" + selectedMode + "\n" + selectedObj + "\n" + "LEVELS: " + howManyLevels, "Yes", "No")) { if (scriptable == null) { scriptable = CreateInstance <GameModeProperties>(); //SI NO SE CREO ANTES, SE CREA AHORA EL SCRIPTABLEOBJ } scriptable.amountOfLevels = howManyLevels; if (!AssetDatabase.IsValidFolder("Assets/Resources/Data")) { AssetDatabase.CreateFolder("Assets/Resources", "Data"); Debug.Log("The introduced folder doesn't exist, so I just created a default one for you."); AssetDatabase.Refresh(); } var path = AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/Data/Game Mode Properties/Level_Properties.asset"); //SE CREA UN PATH DONDE GUARDAR EL SCRIPTABLE gameModePage = true; propertiesPage = false; //SE VUELVE A LA PAGINA DONDE SE ELIGE EL GAMEMODE AssetDatabase.CreateAsset(scriptable, path); //SE PONE EL SCRIPTABLE EN EL PATH for (int i = 0; i < howManyLevels; i++) //ACA SE CREAN LAS ESCENAS DEPENDIENDO LA PERSPECTIVA CON EL NOMBRE LEVEL0 { if (scriptable.pers == Perspective.side) { if (scriptable.gm == GameMode.endless) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestEndlessSide.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else if (scriptable.gm == GameMode.platform) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestPlatSide.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestSurSide.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } } if (scriptable.pers == Perspective.top) { if (scriptable.gm == GameMode.endless) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestEndlessTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else if (scriptable.gm == GameMode.platform) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestPlatTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } } if (scriptable.pers == Perspective.third) { if (scriptable.gm == GameMode.endless) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestEndlessTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else if (scriptable.gm == GameMode.platform) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestPlatTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } } if (scriptable.pers == Perspective.iso) { if (scriptable.gm == GameMode.endless) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestEndlessTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else if (scriptable.gm == GameMode.platform) { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestPlatTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } else { AssetDatabase.CopyAsset("Assets/Scenes/MatiTestTop.unity", "Assets/Resources/Prefabs/Level" + i + ".unity"); } } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorSceneManager.OpenScene("Assets/Resources/Prefabs/Level0.unity"); //SE ABRE EL PRIMER NIVEL var manager = FindObjectOfType <GameManager>();// SETEO LOS VALORES DEL MANAGER DEL NUEVO NIVEL manager.scriptable = scriptable; if (scriptable.objPlatform == ObjectivePlatformer.CollectCoins) { manager.objPlatform.SetActive(false); } else if (scriptable.objPlatform == ObjectivePlatformer.GetToPointB) { manager.objPlatform.SetActive(false); } manager.myscenes = new UnityEngine.SceneManagement.Scene[howManyLevels]; manager.amountScenes = howManyLevels; for (int i = 0; i < howManyLevels; i++) //ACA QUISE CONSEGUIR TODAS LAS ESCENAS CREADAS Y GUARDARLAS EN UNA VARIABLE EN EL MANAGER DEL NIVEL { manager.myscenes[i] = UnityEngine.SceneManagement.SceneManager.GetSceneByPath("Assets/Resources/Prefabs/Level" + i + ".unity"); } PlayerGeneratorWindow.OpenWindow(); scriptable = null; //EL SCRIPTABLE DE LA VENTANA SE HACE NULL, Y SE VA A CREAR UNA DE CERO } }