Beispiel #1
0
    protected void GUIAnimationRef(SerializedProperty animationRef, bool showFromTheBeginning)
    {
        var name = animationRef.FindPropertyRelative("name");

        GUIAnimationName(name);
        //MadGUI.PropertyField(name, "Name");

        if (showFromTheBeginning)
        {
            using (MadGUI.Indent()) {
                var fromTheBeginning = animationRef.FindPropertyRelative("fromTheBeginning");
                MadGUI.PropertyField(fromTheBeginning, "From The Start");
            }
        }
    }
 private void GUILevels(string path)
 {
     using (MadGUI.Indent(2)) {
         var levelNames = MadLevelProfile.GetLevelNames();
         levelNames.Sort(new MadNaturalSortComparer());
         foreach (var levelName in levelNames)
         {
             path += "/" + levelName;
             if (Foldout(levelName, path))
             {
                 GUILevel(levelName);
             }
         }
     }
 }
Beispiel #3
0
    protected void HandleMobileBack()
    {
        MadGUI.PropertyField(handleMobileBackButton, "Handle Mobile 'Back'",
                             "Handles mobile 'back' action by loading selected level.");
        MadGUI.Indent(() => {
            MadGUI.PropertyFieldEnumPopup(handleMobileBackButtonAction, "Action");

            if (s.handleMobileBackButtonAction == MadLevelAbstractLayout.OnMobileBack.LoadSpecifiedLevel)
            {
                MadGUI.Indent(() => {
                    MadGUI.PropertyField(handleMobileBackButtonLevelName, "Level TypeID", MadGUI.StringNotEmpty);
                });
            }
        });
    }
    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();
    }
    private void GUIProfile(string profile, string path)
    {
        using (MadGUI.Indent(2)) {
            MadLevelProfile.profile = profile;

            if (Foldout("Levels", path + "/Levels"))
            {
                GUILevels(path + "/Levels");
            }

            var profilePropertyNames = MadLevelProfile.GetProfilePropertyNames();
            foreach (var profilePropertyName in profilePropertyNames)
            {
                GUIProperty(profilePropertyName, MadLevelProfile.GetProfileAny(profilePropertyName));
            }
        }
    }
    public override void OnInspectorGUI()
    {
        RefreshAnimationNames();

        serializedObject.UpdateIfDirtyOrScript();

        GUILayout.Label("Events", "HeaderLabel");
        EditorGUILayout.Space();

        using (MadGUI.Indent()) {
            GUIEvents();
        }

        GUIElements();

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #7
0
    protected void SectionSprite(DisplayFlag flags)
    {
        serializedObject.Update();
        MadGUI.PropertyField(visible, "Visible");

        if ((flags & DisplayFlag.WithoutMaterial) == 0)
        {
            MadGUI.PropertyField(texture, "Texture", MadGUI.ObjectIsSet);
            MadGUI.Indent(() => {
                MadGUI.PropertyFieldVector2(textureRepeat, "Repeat");
                MadGUI.PropertyFieldVector2(textureOffset, "Offset");
            });
        }

        MadGUI.PropertyField(tint, "Tint");

        if ((flags & DisplayFlag.WithoutSize) == 0)
        {
            if (GUILayout.Button(new GUIContent("Resize To Texture",
                                                "Resizes this sprite to match texture size")))
            {
                var sprite = target as MadSprite;
                MadUndo.RecordObject2(sprite, "Resize To Texture");
                sprite.ResizeToTexture();
                EditorUtility.SetDirty(sprite);
            }
        }

        MadGUI.PropertyField(pivotPoint, "Pivot Point");
        MadGUI.PropertyField(guiDepth, "GUI Depth");

        if ((flags & DisplayFlag.WithoutFill) == 0)
        {
            MadGUI.PropertyField(fillType, "Fill Type");
            EditorGUILayout.Slider(fillValue, 0, 1, "Fill Value");

            if (sprite.fillType == MadSprite.FillType.RadialCCW || sprite.fillType == MadSprite.FillType.RadialCW)
            {
                MadGUI.PropertyFieldSlider(radialFillOffset, -1, 1, "Offset");
                MadGUI.PropertyFieldSlider(radialFillLength, 0, 1, "Length");
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

        MadGUI.PropertyField(moveEasingType, "Type");
        MadGUI.PropertyField(moveEasingDuration, "Duration");

        EditorGUILayout.Space();

        GUILayout.Label("Swipe", "HeaderLabel");
        using (MadGUI.Indent()) {
            MadGUI.PropertyField(swipeVirtualDistanceModifier, "Virtual Distance Modifier");
            MadGUI.PropertyField(limitSwipeToSinglePage, "Limit To A Single Page");
            MadGUI.PropertyField(switchAfterDistance, "Switch Page After Distance");
        }

        serializedObject.ApplyModifiedProperties();
    }
    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;
            if (GUILayout.Button("Rebuild Now"))
            {
                Rebuild();
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();
        });
    }
Beispiel #10
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

        MadGUI.PropertyField(animationName, "Animation Name");
        EditorGUILayout.Space();

        DrawInspector();
        EditorGUILayout.Space();

        MadGUI.PropertyField(duration, "Duration");
        MadGUI.PropertyField(delay, "Delay");
        MadGUI.PropertyFieldSlider(offset, 0, 1, "Offset");
        EditorGUILayout.Space();

        MadGUI.PropertyFieldEnumPopup(easing, "Easing");
        MadGUI.PropertyFieldEnumPopup(wrapMode, "Wrap Mode");
        MadGUI.PropertyField(queue, "Queue");
        EditorGUILayout.Space();

        MadGUI.PropertyField(playOnAwake, "Play On Awake");
        MadGUI.PropertyField(destroyObjectOnFinish, "Destroy On Finish");
        MadGUI.PropertyField(sendMessageOnFinish, "Send Message On Finish");

        if (sendMessageOnFinish.boolValue)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(messageReceiver, "Receiver", MadGUI.ObjectIsSet);
                MadGUI.PropertyField(messageName, "Method Name", MadGUI.StringNotEmpty);
            }
        }

        MadGUI.PropertyField(playAnimationOnFinish, "Play Animation On Finish");

        if (playAnimationOnFinish.boolValue)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(playAnimationOnFinishName, "Name", MadGUI.StringNotEmpty);
                MadGUI.PropertyField(playAnimationOnFinishFromTheBeginning, "From The Beginning");
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #11
0
    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();
        });
    }
    protected void GUIAction(SerializedProperty action)
    {
        var playAnimations    = action.FindPropertyRelative("playAnimations");
        var stopAnimations    = action.FindPropertyRelative("stopAnimations");
        var stopAllAnimations = action.FindPropertyRelative("stopAllAnimations");

        EditorGUILayout.LabelField("Play Animations");
        using (MadGUI.Indent()) {
            GUIAnimationRefList(playAnimations, true);
        }

        MadGUI.PropertyFieldToggleGroup2(stopAllAnimations, "Stop All Animations", () => {
            GUI.enabled = !GUI.enabled;
            EditorGUILayout.LabelField("Stop Animations");
            using (MadGUI.Indent()) {
                GUIAnimationRefList(stopAnimations, false);
            }
        });
    }
    protected override void DrawInspector()
    {
        MadGUI.PropertyFieldEnumPopup(colorFrom, "From");

        if (colorFrom.enumValueIndex == (int)MadAnimColor.ValueType.Value)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(colorFromValue, "Value");
            }
        }

        MadGUI.PropertyFieldEnumPopup(colorTo, "To");

        if (colorTo.enumValueIndex == (int)MadAnimColor.ValueType.Value)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(colorToValue, "Value");
            }
        }
    }
