Exemplo n.º 1
0
    // ===========================================================
    // Methods
    // ===========================================================

    void OnGUI()
    {
        MadGUI.Info("This tool initialized your scene for GUI drawing. Please choose root object name and layer "
                    + "on which GUI will be painted.");

        rootObjectName = EditorGUILayout.TextField("Root Name", rootObjectName);
        layer          = EditorGUILayout.LayerField("Layer", layer);

        OnFormGUI();

        if (GUILayout.Button("Create"))
        {
            var  panel  = MadPanel.UniqueOrNull();
            bool doInit = true;
            if (panel != null)
            {
                doInit = EditorUtility.DisplayDialog("Scene initialized", "Scene looks like it is already initialized. "
                                                     + "Are you sure that you want to continue?", "Yes", "No");
            }

            if (doInit)
            {
                root = Init(rootObjectName, layer, hideInvisibleSprites, depthBasedRenderMode);
                AfterCreate(root);
            }
        }
    }
Exemplo n.º 2
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);

        if (serializedObject.ApplyModifiedProperties())
        {
            layer.SetDirty();
        }
    }
Exemplo n.º 3
0
    private void CheckConflictError()
    {
        var set = new HashSet <GameObject>();

        foreach (List <GameObject> list in new List <GameObject>[] {
            levelIcon.showWhenLevelCompleted,
            levelIcon.showWhenLevelLocked,
            levelIcon.showWhenLevelNotCompleted,
            levelIcon.showWhenLevelUnlocked
        })
        {
            foreach (var el in list)
            {
                if (el == null)
                {
                    continue;
                }

                if (!set.Contains(el))
                {
                    set.Add(el);
                }
                else
                {
                    MadGUI.Error("Child \"" + el.name + "\" is set in multiple places.");
                }
            }
        }
    }
Exemplo n.º 4
0
 public override void OnInspectorGUI() {
     serializedObject.UpdateIfDirtyOrScript();
 
     MadGUI.PropertyField(dragArea, "Drag Area");
     MadGUI.PropertyFieldVector2(dragStartPosition, "Drag Start Position");
     
     MadGUI.PropertyField(scaling, "Allow Scaling");
     MadGUI.ConditionallyEnabled(scaling.boolValue, () => {
         MadGUI.Indent(() => {
             MadGUI.PropertyField(scalingMin, "Scaling Min");
             MadGUI.PropertyField(scalingMax, "Scaling Max");
         });
     });
     
     MadGUI.PropertyField(moveEasing, "Move Easing");
     MadGUI.ConditionallyEnabled(moveEasing.boolValue, () => {
         MadGUI.Indent(() => {
             MadGUI.PropertyField(moveEasingType, "Type");
             MadGUI.PropertyField(moveEasingDuration, "Duration");
         });
     });
     
     MadGUI.PropertyField(scaleEasing, "Scale Easing");
     MadGUI.ConditionallyEnabled(scaleEasing.boolValue, () => {
         MadGUI.Indent(() => {
             MadGUI.PropertyField(scaleEasingType, "Type");
             MadGUI.PropertyField(scaleEasingDuration, "Duration");
         });
     });
     
     serializedObject.ApplyModifiedProperties();
 }
    protected override void GUIElements()
    {
        base.GUIElements();

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

        using (MadGUI.Indent()) {
            EditorGUILayout.LabelField("Delay");
            using (MadGUI.Indent()) {
                GUIModifiers(delayModifiers);
            }

            EditorGUILayout.LabelField("Offset");
            using (MadGUI.Indent()) {
                GUIModifiers(offsetModifiers);
            }
        }

        GUILayout.Label("Startup Properties", "HeaderLabel");

        using (MadGUI.Indent()) {
            GUIStartupProperty(startupPositionApplyMethod, startupPosition, "Position");
            GUIStartupProperty(startupRotationApplyMethod, startupRotation, "Rotation");
            GUIStartupProperty(startupScaleApplyMethod, startupScale, "Scale");
        }
    }
