protected void FieldSetNativeSize()
 {
     if (MadGUI.Button("Set Native Size"))
     {
         var b = (EnergyBarUGUIBase)target;
         MadUndo.RecordObject2(b.gameObject, "Set Native Size");
         b.SetNativeSize();
     }
 }
Пример #2
0
        void OnGUI()
        {
            MadGUI.Info("There's more than one Panel on the scene. Please set the one that you want to create the bar on.");

            panel   = EditorGUILayout.ObjectField("Panel", panel, typeof(MadPanel), true) as MadPanel;
            barType = (EnergyBar3DBase.BarType)EditorGUILayout.EnumPopup("Bar Type", barType);

            GUI.enabled = panel != null;
            if (MadGUI.Button("Create", Color.green))
            {
                EnergyBarUtils.Create3DBar(barType, panel);
                Close();
            }
            GUI.enabled = true;
        }
Пример #3
0
    private void FieldBatchTextureSet() {
        MadGUI.Info("If your atlas textures have regular names (like part_01, part_02) then you can add them all at once. "
            + "Just enter here something like 'part_??' where ?? are placeholders for digits, and then press the button below.");

        nameTemplate = EditorGUILayout.TextField("Name Template", nameTemplate);

        if (MadGUI.Button("Batch Texture Set", Color.yellow)) {
            if (EditorUtility.DisplayDialog("Batch Texture Set", "Are you sure that you want to overwrite your texture settings?", "Yes", "No")) {
                MadUndo.RecordObject2(script, "Batch Texture Set");

                var regex = "^" + nameTemplate.Replace("?", "[0-9]") + "$";
                var filtered = from i in script.atlas.items where Regex.Match(i.name, regex).Success orderby i.name select i;
                var filteredArr = filtered.ToArray();

                for (int i = 0; i < script.sequenceAtlasTexturesGUID.Length && i < filteredArr.Length; ++i) {
                    script.sequenceAtlasTexturesGUID[i] = filteredArr[i].textureGUID;
                }
            }
        }
    }