Beispiel #14
0
    protected override void DrawInspector()
    {
        MadGUI.PropertyFieldEnumPopup(moveFrom, "From");

        if (moveFrom.enumValueIndex >= 2)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(moveFromPosition, "Position");
            }
        }

        MadGUI.PropertyFieldEnumPopup(moveTo, "To");

        if (moveTo.enumValueIndex >= 2)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(moveToPosition, "Position");
            }
        }
    }
    protected override void DrawInspector()
    {
        MadGUI.PropertyFieldEnumPopup(rotateFrom, "From");

        if (rotateFrom.enumValueIndex >= 2)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(rotateFromValue, "Value");
            }
        }

        MadGUI.PropertyFieldEnumPopup(rotateTo, "To");

        if (rotateTo.enumValueIndex >= 2)
        {
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(rotateToValue, "Value");
            }
        }
    }
Beispiel #16
0
    public override void OnInspectorGUI()
    {
        SectionSprite(DisplayFlag.WithoutSize | DisplayFlag.WithoutMaterial | DisplayFlag.WithoutFill);

        serializedObject.Update();
        MadGUI.PropertyField(panel, "Panel", MadGUI.ObjectIsSet);
        EditorGUILayout.Space();

        MadGUI.PropertyField(font, "Font", MadGUI.ObjectIsSet);
        EditorGUILayout.LabelField("Text");
        text.stringValue = EditorGUILayout.TextArea(text.stringValue);
        MadGUI.PropertyField(scale, "Scale");
        MadGUI.PropertyField(align, "Align");
        MadGUI.PropertyField(letterSpacing, "Letter Spacing");
        MadGUI.PropertyField(wordWrap, "Word Wrap");
        MadGUI.Indent(() => {
            MadGUI.PropertyField(wordWrapLength, "Line Length");
        });

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #17
0
    // ===========================================================
    // 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();
            });
        }
    }
    protected void LoadLevel()
    {
        MadGUI.PropertyFieldEnumPopup(loadLevel, "Load Level...");

        switch (s.loadLevel)
        {
        case MadLevelAbstractLayout.LoadLevel.Immediately:
            // do nothing
            break;

        case MadLevelAbstractLayout.LoadLevel.WithDelay:
            using (MadGUI.Indent()) {
                MadGUI.PropertyField(loadLevelLoadLevelDelay, "Delay");
                if (loadLevelLoadLevelDelay.floatValue < 0)
                {
                    loadLevelLoadLevelDelay.floatValue = Mathf.Max(0, loadLevelLoadLevelDelay.floatValue);
                }
            }
            break;

        case MadLevelAbstractLayout.LoadLevel.SendMessage:
            using (MadGUI.Indent()) {
                MadGUI.Info("By choosing this option you are responsible for loading the level. "
                            + "Activated MadLevelIcon will be passed as message argument.");

                MadGUI.PropertyField(loadLevelMessageReceiver, "Receiver", MadGUI.ObjectIsSet);
                MadGUI.PropertyField(loadLevelMessageName, "Method Name", MadGUI.StringNotEmpty);
                MadGUI.PropertyField(loadLevelMessageIncludeChildren, "Include Children");
            }
            break;

        case MadLevelAbstractLayout.LoadLevel.DoNotLoad:
            // do nothing
            break;

        default:
            Debug.LogError("Unknown option: " + s.loadLevel);
            break;
        }
    }
    private void GUIModifier(SerializedProperty modifierProperty)
    {
        var animationName = modifierProperty.FindPropertyRelative("animationName");

        var modifierFunction = modifierProperty.FindPropertyRelative("modifierFunction");
        var baseOperator     = modifierProperty.FindPropertyRelative("baseOperator");
        var firstParameter   = modifierProperty.FindPropertyRelative("firstParameter");
        var valueOperator    = modifierProperty.FindPropertyRelative("valueOperator");
        var secondParameter  = modifierProperty.FindPropertyRelative("secondParameter");


        //var function = modifierProperty.FindPropertyRelative("modifierFunction");
        //var method = modifierProperty.FindPropertyRelative("method");

        GUIAnimationName(animationName);
        MadGUI.PropertyFieldEnumPopup(modifierFunction, "Function");
        if (modifierFunction.enumValueIndex == (int)MadLevelAnimator.Modifier.ModifierFunc.Predefined)
        {
            MadGUI.PropertyFieldEnumPopup(baseOperator, "Base Operator");

            using (MadGUI.Indent()) {
                EditorGUILayout.LabelField("Expression");

                EditorGUILayout.BeginHorizontal();
                MadGUI.PropertyFieldEnumPopup(firstParameter, "", GUILayout.Width(150));
                //MadGUI.LookLikeControls(0, 0);
                MadGUI.PropertyFieldEnumPopup(valueOperator, "", GUILayout.Width(100));
                EditorGUILayout.PropertyField(secondParameter, new GUIContent(""), GUILayout.Width(80));
                //MadGUI.LookLikeControls(0);
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
        }



        //MadGUI.PropertyFieldEnumPopup(function, "Function");
        //MadGUI.PropertyFieldEnumPopup(method, "Method");
    }
Beispiel #20
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

        GUILayout.Label("Fundaments", "HeaderLabel");
        MadGUI.Indent(() => {
            MadGUI.PropertyField(configuration, "Configuration", MadGUI.ObjectIsSet);
            MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet);
            MadGUI.PropertyField(backgroundTexture, "Background Texture");
        });

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

        MadGUI.Indent(() => {
            MadGUI.PropertyField(lookAtLastLevel, "Look At Last Level", "When scene is loaded, it will automatically "
                                 + "go to the previously played level (but only if previous scene is of type Level.");
            HandleMobileBack();
            TwoStepActivation();
        });

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #21
0
    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();
    }
    protected void TwoStepActivation()
    {
        MadGUI.PropertyFieldEnumPopup(twoStepActivationType, "Two Step Activation");
        MadGUI.ConditionallyEnabled(
            twoStepActivationType.enumValueIndex != (int)MadLevelAbstractLayout.TwoStepActivationType.Disabled, () => {
            MadGUI.Indent(() => {
                if (MadGUI.Foldout("On Activate", false))
                {
                    MadGUI.Indent(() => {
                        ActivateAction(
                            onIconActivatePlayAudio,
                            onIconActivatePlayAudioClip,
                            onIconActivatePlayAudioVolume,
                            onIconActivateMessage,
                            onIconActivateMessageReceiver,
                            onIconActivateMessageMethodName,
                            onIconActivateMessageIncludeChildren
                            );
                    });
                }

                if (MadGUI.Foldout("On Deactivate", false))
                {
                    MadGUI.Indent(() => {
                        ActivateAction(
                            onIconDeactivatePlayAudio,
                            onIconDeactivatePlayAudioClip,
                            onIconDeactivatePlayAudioVolume,
                            onIconDeactivateMessage,
                            onIconDeactivateMessageReceiver,
                            onIconDeactivateMessageMethodName,
                            onIconDeactivateMessageIncludeChildren
                            );
                    });
                }
            });
        });
    }
    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();
    }