Exemplo n.º 6
0
    protected void GUIEvent(string name, SerializedProperty property)
    {
        int  playCount, stopCount;
        bool stopAll;

        AnalyzeAction(property, out playCount, out stopCount, out stopAll);

        bool colorize = playCount > 0 || stopCount > 0 || stopAll;

        if (colorize)
        {
            GUI.color = Color.yellow;
        }

        if (MadGUI.Foldout(name, false))
        {
            GUI.color = Color.white;

            using (MadGUI.Indent()) {
                GUIAction(property);
            }
        }

        GUI.color = Color.white;
    }
    private void FieldLiveBounds()
    {
        int texWidth  = sprite.currentTextureWidth;
        int texHeight = sprite.currentTextureHeight;

        MadGUI.PropertyField(hasLiveBounds, "Has Border");

        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();
    }
Exemplo n.º 8
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();
            }
        }
    }
Exemplo n.º 9
0
    // ===========================================================
    // Static Methods
    // ===========================================================

    public static void DrawInspector(SerializedObject so)
    {
        so.Update();

        var mode         = so.FindProperty("mode");
        var position     = so.FindProperty("position");
        var anchorObject = so.FindProperty("anchorObject");
        var anchorCamera = so.FindProperty("anchorCamera");
        var moveIn3D     = so.FindProperty("moveIn3D");
        var faceCamera   = so.FindProperty("faceCamera");

        MadGUI.PropertyField(mode, "Mode");
        switch ((MadAnchor.Mode)mode.enumValueIndex)
        {
        case MadAnchor.Mode.ObjectAnchor:
            MadGUI.PropertyField(anchorObject, "Anchor Object");
            MadGUI.PropertyField(anchorCamera, "Anchor Camera");
            MadGUI.PropertyField(moveIn3D, "Move In 3D");
            MadGUI.PropertyField(faceCamera, "Face Camera", "Bar graphics will always face anchor camera.");
            break;

        case MadAnchor.Mode.ScreenAnchor:
            MadGUI.PropertyField(position, "Position");
            break;

        default:
            MadDebug.Assert(false, "Unknown mode: " + (MadAnchor.Mode)mode.enumValueIndex);
            break;
        }

        so.ApplyModifiedProperties();
    }
Exemplo n.º 10
0
    void GUICreator(bool recreate)
    {
        serializedObject.Update();
        MadGUI.PropertyField(inputType, "Input Type");

        bool canCreate = false;

        switch ((MadFont.InputType)inputType.enumValueIndex)
        {
        case MadFont.InputType.TextureAndGlyphList:
            canCreate = GUITextureAndGlyphListCreator();
            break;

        case MadFont.InputType.Bitmap:
            canCreate = GUIBitmapFontCreator();
            break;
        }

        MadGUI.PropertyField(forceWhite, "Force White Color", "Forces this font to be rendered with white color only.");

        serializedObject.ApplyModifiedProperties();

        GUI.enabled = canCreate;
        if (GUILayout.Button(recreate ? "Recreate" : "Create"))
        {
            var builder = new MadFontBuilder(target as MadFont);
            builder.white = forceWhite.boolValue;
            builder.Build();
        }
        GUI.enabled = true;
    }
Exemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        chosenBackend = EditorGUILayout.Popup(
            "Load & Save Backend", chosenBackend, backendDisplayedNameList.ToArray());
        if (EditorGUI.EndChangeCheck())
        {
            settings.profileBackend = IndexToBackend(chosenBackend);
            EditorUtility.SetDirty(settings);
        }

        if (backendList.Count <= chosenBackend)
        {
            return;
        }

        string backend = backendList[chosenBackend];

        DrawBackendProperties(backend);

        EditorGUILayout.Space();
        DrawBackendHelpIfAvailable(backend);

        if (backendList[chosenBackend] == (typeof(MadLevelProfile.DefaultBackend).FullName))
        {
            MadGUI.Info("To get access to more Load & Save backends, unpack packages from the \"Mad Level Manager/Save Load Backends\" directory.");
        }
    }
Exemplo n.º 12
0
    public override void OnInspectorGUI()
    {
        GUICreator(script.created);

        switch (script.createStatus)
        {
        case MadFont.CreateStatus.None:
            MadGUI.Warning("This font is not yet created. Please fill above and click on the Create button.");
            break;

        case MadFont.CreateStatus.TooMuchGlypsDefined:
            MadGUI.Error("There more glyphs declared than found in the texture.");
            break;

        case MadFont.CreateStatus.TooMuchGlypsFound:
            MadGUI.Error("There more glyphs found in the texture than declared.");
            break;

        case MadFont.CreateStatus.Ok:
            // nothing wrong
            break;

        default:
            MadDebug.Assert(false, "Unknown create status: " + script.createStatus);
            break;
        }

//        MadGUI.Info("This field is read-only");
//        EditorGUILayout.TextArea(font.dimensions);
    }
