private void TopPanel() { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("For Configuration: "); if (MadGUI.Button(configuration.name, Color.cyan)) { Selection.activeObject = configuration; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); int extensionCount = configuration.extensions.Count; if (extensionCount > 0) { MadGUI.LookLikeControls(120, 150); selectedExtensionIndex = MadGUI.DynamicPopup(selectedExtensionIndex, "Current Extension:", extensionCount, (index) => { var extension = configuration.extensions[index]; return(extension.name); }); MadGUI.LookLikeControls(0); GUILayout.FlexibleSpace(); if (MadGUI.Button("Remove", Color.red)) { RemoveExtension(selectedExtensionIndex); } } else { GUILayout.Label("There's no extensions yet."); } GUILayout.Space(10); if (MadGUI.Button("Create New Extension", Color.green)) { var builder = new MadInputDialog.Builder("Create New Extension", "Enter a new extension name.", (result) => { if (!string.IsNullOrEmpty(result)) { var extension = CreateNewExtension(result); if (extension != null) { currentExtension = extension; } } }); builder.BuildAndShow(); } EditorGUILayout.EndHorizontal(); }
private MadLevelExtension CreateNewExtension(string name) { if (ExtensionExists(name)) { EditorUtility.DisplayDialog("Extension exists!", "Extension with name '" + name + "' already exists!", "OK"); return(null); } MadUndo.RecordObject2(configuration, "Create New Extension"); var extension = new MadLevelExtension(name); configuration.extensions.Add(extension); EditorUtility.SetDirty(configuration); Repaint(); return(extension); }
private void TopPanel() { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("For Configuration: "); if (MadGUI.Button(configuration.name, Color.cyan)) { Selection.activeObject = configuration; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); int extensionCount = configuration.extensions.Count; if (extensionCount > 0) { MadGUI.LookLikeControls(120, 150); selectedExtensionIndex = MadGUI.DynamicPopup(selectedExtensionIndex, "Current Extension:", extensionCount, (index) => { var extension = configuration.extensions[index]; return extension.name; }); MadGUI.LookLikeControls(0); GUILayout.FlexibleSpace(); if (MadGUI.Button("Remove", Color.red)) { RemoveExtension(selectedExtensionIndex); } } else { GUILayout.Label("There's no extensions yet."); } GUILayout.Space(10); if (MadGUI.Button("Create New Extension", Color.green)) { var builder = new MadInputDialog.Builder("Create New Extension", "Enter a new extension name.", (result) => { if (!string.IsNullOrEmpty(result)) { var extension = CreateNewExtension(result); if (extension != null) { currentExtension = extension; } } }); builder.BuildAndShow(); } EditorGUILayout.EndHorizontal(); }
private MadLevelExtension CreateNewExtension(string name) { if (ExtensionExists(name)) { EditorUtility.DisplayDialog("Extension exists!", "Extension with name '" + name + "' already exists!", "OK"); return null; } MadUndo.RecordObject2(configuration, "Create New Extension"); var extension = new MadLevelExtension(name); configuration.extensions.Add(extension); EditorUtility.SetDirty(configuration); Repaint(); return extension; }