public static void OnEditorGUIExpired(string toolName) { MadGUI.Error("This is an evaluation version of " + toolName + " and your evaluation period has expired. If you want to continue using " + toolName + " please purchase it or send a request for another evaluation period."); EditorGUILayout.Space(); if (MadGUI.Button("Purchase", Color.yellow)) { Application.OpenURL(PurchaseUrl); } EditorGUILayout.Space(); if (MadGUI.Button("Request Another Evaluation Period", Color.magenta)) { RequestExtend(toolName); } if (MadGUI.Button("I Have An Evaluation Key!", Color.green)) { var builder = new MadInputDialog.Builder("Enter Key", "Enter new evaluation key.", (key) => { if (!string.IsNullOrEmpty(key)) { Extend(key.Trim()); } }); builder.BuildAndShow(); } }
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(); }
void OnGUI() { var arrayList = new MadGUI.ArrayList <MadLevelConfiguration.Group>(conf.groups, @group => { if (MadGUI.Button(@group.name)) { var builder = new MadInputDialog.Builder("Rename group " + @group.name, "New name for group " + @group.name, newName => TryRename(@group, newName)); builder.BuildAndShow(); } return(@group); }); arrayList.beforeRemove += @group => { if ( !EditorUtility.DisplayDialog("Remove Group", "Are you sure that you want to remove group " + @group.name + "?", "Yes", "No")) { return(false); } if (group.GetLevels().Count > 0) { MadUndo.RecordObject2(conf, "Remove Group"); if (EditorUtility.DisplayDialog("Remove Levels As Well?", "Do you want to remove all levels in this group as well? " + "If no, all levels will be moved to default group.", "Yes", "No")) { var levels = group.GetLevels(); conf.levels.RemoveAll((level) => levels.Contains(level)); } else { var defaultGroup = conf.defaultGroup; var levels = group.GetLevels(); foreach (var level in levels) { level.groupId = defaultGroup.id; } } } return(true); }; arrayList.beforeAdd = () => MadUndo.RecordObject2(conf, "Add Group"); arrayList.createFunctionGeneric = CreateGroup; if (arrayList.Draw()) { EditorUtility.SetDirty(conf); } }
void OnGUI() { MadGUI.Info("To create a generator, implement IMadLevelGenerator interface and place your script in any Editor folder."); if (generators.Count == 0) { MadGUI.Error("I cannot found any generator in your project. Please implement at least one!"); return; } chosenGeneratorIndex = EditorGUILayout.Popup("Generator", chosenGeneratorIndex, generators.ToArray()); MadLevelConfiguration conf = MadLevelConfiguration.GetActive(); chosenGroupIndex = EditorGUILayout.Popup("Group", chosenGroupIndex, GroupNames(conf)); scene = EditorGUILayout.ObjectField("Scene", scene, typeof(Object), false); levelsCount = EditorGUILayout.IntField("Level Count", levelsCount); GUI.enabled = scene != null; if (MadGUI.Button("Create")) { string generatorName = generators[chosenGeneratorIndex]; Type generatorType = Type.GetType(generatorName + ", Assembly-CSharp-Editor"); var generator = Activator.CreateInstance(generatorType) as IMadLevelGenerator; MadLevelConfiguration.Group group; if (chosenGroupIndex == 0) { group = conf.defaultGroup; } else { group = conf.groups[chosenGroupIndex - 1]; } for (int i = 1; i <= levelsCount; ++i) { MadLevelConfiguration.Level level = conf.CreateLevel(); level.sceneObject = scene; level.groupId = group.id; level.type = MadLevel.Type.Level; level.order = int.MaxValue; level.name = generator.GetLevelName(i); level.arguments = generator.GetLevelArguments(i); conf.levels.Add(level); conf.SetDirty(); } EditorUtility.SetDirty(conf); } }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(dragBounds, "Drag Area"); EditorGUILayout.Space(); MadGUI.ConditionallyEnabled(HasBackground(), () => { if (MadGUI.Button("Resize Drag Area To Background", Color.yellow)) { ResizeDragAreaToBackground(); } }); EditorGUILayout.Space(); MadGUI.PropertyFieldEnumPopup(scaleMode, "Allow Scaling"); MadGUI.ConditionallyEnabled(script.scaleMode == MadFreeDraggable.ScaleMode.Free, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scalingMin, "Scaling Min"); MadGUI.PropertyField(scalingMax, "Scaling Max"); }); }); EditorGUILayout.Space(); MadGUI.PropertyField(moveEasing, "Move Easing"); MadGUI.ConditionallyEnabled(moveEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(moveEasingType, "Type"); MadGUI.PropertyField(moveEasingDuration, "Duration"); }); }); EditorGUILayout.Space(); MadGUI.PropertyField(scaleEasing, "Scale Easing"); MadGUI.ConditionallyEnabled(scaleEasing.boolValue, () => { MadGUI.Indent(() => { MadGUI.PropertyField(scaleEasingType, "Type"); MadGUI.PropertyField(scaleEasingDuration, "Duration"); }); }); serializedObject.ApplyModifiedProperties(); }
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(); }
public static void OnEditorGUIExpired(string toolName) { MadGUI.Error("This is an evaluation version of " + toolName + " and your evaluation period has expired. If you want to continue using " + toolName + " please purchase it or send a request for another evaluation period."); EditorGUILayout.Space(); if (MadGUI.Button("Purchase", Color.yellow)) { Application.OpenURL(PurchaseUrl); } EditorGUILayout.Space(); if (MadGUI.Button("Request Another Evaluation Period", Color.magenta)) { RequestExtend(toolName); } if (MadGUI.Button("I Have An Evaluation Key!", Color.green)) { EnterEvaluationKeyDialog(); } }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } LoadTextures(); // loading textures with delay to prevent editor errors CheckAssetLocation(); ActiveInfo(); GUIGroupPopup(); LoadItems(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(GUILayout.Width(1)); GUILayout.Space(200); EditorGUILayout.EndVertical(); list.Draw(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add")) { AddLevel(); } GUI.backgroundColor = Color.white; GUI.enabled = list.selectedItem != null; GUI.backgroundColor = Color.red; if (GUILayout.Button("Remove") || GUI.enabled && Event.current.keyCode == KeyCode.Delete) { RemoveLevel(); } GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.Label("Move"); if (GUILayout.Button("Down")) { MoveDown(); configuration.SetDirty(); } if (GUILayout.Button("Up")) { MoveUp(); configuration.SetDirty(); } GUILayout.Space(10); if (GUILayout.Button("Bottom")) { MoveToBottom(); configuration.SetDirty(); } if (GUILayout.Button("Top")) { MoveToTop(); configuration.SetDirty(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); MadGUI.IndentBox("Level Properties", () => { var item = list.selectedItem; var items = list.selectedItems; if (item == null) { item = new LevelItem(configuration); GUI.enabled = false; } MadUndo.RecordObject(configuration, "Edit '" + item.level.name + "'"); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); UnityEngine.Object sceneValue = null; if (!multiSelection) { MadGUI.Validate(() => item.level.sceneObject != null, () => { sceneValue = EditorGUILayout.ObjectField("Scene", item.level.sceneObject, typeof(UnityEngine.Object), false); }); } else { bool unified = (from i in items select i.level.sceneObject).Distinct().Count() == 1; if (unified) { sceneValue = EditorGUILayout.ObjectField("Scene", item.level.sceneObject, typeof(UnityEngine.Object), false); } else { sceneValue = EditorGUILayout.ObjectField("Scene", null, typeof(UnityEngine.Object), false); } } if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Level Scene"); foreach (var levelItem in items) { levelItem.level.sceneObject = sceneValue; } } GUI.backgroundColor = Color.yellow; if (GUILayout.Button("Set Current", GUILayout.Width(85))) { MadUndo.RecordObject2(target, "Change Scene"); #if UNITY_5 && !(UNITY_5_0 || UNITY_5_1 || UNITY_5_2) Scene activeScene = SceneManager.GetActiveScene(); var obj = AssetDatabase.LoadAssetAtPath(activeScene.name, typeof(UnityEngine.Object)); #else var obj = AssetDatabase.LoadAssetAtPath(EditorApplication.currentScene, typeof(UnityEngine.Object)); #endif if (obj != null) { foreach (var levelItem in items) { levelItem.level.sceneObject = obj; } } else { EditorUtility.DisplayDialog("Scene not saved", "Current scene is not saved. Please save it first (CTRL+S).", "OK"); } } GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); if (!CheckAssetIsScene(item.level.sceneObject)) { item.level.sceneObject = null; } MadGUI.Validate(() => !string.IsNullOrEmpty(item.level.name), () => { GUI.SetNextControlName("level name"); // needs names to unfocus using (MadGUI.EnabledIf(!multiSelection)) { if (!multiSelection) { EditorGUI.BeginChangeCheck(); var value = EditorGUILayout.TextField("Level Name", item.level.name); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Level Name"); item.level.name = value; } } else { EditorGUILayout.TextField("Level Name", "-"); } } }); // level type MadLevel.Type typeValue = default(MadLevel.Type); EditorGUI.BeginChangeCheck(); if (!multiSelection) { typeValue = (MadLevel.Type)EditorGUILayout.EnumPopup("Type", item.level.type); } else { bool unified = (from i in items select i.level.type).Distinct().Count() == 1; if (unified) { typeValue = (MadLevel.Type)EditorGUILayout.EnumPopup("Type", item.level.type); } else { int val = EditorGUILayout.Popup("Type", -1, Enum.GetNames(typeof(MadLevel.Type))); if (val != -1) { typeValue = (MadLevel.Type)val; } } } if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Level Type"); foreach (var levelItem in items) { levelItem.level.type = typeValue; } } GUI.SetNextControlName("arguments"); // needs names to unfocus if (!multiSelection) { EditorGUI.BeginChangeCheck(); var value = EditorGUILayout.TextField("Arguments", item.level.arguments); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Level Arguments"); item.level.arguments = value; } } else { bool unified = (from i in items select i.level.arguments).Distinct().Count() == 1; EditorGUI.BeginChangeCheck(); string value = ""; if (unified) { value = EditorGUILayout.TextField("Arguments", item.level.arguments); } else { value = EditorGUILayout.TextField("Arguments", "-"); } if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Level Arguments"); foreach (var levelItem in items) { levelItem.level.arguments = value; } } } if (MadGUI.Foldout("Locking", false)) { using (MadGUI.Indent()) { bool lockedByDefultState = false; if (multiSelection) { bool unified = (from i in items select i.level.lockedByDefault).Distinct().Count() == 1; if (unified && (item.level.lockedByDefault)) { lockedByDefultState = true; } } else { lockedByDefultState = item.level.lockedByDefault; } EditorGUI.BeginChangeCheck(); GUI.SetNextControlName("locked by default"); // needs names to unfocus bool lockedByDefaultValue = EditorGUILayout.Toggle("Locked By Default", lockedByDefultState); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Locked By Default"); foreach (var levelItem in items) { levelItem.level.lockedByDefault = lockedByDefaultValue; } } } EditorGUILayout.Space(); } if (MadGUI.Foldout("Extensions", false)) { using (MadGUI.Indent()) { EditorGUI.BeginChangeCheck(); int extensionIndex = -1; if (!multiSelection) { extensionIndex = configuration.extensions.FindIndex((e) => e == item.level.extension) + 1; } else { bool unified = (from i in items select i.level.extension).Distinct().Count() == 1; if (unified) { extensionIndex = configuration.extensions.FindIndex((e) => e == item.level.extension) + 1; } } extensionIndex = MadGUI.DynamicPopup(extensionIndex, "Extension", configuration.extensions.Count + 1, (index) => { if (index == 0) { return("(none)"); } else { return(configuration.extensions[index - 1].name); } }); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(target, "Changed Extension For Level"); foreach (var levelItem in items) { if (extensionIndex == 0) { levelItem.level.extension = null; } else { levelItem.level.extension = configuration.extensions[extensionIndex - 1]; } } configuration.SetDirty(); } bool enabledState = GUI.enabled; GUI.enabled = true; if (MadGUI.Button("Open Extension Editor", Color.magenta)) { MadLevelExtensionEditor.Show(configuration); } GUI.enabled = enabledState; EditorGUILayout.Space(); } } EditorGUI.BeginChangeCheck(); int groupIndex = GroupToIndex(item.level.group); groupIndex = EditorGUILayout.Popup("Move To Group:", groupIndex, GroupNames()); if (EditorGUI.EndChangeCheck()) { var @group = IndexToGroup(groupIndex); MadUndo.RecordObject2(target, "Move Levels To Group " + @group.name); foreach (var levelItem in items) { levelItem.level.group = @group; } } if (EditorGUI.EndChangeCheck()) { configuration.SetDirty(); } if (inspectorAddons.Count > 0) { EditorGUILayout.Space(); } foreach (var addon in inspectorAddons) { addon.OnInspectorGUI(item.level); } GUI.enabled = true; }); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Help")) { Help.BrowseURL(MadLevelHelp.LevelConfigurationHelp); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (!configuration.IsValid()) { MadGUI.Error("Configuration is invalid. Please make sure that:\n" + "- There's no levels with \"!!!\" icon. These levels may have duplicated name or missing scene.\n" + "- All your extensions have no missing scenes (in Extension Editor)" ); } if (configuration.active && !MadLevelConfigurationEditor.CheckBuildSynchronized(configuration)) { if (MadGUI.ErrorFix( "Build configuration is not in synch with level configuration.", "Synchronize Now")) { MadLevelConfigurationEditor.SynchronizeBuild(configuration); } } ExecuteDelayed(); }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); EditorGUILayout.Space(); if (MadGUI.Button("Select Parent Icon", Color.yellow)) { Selection.activeObject = property.icon.gameObject; } EditorGUILayout.Space(); GUILayout.Label("Property", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { EditorGUILayout.Space(); GUILayout.Label("Property Name: " + property.name); EditorGUILayout.BeginHorizontal(); GUILayout.Label("State"); GUILayout.FlexibleSpace(); 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(50))) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } } else { if (MadGUI.Button("Off", Color.red, GUILayout.Width(50))) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } } EditorGUILayout.EndHorizontal(); if (property.GetComponent <MadText>() != null) { EditorGUILayout.Space(); MadGUI.PropertyField(textFromProperty, "Text From Property"); MadGUI.ConditionallyEnabled(textFromProperty.boolValue, () => { MadGUI.PropertyField(textPropertyName, "Text Property Name"); }); } }); GUILayout.Label("Connections", "HeaderLabel"); EditorGUILayout.Space(); MadGUI.Indent(() => { bool connectionChanged; GUILayout.Label("Things to show when this property is enabled:"); connectionChanged = new MadGUI.ArrayList <GameObject>(showWhenEnabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } EditorGUILayout.Space(); GUILayout.Label("Things to show when this property is disabled:"); connectionChanged = new MadGUI.ArrayList <GameObject>(showWhenDisabled, (p) => { MadGUI.PropertyField(p, ""); }).Draw(); if (connectionChanged) { property.icon.ApplyConnections(); } }); serializedObject.ApplyModifiedProperties(); }
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(); }
// =========================================================== // Methods // =========================================================== void OnGUI() { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); MadGUI.BeginBox("Profiles"); MadGUI.Indent(() => { int currentProfileIndex = 0; string[] profiles = MadLevelProfile.profileList; for (int i = 0; i < profiles.Length; ++i) { string profile = profiles[i]; if (profile == MadLevelProfile.profile) { profiles[i] = profile + " (Current)"; currentProfileIndex = i; } } selectedProfileIndex = EditorGUILayout.Popup("Profiles", selectedProfileIndex, profiles); onCurrentProfile = currentProfileIndex == selectedProfileIndex; selectedProfileName = MadLevelProfile.profileList[selectedProfileIndex]; if (onCurrentProfile) { GUI.enabled = false; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Switch")) { SwitchProfile(selectedProfileName); } GUI.enabled = true; if (onCurrentProfile || selectedProfileName == MadLevelProfile.DefaultProfile) { GUI.enabled = false; } if (GUILayout.Button("Delete")) { DeleteProfile(selectedProfileName); } GUI.enabled = true; if (GUILayout.Button("Reset")) { ResetProfile(selectedProfileName); } EditorGUILayout.EndHorizontal(); }); MadGUI.BeginBox("New Profile"); EditorGUILayout.BeginHorizontal(); newProfileName = EditorGUILayout.TextField(newProfileName); if (string.IsNullOrEmpty(newProfileName)) { GUI.enabled = false; } if (GUILayout.Button("Create")) { CreateProfile(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); MadGUI.EndBox(); MadGUI.BeginBox("Save/Load"); GUILayout.Label("These actions will be taken on selected profile above."); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save Profile")) { SaveProfile(); } if (GUILayout.Button("Load Profile")) { LoadProfile(); } EditorGUILayout.EndHorizontal(); MadGUI.EndBox(); MadGUI.EndBox(); MadGUI.BeginBox("Toolbox"); EditorGUILayout.BeginHorizontal(); if (MadGUI.Button("Unlock All Levels")) { UnlockAllLevels(); } if (MadGUI.Button("Complete All Levels")) { CompleteAllLevels(); } EditorGUILayout.EndHorizontal(); MadGUI.EndBox(); EditorGUILayout.EndScrollView(); }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } serializedObject.UpdateIfDirtyOrScript(); GUILayout.Label("Fundaments", "HeaderLabel"); MadGUI.Indent(() => { ConfigurationField(); if (script.currentConfiguration != null) { var group = script.currentConfiguration.FindGroupById(script.configurationGroup); int index = GroupToIndex(script.currentConfiguration, group); var names = GroupNames(script.currentConfiguration); EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup("Group", index, names); if (EditorGUI.EndChangeCheck()) { MadUndo.RecordObject2(script, "Changed Group"); script.configurationGroup = IndexToGroup(script.currentConfiguration, index).id; script.dirty = true; EditorUtility.SetDirty(script); } GUI.enabled = true; } EditorGUILayout.Space(); MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet); if (script.iconTemplate != null) { var prefabType = PrefabUtility.GetPrefabType(script.iconTemplate); if (prefabType == PrefabType.None) { MadGUI.Warning("It's recommended to use prefab as a template. All visible icon instances will be linked to this prefab."); } } using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(enumerationType, "Enumeration"); using (MadGUI.Indent()) { MadGUI.PropertyField(enumerationOffset, "Offset"); } } EditorGUILayout.Space(); MadGUI.PropertyField(backgroundTexture, "Background Texture"); EditorGUILayout.Space(); MadGUI.Info("Use the button below if you've updated your icon template and you want to replace all icons in your layout with it."); if (MadGUI.Button("Replace All Icons", Color.yellow)) { ReplaceAllIcons(); } MadGUI.Info("More customization options are available in the Draggable object."); if (MadGUI.Button("Select Draggable", Color.magenta)) { SelectDraggable(); } }); EditorGUILayout.Space(); GUILayout.Label("Mechanics", "HeaderLabel"); MadGUI.Indent(() => { LookAtLastLevel(); EditorGUILayout.Space(); HandleMobileBack(); EditorGUILayout.Space(); TwoStepActivation(); EditorGUILayout.Space(); LoadLevel(); }); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired) { MadTrialEditor.OnEditorGUIExpired("Mad Level Manager"); return; } LoadTextures(); // loading textures with delay to prevent editor errors CheckAssetLocation(); ActiveInfo(); GUIGroupPopup(); LoadItems(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(GUILayout.Width(1)); GUILayout.Space(200); EditorGUILayout.EndVertical(); list.Draw(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUI.backgroundColor = Color.green; if (GUILayout.Button("Add")) { AddLevel(); } GUI.backgroundColor = Color.white; GUI.enabled = list.selectedItem != null; GUI.backgroundColor = Color.red; if (GUILayout.Button("Remove") || GUI.enabled && Event.current.keyCode == KeyCode.Delete) { RemoveLevel(); } GUI.backgroundColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.Label("Move"); if (GUILayout.Button("Down")) { MoveDown(); configuration.SetDirty(); } if (GUILayout.Button("Up")) { MoveUp(); configuration.SetDirty(); } GUILayout.Space(10); if (GUILayout.Button("Bottom")) { MoveToBottom(); configuration.SetDirty(); } if (GUILayout.Button("Top")) { MoveToTop(); configuration.SetDirty(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); MadGUI.IndentBox("Level Properties", () => { var item = list.selectedItem; if (item == null) { item = new LevelItem(configuration); GUI.enabled = false; } MadUndo.RecordObject(configuration, "Edit '" + item.level.name + "'"); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); MadGUI.Validate(() => item.level.sceneObject != null, () => { item.level.sceneObject = EditorGUILayout.ObjectField("Scene", item.level.sceneObject, typeof(UnityEngine.Object), false); }); GUI.backgroundColor = Color.yellow; if (GUILayout.Button("Set Current", GUILayout.Width(85))) { MadUndo.RecordObject2(target, "Change Scene"); var obj = AssetDatabase.LoadAssetAtPath(EditorApplication.currentScene, typeof(UnityEngine.Object)); if (obj != null) { item.level.sceneObject = obj; } else { EditorUtility.DisplayDialog("Scene not saved", "Current scene is not saved. Please save it first (CTRL+S).", "OK"); } } GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); if (!CheckAssetIsScene(item.level.sceneObject)) { item.level.sceneObject = null; } MadGUI.Validate(() => !string.IsNullOrEmpty(item.level.name), () => { GUI.SetNextControlName("level name"); // needs names to unfocus item.level.name = EditorGUILayout.TextField("Level Name", item.level.name); }); item.level.type = (MadLevel.Type)EditorGUILayout.EnumPopup("Type", item.level.type); GUI.SetNextControlName("arguments"); // needs names to unfocus item.level.arguments = EditorGUILayout.TextField("Arguments", item.level.arguments); GUI.SetNextControlName("locked by default"); // needs names to unfocus item.level.lockedByDefault = EditorGUILayout.Toggle("Locked By Default", item.level.lockedByDefault); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); extensionIndex = configuration.extensions.FindIndex((e) => e == item.level.extension) + 1; extensionIndex = MadGUI.DynamicPopup(extensionIndex, "Extension", configuration.extensions.Count + 1, (index) => { if (index == 0) { return("(none)"); } else { return(configuration.extensions[index - 1].name); } }); if (EditorGUI.EndChangeCheck()) { if (extensionIndex == 0) { item.level.extension = null; } else { item.level.extension = configuration.extensions[extensionIndex - 1]; configuration.SetDirty(); } } bool enabledState = GUI.enabled; GUI.enabled = true; if (MadGUI.Button("Open Extension Editor", Color.magenta)) { MadLevelExtensionEditor.Show(configuration); } GUI.enabled = enabledState; EditorGUILayout.Space(); int groupIndex = GroupToIndex(item.level.group); groupIndex = EditorGUILayout.Popup("Move To Group:", groupIndex, GroupNames()); item.level.group = IndexToGroup(groupIndex); if (EditorGUI.EndChangeCheck()) { configuration.SetDirty(); } GUI.enabled = true; }); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Help")) { Help.BrowseURL(MadLevelHelp.LevelConfigurationHelp); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (!configuration.IsValid()) { MadGUI.Error("Configuration is invalid. Please make sure that:\n" + "- There's no levels with \"!!!\" icon. These levels may have duplicated name or missing scene.\n" + "- All your extensions have no missing scenes (in Extension Editor)" ); } if (configuration.active && !MadLevelConfigurationEditor.CheckBuildSynchronized(configuration)) { if (MadGUI.ErrorFix( "Build configuration is not in synch with level configuration.", "Synchronize Now")) { MadLevelConfigurationEditor.SynchronizeBuild(configuration); } } foreach (var ex in executionQueue) { ex(); } executionQueue.Clear(); }