Exemplo n.º 13
0
    public static void OnEditorGUIExpired(string toolName)
    {
        MadGUI.Error("This is an evaluation version of " + toolName + " and your evaluation period has expired. If you want to continue using " + toolName + " please purchase it or send a request for another evaluation period.");

        EditorGUILayout.Space();

        if (MadGUI.Button("Purchase", Color.yellow))
        {
            Application.OpenURL(PurchaseUrl);
        }

        EditorGUILayout.Space();

        if (MadGUI.Button("Request Another Evaluation Period", Color.magenta))
        {
            RequestExtend(toolName);
        }

        if (MadGUI.Button("I Have An Evaluation Key!", Color.green))
        {
            var builder = new MadInputDialog.Builder("Enter Key", "Enter new evaluation key.", (key) => {
                if (!string.IsNullOrEmpty(key))
                {
                    Extend(key.Trim());
                }
            });
            builder.BuildAndShow();
        }
    }
    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);
                }
            }
        }
    }
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

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

        serializedObject.ApplyModifiedProperties();
    }
    protected void LookAtLastLevel()
    {
        MadGUI.PropertyField(lookAtLastLevel, "Look At Previous Level", "When scene is loaded, it will automatically "
                             + "go to the previously played level (but only if previous scene is of type Level.");

        GUILayout.Label("If above is disabled or cannot be determined, then...");

        MadGUI.PropertyFieldEnumPopup(lookAtLevel, "Look At Level");
    }
Exemplo n.º 17
0
 public static void LineHelp(ref bool state, string helpMessage, RunnableVoid0 runnable) {
     EditorGUILayout.BeginHorizontal();
     runnable();
     state = GUILayout.Toggle(state, "?", "Button", GUILayout.Width(20));
     EditorGUILayout.EndHorizontal();
     if (state) {
         MadGUI.Message("Help:\n" + helpMessage, MessageType.Info);
     }
 }
Exemplo n.º 18
0
    void GUICreator(bool created)
    {
        serializedObject.Update();
        MadGUI.PropertyField(inputType, "Input Type");

        bool canCreate = false;

        switch ((MadFont.InputType)inputType.enumValueIndex)
        {
        case MadFont.InputType.TextureAndGlyphList:
            canCreate = GUITextureAndGlyphListCreator();
            break;

        case MadFont.InputType.Bitmap:
            canCreate = GUIBitmapFontCreator();
            break;
        }

        EditorGUI.BeginChangeCheck();
        MadGUI.PropertyField(forceWhite, "Force White Color", "Forces this font to be rendered with white color only.");
        if (EditorGUI.EndChangeCheck())
        {
            if (script.created)
            {
                ReloadColors();
            }
        }

        MadGUI.ConditionallyEnabled(!forceWhite.boolValue, () => {
            EditorGUI.BeginChangeCheck();
            primaryColor   = EditorGUILayout.ColorField("Primary Color", primaryColor);
            secondaryColor = EditorGUILayout.ColorField("Secondary Color", secondaryColor);
            if (EditorGUI.EndChangeCheck())
            {
                if (created)
                {
                    SetColors();
                }
            }
        });

        serializedObject.ApplyModifiedProperties();

        GUI.enabled = canCreate;
        if (GUILayout.Button(created ? "Recreate" : "Create"))
        {
            var builder = new MadFontBuilder(script);
            builder.white = forceWhite.boolValue;
            builder.Build();

            if (!forceWhite.boolValue && script.created)
            {
                SetColors();
            }
        }
        GUI.enabled = true;
    }
