// =========================================================== // Constants // =========================================================== // =========================================================== // Fields // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== // =========================================================== // Methods // =========================================================== public override void OnInspectorGUI() { base.OnInspectorGUI(); if (Foldout("Property", true)) { MadGUI.Indent(() => { MadGUI.BeginBox(); var property = target as MadLevelProperty; EditorGUILayout.LabelField("Property name: " + target.name); EditorGUILayout.BeginHorizontal(); GUI.enabled = !property.propertyEnabled; if (GUILayout.Button("Enable")) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } GUI.enabled = property.propertyEnabled; if (GUILayout.Button("Disable")) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } GUI.enabled = true; GUI.color = Color.white; EditorGUILayout.EndHorizontal(); // if (!Application.isPlaying) { // if (MessageWithButton("To test animations please enter the Play mode.", "Enter Play Mode", MessageType.Info)) { // EditorApplication.ExecuteMenuItem("Edit/Play"); // } // EditorGUILayout.Space(); // } MadGUI.EndBox(); }); } }
public override void OnInspectorGUI() { serializedObject.UpdateIfDirtyOrScript(); MadGUI.BeginBox("Test Mode"); using (MadGUI.Indent()) { MadGUI.PropertyField(testMode, "Enabled"); var ignoreObject = GameObject.Find("/_mlm_ignore"); if (testMode.boolValue && ignoreObject == null) { new GameObject("_mlm_ignore"); } else if (!testMode.boolValue && ignoreObject != null) { DestroyImmediate(ignoreObject); } MadGUI.PropertyField(testLevelToLoad, "Load Level"); } MadGUI.EndBox(); MadGUI.BeginBox("Loading"); using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(loadingMethod, "Method"); MadGUI.PropertyField(delayLoadingSeconds, "Delay"); MadGUI.PropertyField(loadingBar, "Loading Bar", ValidateLoadingBar); if (!ValidateLoadingBar(loadingBar)) { MadGUI.Error("Attached object does not have MadSprite, UISprite (NGUI) or Image (uGUI) component. " + "Please make sure that you've assigned a valid game object."); } using (MadGUI.Indent()) { MadGUI.PropertyField(loadingBarSmooth, "Smooth"); using (MadGUI.EnabledIf(loadingBarSmooth.boolValue)) { MadGUI.PropertyField(loadingBarSmoothSpeed, "Smooth Speed"); MadGUI.PropertyField(waitForBarToFillUp, "Wait To Fill Up"); } } } MadGUI.EndBox(); MadGUI.BeginBox("When Loaded"); using (MadGUI.Indent()) { MadGUI.PropertyFieldEnumPopup(whenLevelLoaded, ""); EditorGUILayout.Space(); if (whenLevelLoaded.enumValueIndex == (int)LoadingScreen.WhenLevelLoaded.WaitAndShow) { using (MadGUI.Indent()) { MadGUI.PropertyField(waitAndShowSeconds, "Seconds"); EditorGUILayout.Space(); } } if (whenLevelLoaded.enumValueIndex != (int)LoadingScreen.WhenLevelLoaded.ShowImmediately) { GUIGameObjectList("Enable Objects", changeEnable); GUIGameObjectList("Disable Objects", changeDisable); } EditorGUILayout.Space(); GUILayout.Label("Don't Destroy Objects", "HeaderLabel"); var arrayList = new MadGUI.ArrayList <string>(ignoreObjects, property => { MadGUI.PropertyField(property, ""); }); arrayList.drawOrderButtons = false; arrayList.Draw(); GUILayout.Label("Notify", "HeaderLabel"); FieldMessage(onLoadedMessage); } MadGUI.EndBox(); MadGUI.BeginBox("When Level Shown"); using (MadGUI.Indent()) { MadGUI.PropertyField(timeScaleToOneWhenShown, "Set Time Scale To One"); GUILayout.Label("Notify", "HeaderLabel"); FieldMessage(onLevelShowMessage); } MadGUI.EndBox(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (levelIcon.generated && SetupMethodGenerate()) { if (MadGUI.WarningFix("This icon instance has been generated. If you want to modify this icon, " + "please switch your Setup Method to Manual or change the template.", "Help")) { Application.OpenURL(MadLevelHelp.IconGenerated); } GUI.enabled = false; } if (MadGameObject.IsActive(levelIcon.gameObject)) { Properties(); } else { MadGUI.Warning("Not all functions are available if this object is disabled! Before editing please enable this game object!"); } MadGUI.BeginBox("Visibility"); MadGUI.Indent(() => { EditorGUILayout.Space(); CheckPropertyError(levelIcon.showWhenLevelLocked); GUILayout.Label("Show when level is locked"); ArrayFor(levelIcon.showWhenLevelLocked); CheckPropertyError(levelIcon.showWhenLevelUnlocked); GUILayout.Label("Show when level is unlocked"); ArrayFor(levelIcon.showWhenLevelUnlocked); CheckPropertyError(levelIcon.showWhenLevelCompleted); GUILayout.Label("Show when level is completed"); ArrayFor(levelIcon.showWhenLevelCompleted); CheckPropertyError(levelIcon.showWhenLevelNotCompleted); GUILayout.Label("Show when level is not completed"); ArrayFor(levelIcon.showWhenLevelNotCompleted); CheckConflictError(); serializedObject.UpdateIfDirtyOrScript(); MadGUI.PropertyField(canFocusIfLocked, "Can Focus If Locked"); serializedObject.ApplyModifiedProperties(); if (levelIcon.generated) { serializedObject.UpdateIfDirtyOrScript(); if (MadGUI.Foldout("Unlock On Complete", false)) { var arrayList = new MadGUI.ArrayList <MadLevelIcon>( unlockOnComplete, (p) => { MadGUI.PropertyField(p, ""); }); arrayList.Draw(); } serializedObject.ApplyModifiedProperties(); } }); MadGUI.EndBox(); if (levelIcon.completedProperty != null || levelIcon.lockedProperty != null) { SectionSecialProperties(); } MadGUI.BeginBox("Sprite"); MadGUI.Indent(() => { SectionSprite(); }); MadGUI.EndBox(); }
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(); }
private void SectionSecialProperties() { MadGUI.BeginBox("Special Properties"); MadGUI.Indent(() => { MadGUI.Warning("Special properties are deprecated. Please use Children section instead."); if (levelIcon.generated) { int levelCount = levelIcon.configuration.LevelCount(MadLevel.Type.Level); if (levelCount > levelIcon.levelIndex) { var level = levelIcon.level; if (level != null) { MadGUI.Disabled(() => { EditorGUILayout.TextField("Level TypeID", level.name); EditorGUILayout.TextField("Level Arguments", level.arguments); }); } else { MadGUI.Warning("Level for this icon no longer exists."); } } if (MadGUI.InfoFix("These values are set and managed by level configuration.", "Configuration")) { Selection.objects = new Object[] { levelIcon.configuration }; } } // // Completed property select popup // EditorGUI.BeginChangeCheck(); MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>( target, "\"Completed\" Property", ref levelIcon.completedProperty, PropertyList(), false ); MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>( target, "\"Locked\" Property", ref levelIcon.lockedProperty, PropertyList(), false ); if (EditorGUI.EndChangeCheck()) { if (levelIcon.completedProperty == null && levelIcon.lockedProperty == null) { EditorUtility.DisplayDialog("Hiding Special Properties", "Special properties are deprecated and they will be now hidden from your inspector view. Please use the Visibility section instead.", "I understand"); } } }); 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() { var levelIcon = target as MadLevelIcon; MadGUI.BeginBox("Properties"); MadGUI.Indent(() => { var properties = PropertyList(); foreach (MadLevelProperty property in properties) { GUILayout.BeginHorizontal(); GUILayout.Label(property.name, GUILayout.Width(170)); GUI.enabled = !property.propertyEnabled; if (GUILayout.Button("Enable")) { property.propertyEnabled = true; EditorUtility.SetDirty(property); } GUI.enabled = property.propertyEnabled; if (GUILayout.Button("Disable")) { property.propertyEnabled = false; EditorUtility.SetDirty(property); } GUI.enabled = true; GUI.color = Color.white; GUILayout.EndHorizontal(); } }); MadGUI.EndBox(); MadGUI.BeginBox("Level Icon"); MadGUI.Indent(() => { if (levelIcon.hasLevelConfiguration) { int levelCount = levelIcon.configuration.LevelCount(MadLevel.Type.Level); if (levelCount > levelIcon.levelIndex) { var level = levelIcon.level; MadGUI.Disabled(() => { EditorGUILayout.TextField("Level Name", level.name); EditorGUILayout.TextField("Level Arguments", level.arguments); }); } if (MadGUI.InfoFix("These values are set and managed by level configuration.", "Configuration")) { Selection.objects = new Object[] { levelIcon.configuration }; } } else { serializedObject.Update(); MadGUI.PropertyField(levelSceneName, "Level Scene Name"); serializedObject.ApplyModifiedProperties(); } // // Completed property select popup // MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>( target, "\"Completed\" Property", ref levelIcon.completedProperty, PropertyList(), false ); MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>( target, "\"Locked\" Property", ref levelIcon.lockedProperty, PropertyList(), false ); MadGUI.PropertyFieldObjectsPopup <MadText>( target, "Level Number Text", ref levelIcon.levelNumber, TextList(), false ); serializedObject.Update(); if (MadGUI.Foldout("Unlock On Complete", false)) { var arrayList = new MadGUI.ArrayList <MadLevelIcon>( unlockOnComplete, (p) => { MadGUI.PropertyField(p, ""); }); arrayList.Draw(); } serializedObject.ApplyModifiedProperties(); }); MadGUI.EndBox(); MadGUI.BeginBox("Sprite"); MadGUI.Indent(() => { SectionSprite(); }); MadGUI.EndBox(); }