private void FieldLiveBounds() { int texWidth = sprite.currentTextureWidth; int texHeight = sprite.currentTextureHeight; MadGUI.PropertyField(hasLiveBounds, "Has Border"); GUI.backgroundColor = Color.yellow; MadGUI.Indent(() => { MadGUI.LookLikeControls(0, 40); FieldLiveBounds(liveLeft, texWidth, "Left", 0, liveRight.floatValue); FieldLiveBounds(liveTop, texHeight, "Top", liveBottom.floatValue, 1); FieldLiveBounds(liveRight, texWidth, "Right", liveLeft.floatValue, 1); FieldLiveBounds(liveBottom, texHeight, "Bottom", 0, liveTop.floatValue); MadGUI.LookLikeControls(0); }); GUI.backgroundColor = Color.white; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (MadGUI.Button("Reset")) { ResetLiveBounds(); } if (MadGUI.Button("Compute")) { MadUndo.RecordObject2(sprite, "Set Live Bounds"); ComputeLiveBounds(); } EditorGUILayout.EndHorizontal(); }
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 void SceneList(string label, List <MadLevelScene> scenes) { GUILayout.Label(label, "HeaderLabel"); int counter = 1; new MadGUI.ArrayList <MadLevelScene>(scenes, (scene) => { MadGUI.Validate(() => scene.sceneObject != null, () => { MadGUI.LookLikeControls(70); scene.sceneObject = MadGUI.SceneField(scene.sceneObject, "Scene " + (counter++)); MadGUI.LookLikeControls(0); }); return(scene); }).Draw(); }
void GUIGroupPopup() { MadGUI.Box("Groups", () => { EditorGUILayout.BeginHorizontal(); MadGUI.LookLikeControls(75); currentGroupIndex = EditorGUILayout.Popup("Group", currentGroupIndex, GroupNames()); MadGUI.LookLikeControls(0); if (MadGUI.Button("Edit Groups", Color.green, GUILayout.Width(100))) { MadLevelGroupsEditTool.Display(configuration); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); }); }
void GUIGroupPopup() { MadGUI.Box("Groups", () => { EditorGUILayout.BeginHorizontal(); MadGUI.LookLikeControls(75); currentGroupIndex = EditorGUILayout.Popup("Group", currentGroupIndex, GroupNames()); MadGUI.LookLikeControls(0); GUI.enabled = currentGroup != configuration.defaultGroup; if (MadGUI.Button("X", Color.red, GUILayout.Width(20))) { RemoveGroup(currentGroup); } if (MadGUI.Button("Rename", Color.yellow, GUILayout.Width(70))) { RenameGroup(currentGroup); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); MadGUI.Indent(() => { newGroupName = EditorGUILayout.TextField("New Group", newGroupName); GUI.enabled = !string.IsNullOrEmpty(newGroupName); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add", GUILayout.Width(40))) { if (AddGroup(newGroupName)) { // newGroupName = ""; } } GUI.backgroundColor = Color.white; GUI.enabled = true; }); EditorGUILayout.EndHorizontal(); }); }
private void FieldLiveBounds() { int texWidth = sprite.currentTextureWidth; int texHeight = sprite.currentTextureHeight; MadGUI.PropertyField(hasLiveBounds, "Has Border"); MadGUI.PropertyField(renderLiveBoundsOnly, "Cut Texture"); if (renderLiveBoundsOnly.boolValue && (sprite.fillType == MadSprite.FillType.RadialCCW || sprite.fillType == MadSprite.FillType.RadialCW)) { MadGUI.Error("Cut not supported for radial fill"); } GUI.backgroundColor = Color.yellow; MadGUI.Indent(() => { MadGUI.LookLikeControls(0, 40); FieldLiveBounds(liveLeft, texWidth, "Left", 0, liveRight.floatValue); FieldLiveBounds(liveTop, texHeight, "Top", liveBottom.floatValue, 1); FieldLiveBounds(liveRight, texWidth, "Right", liveLeft.floatValue, 1); FieldLiveBounds(liveBottom, texHeight, "Bottom", 0, liveTop.floatValue); MadGUI.LookLikeControls(0); }); GUI.backgroundColor = Color.white; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (MadGUI.Button("Reset")) { ResetLiveBounds(); } if (MadGUI.Button("Compute")) { MadUndo.RecordObject2(sprite, "Set Live Bounds"); ComputeLiveBounds(); } EditorGUILayout.EndHorizontal(); }
private void Properties() { MadGUI.BeginBox("Children"); MadGUI.Indent(() => { MadGUI.Info("Properties are persistent values saved and loaded from the current game state. " + "They are good for things like stars or medals."); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Create:"); GUI.backgroundColor = Color.green; if (GUILayout.Button("Empty")) { if (ShouldCreateProperty()) { CreateEmptyProperty(); } else { CreateEmpty(); } } if (GUILayout.Button("Sprite")) { if (ShouldCreateProperty()) { CreateSpriteProperty(); } else { CreateSprite(); } } if (GUILayout.Button("Text")) { if (ShouldCreateProperty()) { CreateTextProperty(); } else { CreateText(); } } GUI.color = Color.white; GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); var properties = PropertyList(); foreach (MadLevelProperty property in properties) { GUILayout.BeginHorizontal(); MadGUI.LookLikeControls(0, 150); property.name = EditorGUILayout.TextField(property.name, GUILayout.Width(120)); MadGUI.LookLikeControls(0); //GUILayout.Label(property.name, GUILayout.Width(170)); GUILayout.FlexibleSpace(); GUILayout.Label("Default State: "); if (property.linked) { if (MadGUI.Button("LINKED", Color.cyan, GUILayout.Width(60))) { if (EditorUtility.DisplayDialog( "State Linked", "This property state is linked by '" + property.linkage.name + "' property and cannot be changed directly. Do you want to select the linkage owner?", "Yes", "No")) { Selection.activeObject = property.linkage.gameObject; } } } else if (property.propertyEnabled) { if (MadGUI.Button("ON", Color.green, GUILayout.Width(60))) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } } else { if (MadGUI.Button("OFF", Color.red, GUILayout.Width(60))) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } } GUILayout.FlexibleSpace(); GUI.backgroundColor = Color.yellow; if (GUILayout.Button("Select", GUILayout.Width(55))) { Selection.activeGameObject = property.gameObject; } GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); } }); EditorGUILayout.Space(); MadGUI.Info("Level icon's text value will be set to current level number."); if (TextList().Count == 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Level Number"); if (MadGUI.Button("Create New", Color.green)) { var text = CreateText(); text.gameObject.name = "level number"; text.font = MadAssets.TryLoadComponent <MadFont>(DefaultFontGUID); text.text = "1"; text.scale = 90; levelIcon.levelNumber = text; } EditorGUILayout.EndHorizontal(); } else { MadGUI.PropertyFieldObjectsPopup <MadText>( target, "Level Number", ref levelIcon.levelNumber, TextList(), false ); } MadGUI.EndBox(); }