Exemplo n.º 19
0
    public override void OnInspectorGUI()
    {
        serializedObject.UpdateIfDirtyOrScript();

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

        DrawInspector();
        EditorGUILayout.Space();

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

        MadGUI.PropertyField(useAnimationCurve, "Use Animation Curve");
        using (MadGUI.Indent()) {
            if (!useAnimationCurve.boolValue)
            {
                MadGUI.PropertyFieldEnumPopup(easing, "Easing");
            }
            else
            {
                MadGUI.PropertyField(animationCurve, "Curve");
            }
        }
        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 TypeID", MadGUI.StringNotEmpty);
            }
        }

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

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

        MadGUI.PropertyField(ignoreTimeScale, "Ignore Time Scale");

        serializedObject.ApplyModifiedProperties();
    }
    private void TopPanel()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("For Configuration: ");
        if (MadGUI.Button(configuration.name, Color.cyan))
        {
            Selection.activeObject = configuration;
        }

        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        int extensionCount = configuration.extensions.Count;

        if (extensionCount > 0)
        {
            MadGUI.LookLikeControls(120, 150);
            selectedExtensionIndex = MadGUI.DynamicPopup(selectedExtensionIndex, "Current Extension:", extensionCount, (index) => {
                var extension = configuration.extensions[index];
                return(extension.name);
            });
            MadGUI.LookLikeControls(0);

            GUILayout.FlexibleSpace();
            if (MadGUI.Button("Remove", Color.red))
            {
                RemoveExtension(selectedExtensionIndex);
            }
        }
        else
        {
            GUILayout.Label("There's no extensions yet.");
        }

        GUILayout.Space(10);

        if (MadGUI.Button("Create New Extension", Color.green))
        {
            var builder = new MadInputDialog.Builder("Create New Extension", "Enter a new extension name.", (result) => {
                if (!string.IsNullOrEmpty(result))
                {
                    var extension = CreateNewExtension(result);
                    if (extension != null)
                    {
                        currentExtension = extension;
                    }
                }
            });
            builder.BuildAndShow();
        }
        EditorGUILayout.EndHorizontal();
    }
Exemplo n.º 21
0
    protected void GUIAnimationName(SerializedProperty animationName)
    {
        int  MissingAnimationNameNum = animationNames.Count + 1;
        bool animationNameMissing    = false;

        string selectedAnimationName = animationName.stringValue;
        int    animationNameNum      = animationNames.FindIndex((s) => s == selectedAnimationName) + 1;

        if (!string.IsNullOrEmpty(selectedAnimationName) && animationNameNum == 0)
        {
            // there was animation name, but it's not available now
            animationNameNum     = MissingAnimationNameNum;
            animationNameMissing = true;
            GUI.backgroundColor  = Color.red;
        }

        EditorGUI.BeginChangeCheck();

        animationNameNum = MadGUI.DynamicPopup(animationNameNum, "Name", animationNames.Count + 1 + (animationNameMissing ? 1 : 0), (index) => {
            if (index == 0)
            {
                return("(none)");
            }
            else if (index == MissingAnimationNameNum)
            {
                return(selectedAnimationName + " (missing)");
            }
            else
            {
                return(animationNames[index - 1]);
            }
        });

        GUI.backgroundColor = Color.white;

        if (animationNameMissing)
        {
            MadGUI.Warning("The animation with this name cannot be found.");
        }

        if (EditorGUI.EndChangeCheck())
        {
            if (animationNameNum == 0)
            {
                animationName.stringValue = "";
            }
            else if (animationNameNum == MissingAnimationNameNum)
            {
                // do nothing
            }
            else
            {
                animationName.stringValue = animationNames[animationNameNum - 1];
            }
        }
    }
Exemplo n.º 22
0
    private void PropertyFieldAnimationName(SerializedProperty animationName, string label)
    {
        //string nameBefore = animationName.stringValue;
        MadGUI.PropertyField(animationName, "Animation TypeID");
        //string nameAfter = animationName.stringValue;

        //if (nameBefore != nameAfter) {
        //    UpdateAnimationName(nameBefore, nameAfter);
        //}
    }
Exemplo n.º 23
0
 private void GUIStartupProperty(SerializedProperty method, SerializedProperty value, string label)
 {
     MadGUI.PropertyFieldEnumPopup(method, label);
     if (method.enumValueIndex != (int)MadLevelAnimator.ApplyMethod.DoNotChange)
     {
         using (MadGUI.Indent()) {
             MadGUI.PropertyField(value, "");
             EditorGUILayout.Space();
         }
     }
 }
    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);
        }
    }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Property Name: " + target.name);
        EditorGUILayout.Space();

        MadGUI.Info("Rename this object to match the property name that text value you want to display. "
                    + "When property is not set then the default text will be displayed.");

        EditorGUILayout.Space();
    }
