public override void OnInspectorGUI() { Generator tar = (Generator)target; //EditorGUI.ProgressBar(Rect, value:, label); //Colors Color col_egg = new Color(), col_black = new Color(), col_semiblack = new Color(); ColorUtility.TryParseHtmlString("#eaf0ce", out col_egg); ColorUtility.TryParseHtmlString("#333232", out col_black); ColorUtility.TryParseHtmlString("#474647", out col_semiblack); //Styling GUIContent content = new GUIContent(); GUIStyle style = new GUIStyle(GUI.skin.button), labelstyle = EditorStyles.boldLabel, generateButton = new GUIStyle(GUI.skin.button), elementBtn = new GUIStyle(GUI.skin.button); style.imagePosition = ImagePosition.ImageLeft; style.fixedHeight = style.fixedWidth = 32; elementBtn.fontStyle = FontStyle.Bold; elementBtn.onActive.textColor = col_egg; elementBtn.onNormal.textColor = col_egg; elementBtn.active.textColor = col_semiblack; generateButton.active.textColor = col_black; generateButton.normal.textColor = col_semiblack; generateButton.onHover.textColor = col_black; generateButton.fontStyle = FontStyle.Bold; generateButton.padding = new RectOffset(10, 10, 10, 5); labelstyle.normal.textColor = col_egg; //Load Icons folderIcon = Resources.Load("Folder") as Texture; content.image = (Texture2D)folderIcon; content.tooltip = "Load a main directory folder where all the ." + FILE_TYPE + " files are located."; //File loading GUI.backgroundColor = col_semiblack; GUILayout.BeginVertical("Box"); GUILayout.Label("File Loading", labelstyle); GUI.backgroundColor = col_black; GUILayout.BeginHorizontal("box"); GUI.backgroundColor = col_egg; if (GUILayout.Button(content, style)) { path = EditorUtility.OpenFolderPanel("Select ." + FILE_TYPE + " directory", "", FILE_TYPE); currentDir = new DirectoryInfo(path); SaveSettings(); FileInfo[] info = currentDir.GetFiles("*." + FILE_TYPE); foreach (FileInfo f in info) { files.Add(f.Name); } } GUI.backgroundColor = Color.white; if (path.Length <= 1) { buttonName = "Load Directory\n <--"; hasDirectory = false; } else { buttonName = "Directory loaded: \n" + Simplify(path); hasDirectory = true; } GUILayout.Box(buttonName, labelstyle); GUI.backgroundColor = col_egg; if (GUILayout.Button("Reset", elementBtn, GUILayout.Width(60))) { path = ""; currentDir = null; hasDirectory = false; } GUILayout.EndHorizontal(); //Open File Panel int labelSize = labelstyle.fontSize; if (hasDirectory) { GUILayout.BeginVertical("Box"); FileInfo[] files = GetFileList(); for (int i = 0; i < files.Length; i++) { if (save.file == files[i].Name) { GUI.backgroundColor = col_semiblack; labelstyle.normal.textColor = col_egg; labelstyle.fontSize = 12; } else { GUI.backgroundColor = col_egg; labelstyle.normal.textColor = col_semiblack; labelstyle.fontSize = labelSize; } GUILayout.BeginHorizontal("box"); if (GUILayout.Button(files[i].Name, labelstyle)) { save.file = files[i].Name; ScanFileType(); } GUILayout.EndHorizontal(); } if (save.file != lastFile) { SaveSettings(); } GUILayout.EndVertical(); } GUILayout.EndVertical(); //Reset style vars labelstyle.fontSize = labelSize; labelstyle.normal.textColor = col_egg; //GameType if (hasDirectory) { GUILayout.Space(10); GUI.backgroundColor = col_semiblack; GUILayout.BeginVertical("Box"); GUILayout.Label("Game Type", EditorStyles.boldLabel); string[] names = new string[Generator.AMOUNT_GAMEMODES()]; for (int i = 0; i < names.Length; i++) { names[i] = ((Generator.GameType[])System.Enum.GetValues(typeof(Generator.GameType)))[i].ToString().Replace('_', ' '); } GUI.backgroundColor = col_egg; elementBtn.padding = new RectOffset(0, 0, 5, 5); save.mode = GUILayout.SelectionGrid(save.mode, names, 2, elementBtn); GUILayout.EndVertical(); if (save.mode != lastMode) { SaveSettings(); } GUILayout.Space(10); //Preview Window GUI.backgroundColor = col_semiblack; GUILayout.BeginVertical("Box"); GUILayout.Label("Preview", EditorStyles.boldLabel); GUI.backgroundColor = col_egg; if (GUILayout.Button("Open Level Editor", generateButton)) { } GUILayout.EndVertical(); GUILayout.Space(5); //Generate button GUI.backgroundColor = col_semiblack; GUILayout.BeginVertical("Box"); GUILayout.Label("Generation", EditorStyles.boldLabel); GUI.backgroundColor = col_egg; if (GUILayout.Button("Generate Level", generateButton)) { tar.Generate(); } GUILayout.EndVertical(); GUILayout.Space(5); } }
public override void OnInspectorGUI() { Generator tar = (Generator)target; //Load Icons folderIcon = Resources.Load("Folder") as Texture; GUIContent content = new GUIContent(); content.image = (Texture2D)folderIcon; content.tooltip = "Load a main directory folder where all the ." + FILE_TYPE + " files are located."; GUIStyle style = new GUIStyle(GUI.skin.button); style.imagePosition = ImagePosition.ImageLeft; //style.font = Resources.Load("BM") as Font; style.fixedHeight = style.fixedWidth = 32; //File loading GUILayout.BeginVertical("Box"); GUILayout.Label("File Loading", EditorStyles.boldLabel); GUILayout.BeginHorizontal(""); Color col = new Color(); ColorUtility.TryParseHtmlString("#eaf0ce", out col); GUI.backgroundColor = col; if (GUILayout.Button(content, style)) { path = EditorUtility.OpenFolderPanel("Select ." + FILE_TYPE + " directory", "", FILE_TYPE); DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] info = dir.GetFiles("*." + FILE_TYPE); foreach (FileInfo f in info) { files.Add(f.Name); } } GUI.backgroundColor = Color.white; if (path.Length <= 1) { buttonName = "Load Directory"; } else { buttonName = "File loaded: \n" + Simplify(path); } GUILayout.TextField(buttonName, GUILayout.Width(204)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); //GameType GUILayout.Space(10); GUILayout.BeginVertical("Box"); GUILayout.Label("Game Type", EditorStyles.boldLabel); string[] names = new string[Generator.AMOUNT_GAMEMODES()]; for (int i = 0; i < names.Length; i++) { names[i] = ((Generator.GameType[])System.Enum.GetValues(typeof(Generator.GameType)))[i].ToString().Replace('_', ' '); } mode = GUILayout.SelectionGrid(mode, names, 2); GUILayout.EndVertical(); GUILayout.Space(20); if (GUILayout.Button("Generate Level")) { tar.Generate(); } GUILayout.Space(5); }