Beispiel #24
0
    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();
    }
Beispiel #25
0
    public override void OnInspectorGUI()
    {
        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
            {
                script.setupMethod = newSetupMethod;
                EditorUtility.SetDirty(script);
            }
        }

        serializedObject.UpdateIfDirtyOrScript();

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

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

        MadGUI.Indent(() => {
            MadGUI.PropertyField(configuration, "Configuration", MadGUI.ObjectIsSet);

            GUI.enabled = generate;

            MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet);
            MadGUI.Indent(() => {
                MadGUI.PropertyFieldVector2(iconScale, "Scale");
                MadGUI.PropertyFieldVector2(iconOffset, "Offset");
            });

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

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

        MadGUI.Indent(() => {
            MadGUI.PropertyField(pixelsWidth, "Pixels Width");
            MadGUI.PropertyField(pixelsHeight, "Pixels Height");
            GUI.enabled = generate;
            MadGUI.PropertyField(gridHeight, "Grid Rows");
            MadGUI.PropertyField(gridWidth, "Grid Columns");
            GUI.enabled = true;
            MadGUI.PropertyField(pagesOffsetFromResolution, "Page Offset Auto");
            MadGUI.ConditionallyEnabled(!pagesOffsetFromResolution.boolValue, () => {
                MadGUI.Indent(() => {
                    MadGUI.PropertyField(pagesOffsetManual, "Pixels Offset");
                });
            });
        });

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

        MadGUI.Indent(() => {
            MadGUI.PropertyField(lookAtLastLevel, "Look At Last Level", "When scene is loaded, it will automatically "
                                 + "go to the page of previously played level (but only if previous scene is of type Level.");
            HandleMobileBack();
            TwoStepActivation();
        });

        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();
    }
    protected void SectionSprite(DisplayFlag flags)
    {
        serializedObject.Update();
        GUIDepthCheck();

        MadGUI.PropertyField(panel, "Panel", MadGUI.ObjectIsSet);
        EditorGUILayout.Space();

        MadGUI.PropertyField(visible, "Visible");

        if ((flags & DisplayFlag.WithoutMaterial) == 0)
        {
            MadGUI.PropertyFieldEnumPopup(inputType, "Input Type");
            MadGUI.Indent(() => {
                switch (sprite.inputType)
                {
                case MadSprite.InputType.SingleTexture:
                    MadGUI.PropertyField(texture, "Texture", MadGUI.ObjectIsSet);
                    MadGUI.Indent(() => {
                        MadGUI.PropertyFieldVector2(textureRepeat, "Repeat");
                        MadGUI.PropertyFieldVector2(textureOffset, "Offset");
                    });
                    break;

                case MadSprite.InputType.TextureAtlas:
                    MadGUI.PropertyField(textureAtlas, "Texture Atlas", MadGUI.ObjectIsSet);

                    if (sprite.textureAtlas != null)
                    {
                        MadAtlasUtil.AtlasField(textureAtlasSpriteGUID, sprite.textureAtlas, "Sprite", this);
                    }

                    break;

                default:
                    Debug.LogError("Unknown input type: " + sprite.inputType);
                    break;
                }
            });
        }

        MadGUI.PropertyField(hasPremultipliedAlpha, "Has Pre-Alpha");

        MadGUI.PropertyField(tint, "Tint");

        EditorGUILayout.Space();

        if ((flags & DisplayFlag.WithoutSize) == 0)
        {
            EditorGUILayout.Space();
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button(new GUIContent("Resize To Texture",
                                                "Resizes this sprite to match texture size")))
            {
                MadUndo.RecordObject2(sprite, "Resize To Texture");
                sprite.ResizeToTexture();
                EditorUtility.SetDirty(sprite);
            }
            GUI.backgroundColor = Color.white;
            EditorGUILayout.Space();
        }

        EditorGUILayout.Space();

        MadGUI.PropertyField(pivotPoint, "Pivot Point");
        if (sprite.pivotPoint == MadSprite.PivotPoint.Custom)
        {
            MadGUI.Indent(() => {
                MadGUI.PropertyFieldVector2(customPivotPoint, "Custom Pivot Point");
            });
        }

        MadGUI.PropertyField(guiDepth, "GUI Depth");

        EditorGUILayout.Space();

        if ((flags & DisplayFlag.WithoutFill) == 0)
        {
            MadGUI.PropertyField(fillType, "Fill Type");
            EditorGUILayout.Slider(fillValue, 0, 1, "Fill Value");

            if (sprite.fillType == MadSprite.FillType.RadialCCW || sprite.fillType == MadSprite.FillType.RadialCW)
            {
                MadGUI.PropertyFieldSlider(radialFillOffset, -1, 1, "Offset");
                MadGUI.PropertyFieldSlider(radialFillLength, 0, 1, "Length");
            }
        }

        if (showLiveBounds)
        {
            GUILayout.Label("Sprite Border", "HeaderLabel");
            EditorGUILayout.Space();
            if (sprite.CanDraw())
            {
                FieldLiveBounds();
            }
            else
            {
                MadGUI.Info("More settings will be available when the sprite texture or atlas is set.");
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
    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();
    }
    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();
    }