Exemplo n.º 26
0
 protected void ArrayList(SerializedProperty property, string title, Runnable1<SerializedProperty> renderer) {
     if (Foldout(title, false)) {
         MadGUI.Indent(() => {
             if (property.arraySize == 0) {
                 GUILayout.Label("   Use 'Add' button to add items");
             } else {
                 int arrSize = property.arraySize;
                 Separator();
                 for (int i = 0; i < arrSize; ++i) {
                     var go = property.GetArrayElementAtIndex(i);
                     EditorGUILayout.BeginHorizontal();
                     
                     EditorGUILayout.BeginVertical();
                     renderer(go);
                     EditorGUILayout.EndVertical();
                     
                     GUI.color = Color.red;
                     if (GUILayout.Button("X", GUILayout.ExpandWidth(false))) {
                         property.DeleteArrayElementAtIndex(i);
                         arrSize--;
                     }
                     GUI.color = Color.white;
                     EditorGUILayout.EndHorizontal();
                     
                     if (i + 1 < arrSize) {
                         EditorGUILayout.Space();
                     }
                     Separator();
                 }
             }
             
             GUI.color = Color.green;
             EditorGUILayout.BeginHorizontal();
             GUILayout.FlexibleSpace();
             if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) {
                 property.arraySize++;
                 
                 // when creating new array element like this, the color will be initialized with
                 // (0, 0, 0, 0) - zero aplha. This may be confusing for end user so this workaround looks
                 // for color fields and sets them to proper values                  
                 var element = property.GetArrayElementAtIndex(property.arraySize - 1);                  
                 var enumerator = element.GetEnumerator();
                 while (enumerator.MoveNext()) {
                     var el = enumerator.Current as SerializedProperty;
                     if (el.type == "ColorRGBA") {
                         el.colorValue = Color.black;
                     }
                 }
             }
             GUI.color = Color.white;
             EditorGUILayout.EndHorizontal();
         });
     }
 }
 void CheckAssetLocation()
 {
     if (!IsAssetLocationRight())
     {
         if (MadGUI.ErrorFix(
                 "Configuration should be placed in Resources/LevelConfig directory", "Where it is now?"))
         {
             EditorGUIUtility.PingObject(configuration);
         }
     }
 }
    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();
        }
    }
Exemplo n.º 29
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();
    }
    void ActivateAction(
        SerializedProperty playAudio,
        SerializedProperty playAudioClip,
        SerializedProperty playAudioVolume,
        SerializedProperty message,
        SerializedProperty messageReceiver,
        SerializedProperty messageMethodName,
        SerializedProperty messageIncludeChildren
        )
    {
        MadGUI.PropertyField(playAudio, "Play Audio");
        MadGUI.ConditionallyEnabled(playAudio.boolValue, () => {
            MadGUI.Indent(() => {
                if (playAudio.boolValue && !FoundAudioListener())
                {
                    if (MadGUI.ErrorFix("There's no AudioListener on the scene. Do you want me to add an "
                                        + "AudioListener to Camera 2D?", "Add"))
                    {
                        var camera = MadTransform.FindParent <Camera>((target as Component).transform);
                        if (camera == null)
                        {
                            camera = FindObjectOfType(typeof(Camera)) as Camera;
                        }
                        if (camera != null)
                        {
                            camera.gameObject.AddComponent <AudioListener>();
                        }
                        else
                        {
                            Debug.LogError("There's no camera on this scene!");
                        }
                    }
                }

                MadGUI.PropertyField(playAudioClip, "Audio Clip", MadGUI.ObjectIsSet);
                MadGUI.PropertyFieldSlider(playAudioVolume, 0, 1, "Volume");
            });
        });

        MadGUI.PropertyField(message, "Send Message");
        MadGUI.ConditionallyEnabled(message.boolValue, () => {
            MadGUI.Indent(() => {
                MadGUI.PropertyField(messageReceiver, "Receiver", MadGUI.ObjectIsSet);
                MadGUI.PropertyField(messageMethodName, "Method Name", MadGUI.StringNotEmpty);
                MadGUI.PropertyField(messageIncludeChildren, "Include Children");

                if (message.boolValue)
                {
                    MadGUI.Info("This should look like this:\nvoid " + messageMethodName.stringValue + "(MadLevelIcon icon)");
                }
            });
        });
    }