Exemplo n.º 1
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();
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
0
    private void SectionSecialProperties()
    {
        MadGUI.BeginBox("Special Properties");
        MadGUI.Indent(() => {
            MadGUI.Warning("Special properties are deprecated. Please use Children section instead.");

            if (levelIcon.generated)
            {
                int levelCount = levelIcon.configuration.LevelCount(MadLevel.Type.Level);
                if (levelCount > levelIcon.levelIndex)
                {
                    var level = levelIcon.level;
                    if (level != null)
                    {
                        MadGUI.Disabled(() => {
                            EditorGUILayout.TextField("Level TypeID", level.name);
                            EditorGUILayout.TextField("Level Arguments", level.arguments);
                        });
                    }
                    else
                    {
                        MadGUI.Warning("Level for this icon no longer exists.");
                    }
                }
                if (MadGUI.InfoFix("These values are set and managed by level configuration.",
                                   "Configuration"))
                {
                    Selection.objects = new Object[] { levelIcon.configuration };
                }
            }

            //
            // Completed property select popup
            //
            EditorGUI.BeginChangeCheck();

            MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>(
                target,
                "\"Completed\" Property",
                ref levelIcon.completedProperty,
                PropertyList(),
                false
                );

            MadGUI.PropertyFieldObjectsPopup <MadLevelProperty>(
                target,
                "\"Locked\" Property",
                ref levelIcon.lockedProperty,
                PropertyList(),
                false
                );
            if (EditorGUI.EndChangeCheck())
            {
                if (levelIcon.completedProperty == null && levelIcon.lockedProperty == null)
                {
                    EditorUtility.DisplayDialog("Hiding Special Properties",
                                                "Special properties are deprecated and they will be now hidden from your inspector view. Please use the Visibility section instead.",
                                                "I understand");
                }
            }
        });
        MadGUI.EndBox();
    }
Exemplo n.º 4
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();
    }