Esempio n. 1
0
    protected void IconTemplateField()
    {
        MadGUI.PropertyField(iconTemplateQuantity, "Icon Quantity");

        using (MadGUI.Indent()) {
            if (s.iconTemplateQuantity == MadLevelAbstractLayout.IconTemplateQuantity.Single)
            {
                MadGUI.PropertyField(iconTemplate, "Icon Template", MadGUI.ObjectIsSet);
                if (s.iconTemplate != null)
                {
                    var prefabType = PrefabUtility.GetPrefabType(s.iconTemplate);
                    if (prefabType == PrefabType.None)
                    {
                        MadGUI.Warning(
                            "It's recommended to use prefab as a template. All visible icon instances will be linked to this prefab.");
                    }
                }
            }
            else
            {
                int i    = 1;
                var list = new MadGUI.ArrayList <MadLevelIcon>(iconTemplates, (icon) => {
                    MadGUI.PropertyField(icon, "Template " + (i++));
                });
                list.drawAddButton    = false;
                list.drawOrderButtons = false;
                list.drawRemoveButton = false;
                list.Draw();
            }
        }
    }
Esempio n. 2
0
    protected void GUIAnimationRefList(SerializedProperty list, bool showFromTheBeginning)
    {
        var alist = new MadGUI.ArrayList <MadAnimator.AnimationRef>(list, (p) => {
            GUIAnimationRef(p, showFromTheBeginning);
        });

        alist.Draw();
    }
    private void GUIModifiers(SerializedProperty listProperty)
    {
        var list = new MadGUI.ArrayList <MadLevelAnimator.Modifier>(listProperty, (p) => {
            GUIModifier(p);
        });

        list.Draw();
    }
    void OnGUI()
    {
        var arrayList = new MadGUI.ArrayList <MadLevelConfiguration.Group>(conf.groups, @group => {
            if (MadGUI.Button(@group.name))
            {
                var builder = new MadInputDialog.Builder("Rename group " + @group.name, "New name for group " + @group.name,
                                                         newName => TryRename(@group, newName));
                builder.BuildAndShow();
            }
            return(@group);
        });

        arrayList.beforeRemove += @group => {
            if (
                !EditorUtility.DisplayDialog("Remove Group",
                                             "Are you sure that you want to remove group " + @group.name + "?", "Yes", "No"))
            {
                return(false);
            }

            if (group.GetLevels().Count > 0)
            {
                MadUndo.RecordObject2(conf, "Remove Group");

                if (EditorUtility.DisplayDialog("Remove Levels As Well?",
                                                "Do you want to remove all levels in this group as well? "
                                                + "If no, all levels will be moved to default group.", "Yes", "No"))
                {
                    var levels = group.GetLevels();
                    conf.levels.RemoveAll((level) => levels.Contains(level));
                }
                else
                {
                    var defaultGroup = conf.defaultGroup;
                    var levels       = group.GetLevels();
                    foreach (var level in levels)
                    {
                        level.groupId = defaultGroup.id;
                    }
                }
            }

            return(true);
        };

        arrayList.beforeAdd = () => MadUndo.RecordObject2(conf, "Add Group");

        arrayList.createFunctionGeneric = CreateGroup;

        if (arrayList.Draw())
        {
            EditorUtility.SetDirty(conf);
        }
    }
    private void GUIGameObjectList(string header, SerializedProperty array)
    {
        GUILayout.Label(header, "HeaderLabel");

        using (MadGUI.Indent()) {
            var arraylist = new MadGUI.ArrayList <GameObject>(array, property => {
                MadGUI.PropertyField(property, "");
            });
            arraylist.drawOrderButtons = false;
            arraylist.Draw();
        }
    }
Esempio n. 6
0
    private void ArrayFor(List <GameObject> list)
    {
        var arrayList = new MadGUI.ArrayList <GameObject>(list, (s) => {
            MadGUI.PropertyFieldObjectsPopup <GameObject>(target, "", ref s, SpriteList(), false);
            return(s);
        });

        arrayList.createFunctionGeneric = () => { return(null); };
        arrayList.drawOrderButtons      = false;

        arrayList.Draw();
    }
    public override void OnInspectorGUI()
    {
        int number = 1;

        var list = new MadGUI.ArrayList <MadLevelImage.LevelTexture>(script.levelTextures, texture => {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Level " + number++ + ".");
            GUILayout.FlexibleSpace();
            texture.image = (Texture2D)EditorGUILayout.ObjectField("", texture.image, typeof(Texture2D), false);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            return(texture);
        });

        if (list.Draw())
        {
            EditorUtility.SetDirty(script);
        }
    }
    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()
    {
        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();
    }
Esempio n. 10
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();
    }
Esempio n. 11
0
    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();
    }
Esempio n. 12
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

        MadGUI.PropertyField(draggable, "Draggable", MadGUI.ObjectIsSet);
        MadGUI.PropertyField(startDepth, "Start Depth", "Depth value of first layer added. "
                             + "Every next layer will receive +1 to it's depth value.");
        MadGUI.PropertyField(ignoreXMovement, "Ignore X Movement");
        MadGUI.PropertyField(ignoreYMovement, "Ignore Y Movement");

        serializedObject.ApplyModifiedProperties();

        var arrayList = new MadGUI.ArrayList <MadLevelBackgroundLayer>(script.layers, (layer) => {
            if (layer == null)
            {
                return;
            }

            var so = new SerializedObject(layer);
            so.UpdateIfDirtyOrScript();

            var texture = so.FindProperty("texture");

            EditorGUILayout.BeginHorizontal();

            MadGUI.PropertyField(texture, "");

            MadGUI.ConditionallyEnabled(CanMoveUp(layer), () => {
                if (GUILayout.Button("Up"))
                {
                    MoveUp(layer);
                }
            });

            MadGUI.ConditionallyEnabled(CanMoveDown(layer), () => {
                if (GUILayout.Button("Down"))
                {
                    MoveDown(layer);
                }
            });

            GUI.color = Color.yellow;
            if (GUILayout.Button("Select"))
            {
                Selection.activeGameObject = layer.gameObject;
            }
            GUI.color = Color.white;
            EditorGUILayout.EndHorizontal();

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

        arrayList.createFunctionGeneric = () => {
            var layer = MadTransform.CreateChild <MadLevelBackgroundLayer>(script.transform, "layer (empty)");
            layer.GetComponent <MadSprite>().hideFlags = HideFlags.HideInInspector;
            return(layer);
        };
        arrayList.onRemove = (layer) => layer.Cleanup();

        arrayList.beforeAdd = () => {
            MadUndo.RecordObject(script, "Add Background Layer");
            MadUndo.LegacyRegisterSceneUndo("Add Background Layer");
        };

        arrayList.beforeRemove = (arg) => {
            MadUndo.RecordObject(script, "Remove Background Layer");
            MadUndo.LegacyRegisterSceneUndo("Remove Background Layer");
        };

        if (arrayList.Draw())
        {
            EditorUtility.SetDirty(script);
        }


        EditorGUI.BeginChangeCheck();

        if (EditorGUI.EndChangeCheck())
        {
            // changed
        }
    }