コード例 #1
0
    protected void ConfigurationField()
    {
        MadGUI.PropertyField(useCurrentlyActiveConfiguration, "Use Currently Active");

        if (!s.useCurrentlyActiveConfiguration)
        {
            MadGUI.PropertyField(configuration, "Configuration", MadGUI.ObjectIsSet);
        }
        else
        {
            using (MadGUI.EnabledIf(false)) {
                EditorGUILayout.ObjectField("Configuration", s.currentConfiguration, typeof(MadLevelConfiguration),
                                            false);
            }

            if (!s.CurrentConfigurationValid())
            {
                bool help = MadGUI.ErrorFix("Current configuration does not include current level select screen or it cannot find current group. " +
                                            "Please make sure to use a similar copy to the original configuration.", "Help");
                if (help)
                {
                    Application.OpenURL(MadLevelHelp.ActiveConfiguration);
                }
            }
        }
    }
コード例 #2
0
    void RebuildButton()
    {
        GUILayout.Label("Rebuild", "HeaderLabel");
        MadGUI.Indent(() => {
            MadGUI.Info("In a case when you've changed something, and result is not available on the screen, "
                        + "please hit this button.");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            GUI.color = Color.green;
            using (MadGUI.EnabledIf(script.iconTemplate != null)) {
                if (GUILayout.Button("Rebuild Now"))
                {
                    Rebuild();
                }
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();
        });
    }
コード例 #3
0
    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();
    }
コード例 #4
0
    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();
    }
コード例 #5
0
    public override void OnInspectorGUI()
    {
        if (MadTrialEditor.isTrialVersion && MadTrialEditor.expired)
        {
            MadTrialEditor.OnEditorGUIExpired("Mad Level Manager");
            return;
        }

        newSetupMethod = (MadLevelGridLayout.SetupMethod)EditorGUILayout.EnumPopup("Setup Method", script.setupMethod);
        if (newSetupMethod != script.setupMethod)
        {
            if (newSetupMethod == MadLevelGridLayout.SetupMethod.Generate && EditorUtility.DisplayDialog(
                    "Are you sure?",
                    "Are you sure that you want to switch to Generate setup method? If you've made any changes to grid "
                    + "object, these changes will be lost!", "Set to Generate", "Cancel"))
            {
                script.setupMethod = newSetupMethod;
                script.deepClean   = true;
                EditorUtility.SetDirty(script);
            }
            else if (EditorUtility.DisplayDialog(
                         "Are you sure?",
                         "Are you sure that you want to switch to Manual setup method? Be aware that after doing this:\n"
                         + "- You won't be able to change your level group (currently " + script.currentConfiguration.FindGroupById(script.configurationGroup).name + ")\n"
                         + "- You won't be able to regenerate grid without losing custom changes",
                         "Set to Manual", "Cancel"))
            {
                script.setupMethod = newSetupMethod;
                EditorUtility.SetDirty(script);
            }
        }

        serializedObject.UpdateIfDirtyOrScript();

        if (script.setupMethod == MadLevelGridLayout.SetupMethod.Generate)
        {
            RebuildButton();
        }

        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);

                GUI.enabled = script.setupMethod == MadLevelGridLayout.SetupMethod.Generate;
                EditorGUI.BeginChangeCheck();
                index = EditorGUILayout.Popup("Group", index, names);
                if (EditorGUI.EndChangeCheck())
                {
                    script.configurationGroup = IndexToGroup(script.currentConfiguration, index).id;
                    Rebuild();
                }
                GUI.enabled = true;
            }

            EditorGUILayout.Space();

            GUI.enabled = generate;

            IconTemplateField();
            EditorGUILayout.Space();

            using (MadGUI.Indent()) {
                MadGUI.PropertyFieldEnumPopup(enumerationType, "Enumeration");
                using (MadGUI.Indent()) {
                    MadGUI.PropertyField(enumerationOffset, "Offset");
                }

                MadGUI.PropertyFieldVector2(iconScale, "Scale");
                MadGUI.PropertyFieldVector2(iconOffset, "Offset");
            }

            EditorGUILayout.Space();

            GUI.enabled = true;

            MadGUI.PropertyField(leftSlideSprite, "Prev Page Sprite");
            MadGUI.Indent(() => {
                MadGUI.PropertyFieldVector2(leftSlideScale, "Scale");
                MadGUI.PropertyFieldVector2(leftSlideOffset, "Offset");
            });

            MadGUI.PropertyField(rightSlideSprite, "Next Page Sprite");
            MadGUI.Indent(() => {
                MadGUI.PropertyFieldVector2(rightSlideScale, "Scale");
                MadGUI.PropertyFieldVector2(rightSlideOffset, "Offset");
            });
        });

        EditorGUILayout.Space();

        GUILayout.Label("Dimensions", "HeaderLabel");

        using (MadGUI.Indent()) {
            MadGUI.PropertyField(pixelsWidth, "Pixels Width");
            MadGUI.PropertyField(pixelsHeight, "Pixels Height");

            EditorGUILayout.Space();
            GUI.enabled = generate;
            MadGUI.PropertyField(gridHeight, "Grid Rows");
            MadGUI.PropertyField(gridWidth, "Grid Columns");

            EditorGUILayout.Space();

            MadGUI.PropertyField(limitLevelsPerPage, "Limit Levels Per Page");
            using (MadGUI.EnabledIf(script.limitLevelsPerPage)) {
                MadGUI.PropertyField(levelsPerPage, "Levels Per Page");
            }

            EditorGUILayout.Space();

            MadGUI.PropertyFieldEnumPopup(horizontalAlign, "Horizontal Align");
            MadGUI.PropertyFieldEnumPopup(verticalAlign, "Vertical Align");

            GUI.enabled = true;
            EditorGUILayout.Space();
        }

        GUILayout.Label("Paging", "HeaderLabel");

        using (MadGUI.Indent()) {
            MadGUI.PropertyFieldEnumPopup(pagingMethod, "Paging Method");
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(pagingInvert, "Invert");

                if (IsPagingMethodZoom())
                {
                    MadGUI.PropertyField(pagesZoomScale, "Zoom Scale");
                }
            }

            EditorGUILayout.Space();

            MadGUI.PropertyField(pagesOffsetFromResolution, "Dynamic Offset");
            using (MadGUI.Indent()) {
                if (pagesOffsetFromResolution.boolValue)
                {
                    MadGUI.PropertyFieldSlider(pagesOffsetPercent, 0, 3, "Offset %");
                }
                else
                {
                    MadGUI.PropertyField(pagesOffsetManual, "Pixels Offset");
                }
            }
        }

        EditorGUILayout.Space();

        GUILayout.Label("Mechanics", "HeaderLabel");

        MadGUI.Indent(() => {
            LookAtLastLevel();
            EditorGUILayout.Space();
            HandleMobileBack();
            EditorGUILayout.Space();
            TwoStepActivation();
            EditorGUILayout.Space();
            LoadLevel();
            EditorGUILayout.Space();
            IgnoreInput();
        });

        GUILayout.Label("Debug", "HeaderLabel");

        MadGUI.Indent(() => {
            MadGUI.PropertyField(hideManagerdObjects, "Hide Managed",
                                 "Hides managed by Mad Level Manager objects from the Hierarchy. If you want to have a look at what the hierarchy "
                                 + "looks like exacly, you can unckeck this option. Be aware that all direct changes to generated "
                                 + "objects will be lost!");
        });

        serializedObject.ApplyModifiedProperties();
    }