Beispiel #29
0
    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();
    }
Beispiel #30
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

        GUI.color = Color.yellow;
        if (GUILayout.Button("<< Back To Layer Listing"))
        {
            Selection.activeGameObject = layer.parent.gameObject;
        }
        GUI.color = Color.white;
        GUILayout.Space(16);

        MadGUI.PropertyField(texture, "Texture");
        MadGUI.PropertyField(tint, "Tint");

        EditorGUILayout.Space();

        MadGUI.PropertyField(scaleMode, "Scale Mode");

        MadGUI.PropertyField(repeatX, "Repeat X");
        MadGUI.PropertyField(repeatY, "Repeat Y");

        MadGUI.ConditionallyEnabled(layer.scaleMode == MadLevelBackgroundLayer.ScaleMode.Fill && !layer.repeatX && !layer.repeatY, () => {
            if (MadGUI.Foldout("Margin", false))
            {
                MadGUI.Indent(() => {
                    MadGUI.PropertyField(fillMarginLeft, "Left");
                    MadGUI.PropertyField(fillMarginTop, "Top");
                    MadGUI.PropertyField(fillMarginRight, "Right");
                    MadGUI.PropertyField(fillMarginBottom, "Bottom");
                });
            }
        });

        MadGUI.ConditionallyEnabled(!layer.repeatX && !layer.repeatY, () => {
            MadGUI.PropertyField(dontStretch, "Don't Stretch");
        });

        if (scaleMode.enumValueIndex == (int)MadLevelBackgroundLayer.ScaleMode.Manual)
        {
            MadGUI.PropertyField(align, "Align");
            EditorGUILayout.Space();
            MadGUI.PropertyFieldVector2Compact(position, "Position", 70);
            MadGUI.PropertyFieldVector2Compact(scale, "Scale", 70);
        }
        else
        {
            MadGUI.PropertyFieldVector2Compact(position, "Position", 70);
        }

        EditorGUILayout.Space();

        MadGUI.PropertyField(followSpeed, "Follow Speed");
        MadGUI.PropertyFieldVector2Compact(scrollSpeed, "Auto Scroll", 70);

        using (MadGUI.Indent()) {
            MadGUI.PropertyField(ignoreTimeSclae, "Ignore Time Scale");
        }

        if (serializedObject.ApplyModifiedProperties())
        {
            layer.SetDirty();
        }
    }