Пример #4
0
    protected void SectionPositionAndSize() {
        var script = target as EnergyBar3DBase;

        Section("Position & Size", () => {
            if (MadGUI.Button("Make Pixel-Perfect", Color.yellow)) {
                script.transform.localPosition = MadMath.Round(script.transform.localPosition);
                script.transform.localScale = new Vector3(1, 1, 1);
                EditorUtility.SetDirty(script);
            }

            if (!IsAnchored()) {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Anchor");
                if (MadGUI.Button("Create", Color.yellow)) {
                    CreateAnchor();
                }
                EditorGUILayout.EndHorizontal();
            } else {
                var anchor = GetAnchor();
                var serAnchor = new SerializedObject(anchor);
                MadAnchorInspector.DrawInspector(serAnchor);
            }

            EditorGUI.BeginChangeCheck();
            script.pivot = (EnergyBar3DBase.Pivot) EditorGUILayout.EnumPopup("Pivot Point", script.pivot);
            if (EditorGUI.EndChangeCheck()) {
                EditorUtility.SetDirty(script);
            }
            MadGUI.PropertyField(guiDepth, "GUI Depth");

            EditorGUILayout.Space();

            MadGUI.PropertyFieldEnumPopup(lookAtMode, "Look At");
            MadGUI.Indent(() => {
                if(lookAtMode.enumValueIndex == (int) EnergyBar3DBase.LookAtMode.CustomObject) { 
                    MadGUI.PropertyField(lookAtObject, "Target Object", MadGUI.ObjectIsSet);
                }
            });
        });
    }
    public override void OnInspectorGUI() {
        serializedObject.Update();
        
        script = target as FilledRenderer3D;
        
        if (MadGUI.Foldout("Textures", true)) {
            MadGUI.BeginBox();
            FieldBackgroundTextures();
            
            EditorGUILayout.PropertyField(textureBar, new GUIContent("Bar Texture"));         
            CheckTextureIsReadable(script.textureBar);
            CheckTextureFilterTypeNotPoint(script.textureBar);
            
            FieldForegroundTextures();
            
            FieldPremultipliedAlpha();
            MadGUI.EndBox();
        }
        
        if (showPositionAndSize && MadGUI.Foldout("Position & Size", true)) {
            MadGUI.BeginBox();
            
            if (MadGUI.Button("Make Pixel-Perfect")) {
                script.transform.localPosition = MadMath.Round(script.transform.localPosition);
                script.transform.localScale = new Vector3(1, 1, 1);
                EditorUtility.SetDirty(script);
            }
            
            if (!IsAnchored()) {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Anchor");
                if (GUILayout.Button("Create")) {
                    CreateAnchor();
                }
                EditorGUILayout.EndHorizontal();
            } else {
                var anchor = GetAnchor();
                var serAnchor = new SerializedObject(anchor);
                MadAnchorInspector.DrawInspector(serAnchor);
            }

            EditorGUI.BeginChangeCheck();
            script.pivot = (EnergyBar3DBase.Pivot) EditorGUILayout.EnumPopup("Pivot Point", script.pivot);
            if (EditorGUI.EndChangeCheck()) {
                EditorUtility.SetDirty(script);
            }
            MadGUI.PropertyField(guiDepth, "GUI Depth");
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Appearance", false)) {
            MadGUI.BeginBox();
            
            var dir = (EnergyBarRenderer.GrowDirection) growDirection.enumValueIndex;
        
            if (dir == EnergyBarRenderer.GrowDirection.ColorChange) {
                GUI.enabled = false;
            }
            EditorGUILayout.PropertyField(textureBarColorType, new GUIContent("Bar Color Type"));
            EditorGUI.indentLevel++;
                switch ((EnergyBarRenderer.ColorType)textureBarColorType.enumValueIndex) {
                    case EnergyBarRenderer.ColorType.Solid:
                        EditorGUILayout.PropertyField(textureBarColor, new GUIContent("Bar Color"));
                        break;
                        
                    case EnergyBarRenderer.ColorType.Gradient:
                        EditorGUILayout.PropertyField(textureBarGradient, new GUIContent("Bar Gradient"));
                        break;
                }
                
            EditorGUI.indentLevel--;
            
            GUI.enabled = true;
            
            EditorGUILayout.PropertyField(growDirection, new GUIContent("Grow Direction"));
            
            if (dir == EnergyBarRenderer.GrowDirection.RadialCW || dir == EnergyBarRenderer.GrowDirection.RadialCCW) {
                MadGUI.Indent(() => {
                    EditorGUILayout.Slider(radialOffset, -1, 1, "Offset");
                    EditorGUILayout.Slider(radialLength, 0, 1, "Length");
                });
            } else if (dir == EnergyBarRenderer.GrowDirection.ColorChange) {
                EditorGUILayout.PropertyField(textureBarGradient, new GUIContent("Bar Gradient"));
            }
            
            FieldLabel();
            
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Effects", false)) {
            MadGUI.BeginBox();
            
            FieldSmoothEffect();
            
            MadGUI.PropertyFieldToggleGroup2(effectBurn, "Burn Out", () => {
                MadGUI.Indent(() => {
                    MadGUI.PropertyField(effectBurnTextureBar, "Burn Texture Bar");
                    MadGUI.PropertyField(effectBurnTextureBarColor, "Burn Color");
                });
            });
            
            MadGUI.PropertyFieldToggleGroup2(effectBlink, "Blink", () => {
                MadGUI.Indent(() => {
                    MadGUI.PropertyField(effectBlinkValue, "Value");
                    MadGUI.PropertyField(effectBlinkRatePerSecond, "Rate (per second)");
                    MadGUI.PropertyField(effectBlinkColor, "Color");
                });
            });
            
            MadGUI.PropertyFieldToggleGroup2(effectFollow, "Sprite Follow", () => {
                MadGUI.Indent(() => {
                    if (GUI.enabled && !GrowDirectionSupportedByFollowEffect()) {
                        MadGUI.Error("This effect cannot be used with selected grow direction. "
                            + "Please read manual for more information.");
                    }
                
                    MadGUI.PropertyField(effectFollowObject, "Texture or GameObject",
                        "This can be Texture, MadSprite or any other GameObject.");
                        
                    if (!VerifyFollowObject()) {
                        MadGUI.Error("You can put here only Texture2D or GameObject.");
                    }
                        
                    MadGUI.PropertyField(effectFollowColor, "Color");
                    MadGUI.PropertyField(effectFollowRotation, "Rotation");
                    if (MadGUI.Foldout("Scale", false)) {
                        MadGUI.Indent(() => {
                            MadGUI.PropertyField(effectFollowScaleX, "X");
                            MadGUI.PropertyField(effectFollowScaleY, "Y");
                            MadGUI.PropertyField(effectFollowScaleZ, "Z");
                        });
                    }
                    
                    
                });
            });
            
            MadGUI.EndBox();
        }
        
        EditorGUILayout.Space();
        
        serializedObject.ApplyModifiedProperties();
    }
    public override void OnInspectorGUI() {
        serializedObject.Update();
        
        var t = target as RepeatedRenderer3D;
        
        if (MadGUI.Foldout("Textures", true)) {
            MadGUI.BeginBox();
            
            EditorGUILayout.BeginHorizontal();
            MadGUI.PropertyField(textureIcon, "Icon");
            EditorGUILayout.PropertyField(tintIcon, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();
            
            EditorGUILayout.BeginHorizontal();
            MadGUI.PropertyField(textureSlot, "Slot");
            EditorGUILayout.PropertyField(tintSlot, new GUIContent(""), new GUILayoutOption[] { GUILayout.Width(50) });
            EditorGUILayout.EndHorizontal();
            
            CheckTextureIsReadable(t.textureIcon);
            CheckTextureIsReadable(t.textureSlot);
            
            MadGUI.EndBox();
        }
        
        if (showPositionAndSize && MadGUI.Foldout("Position & Size", true)) {
            MadGUI.BeginBox();
            
            if (MadGUI.Button("Make Pixel-Perfect")) {
                t.transform.localPosition = MadMath.Round(t.transform.localPosition);
                t.transform.localScale = new Vector3(1, 1, 1);
                EditorUtility.SetDirty(t);
            }
            
            if (!IsAnchored()) {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Anchor");
                if (GUILayout.Button("Create")) {
                    CreateAnchor();
                }
                EditorGUILayout.EndHorizontal();
            } else {
                var anchor = GetAnchor();
                var serAnchor = new SerializedObject(anchor);
                MadAnchorInspector.DrawInspector(serAnchor);
            }

            EditorGUI.BeginChangeCheck();
            t.pivot = (EnergyBar3DBase.Pivot) EditorGUILayout.EnumPopup("Pivot Point", t.pivot);
            if (EditorGUI.EndChangeCheck()) {
                EditorUtility.SetDirty(t);
            }
            
            MadGUI.PropertyField(guiDepth, "GUI Depth");
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Appearance", false)) {
            MadGUI.BeginBox();
            
            MadGUI.PropertyField(repeatCount, "Repeat Count");
            MadGUI.PropertyFieldVector2(repeatPositionDelta, "Icon Distance");
            
            MadGUI.PropertyField(growType, "Grow Type");
            MadGUI.ConditionallyEnabled(growType.enumValueIndex == (int) RepeatedRenderer3D.GrowType.Fill, () => {
                MadGUI.PropertyField(fillDirection, "Fill Direction");
            });
            
            FieldLabel();
            
            MadGUI.EndBox();
        }
        
        if (MadGUI.Foldout("Effects", false)) {
            MadGUI.BeginBox();
            
            FieldSmoothEffect();
            
            MadGUI.EndBox();
        }
        
        EditorGUILayout.Space();
        
        serializedObject.ApplyModifiedProperties();
    }