public static void Open(String title, Action <String> onNamneEntered) { Name = ""; Title = title; OnNamneEntered = onNamneEntered; Window = (EnterNameWindow)EditorWindow.GetWindow(typeof(EnterNameWindow)); Window.Show(); }
private void DrawLeftSide() { int y = Offset; GUI.Label(new Rect(Offset, y, 180, LineHeight), "Level Name:"); y += LineHeight; if (WorldData == null) { GUI.Label(new Rect(Offset, y, 180, LineHeight), "Create NEW or LOAD world!"); } else { WorldData.WorldName = GUI.TextField(new Rect(Offset, y, 150, LineHeight), WorldData.WorldName); } y += LineHeight + Offset; WorldData = (IsometricWorldData)EditorGUI.ObjectField(new Rect(Offset, y, 180, LineHeight), WorldData, typeof(IsometricWorldData), false); y += LineHeight + Offset; int numberOfButtons = 2; float button_width = (LeftWidth - (numberOfButtons + 1) * Offset) / numberOfButtons; if (GUI.Button(new Rect(Offset, y, button_width, LineHeight), "NEW")) { SaveWorld(); EnterNameWindow.Open("Enter world name:", CreateNewWorld); } EditorGUI.BeginDisabledGroup(WorldData == null); if (GUI.Button(new Rect(Offset * 2 + button_width, y, button_width, LineHeight), "DELETE")) { AssetDatabase.DeleteAsset(WorldDataPath + WorldData.name + ".asset"); WorldData = null; SaveWorld(); } EditorGUI.EndDisabledGroup(); y += LineHeight + Offset; EditorGUI.BeginDisabledGroup(true); if (GUI.Button(new Rect(Offset, y, button_width, LineHeight), "LOAD")) { //TODO } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(WorldData == null); if (GUI.Button(new Rect(Offset * 2 + button_width, y, button_width, LineHeight), "SAVE")) { SaveWorld(); } EditorGUI.EndDisabledGroup(); y += LineHeight + Offset; GUI.Box(new Rect(0, y, LeftWidth, LineWidth), ""); y += Offset; }
public override void OnInspectorGUI() { if (WorldEditor == null) { WorldEditor = (WorldEditor)target; if (WorldEditor == null) { return; } } GUILayout.Space(10f); WorldEditor.TileSetData = (TileSetData)EditorGUILayout.ObjectField(WorldEditor.TileSetData, typeof(TileSetData), false); WorldEditor.WorldData = (WorldData)EditorGUILayout.ObjectField(WorldEditor.WorldData, typeof(WorldData), false); GUILayout.Space(10f); GUILayout.Label("World data functions:"); GUILayout.BeginHorizontal(); if (GUILayout.Button("NEW")) { SaveWorld(); EnterNameWindow.Open("Enter world name:", CreateNewWorld); } Color startColor = GUI.color; if (WorldEditor.WorldData != null && LoadedTiles.Count <= 0) { GUI.color = Color.green; } EditorGUI.BeginDisabledGroup(WorldEditor.WorldData == null); if (GUILayout.Button("LOAD")) { LoadWorld(); } GUI.color = startColor; EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(WorldEditor.WorldData == null || LoadedTiles.Count == 0); if (GUILayout.Button("UNLOAD")) { SaveWorld(); UnloadWorld(); } if (GUILayout.Button("SAVE")) { SaveWorld(); } EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); if (WorldEditor.WorldData == null || LoadedTiles.Count <= 0) { return; } if (WorldEditor.TileSetData.ShowTileInEditor == null || WorldEditor.TileSetData.ShowTileInEditor.Length != WorldEditor.TileSetData.Tiles.Length) { WorldEditor.TileSetData.ShowTileInEditor = new bool[WorldEditor.TileSetData.Tiles.Length]; } GUILayout.Space(5f); GUILayout.Label("Select edit type:"); GUILayout.BeginHorizontal(); foreach (EditType type in Enum.GetValues(typeof(EditType))) { if (type == CurrentEditType) { GUI.color = Color.green; } if (GUILayout.Button(type.ToString())) { CurrentEditType = type; if (CurrentHumanSpawnerIndex < HumanSpanerGameObjects.Count && CurrentHumanSpawnerIndex >= 0) { if (type == EditType.HumanAI) { HumanSpanerGameObjects[CurrentHumanSpawnerIndex].SetActive(true); } else { HumanSpanerGameObjects[CurrentHumanSpawnerIndex].SetActive(false); } } if (CurrentCarAiIndex < CarAiGameObjets.Count && CurrentCarAiIndex >= 0) { if (type == EditType.CarAI) { foreach (GameObject locator in CarAiGameObjets[CurrentCarAiIndex]) { locator.SetActive(true); } } else { foreach (GameObject locator in CarAiGameObjets[CurrentCarAiIndex]) { locator.SetActive(false); } } } } GUI.color = startColor; } GUILayout.EndHorizontal(); switch (CurrentEditType) { case EditType.World: DrawWorldEdit(); break; case EditType.HumanAI: DrawHumanAIEdit(); break; case EditType.CarAI: DrawCarAiEdit(); break; } }