示例#1
0
    // ===========================================================
    // Constructors (Including Static Constructors)
    // ===========================================================

    // ===========================================================
    // Getters / Setters
    // ===========================================================

    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================
    
    public override void OnEnable() {
        base.OnEnable();
        
        textureBar = serializedObject.FindProperty("textureBar");
        atlasTextureBarGUID = serializedObject.FindProperty("atlasTextureBarGUID");
        
        textureBarColorType = serializedObject.FindProperty("textureBarColorType");
        textureBarColor = serializedObject.FindProperty("textureBarColor");
        textureBarGradient = serializedObject.FindProperty("textureBarGradient");
        
        growDirection = serializedObject.FindProperty("growDirection");
        
        radialOffset = serializedObject.FindProperty("radialOffset");
        radialLength = serializedObject.FindProperty("radialLength");
        
        effectBurn = serializedObject.FindProperty("effectBurn");
        effectBurnTextureBar = serializedObject.FindProperty("effectBurnTextureBar");
        atlasEffectBurnTextureBarGUID = serializedObject.FindProperty("atlasEffectBurnTextureBarGUID");
        effectBurnTextureBarColor = serializedObject.FindProperty("effectBurnTextureBarColor");
        
        effectBlink = serializedObject.FindProperty("effectBlink");
        effectBlinkValue = serializedObject.FindProperty("effectBlinkValue");
        effectBlinkRatePerSecond = serializedObject.FindProperty("effectBlinkRatePerSecond");
        effectBlinkColor = serializedObject.FindProperty("effectBlinkColor");
        
        effectFollow = serializedObject.FindProperty("effectFollow");
        effectFollowObject = serializedObject.FindProperty("effectFollowObject");
        effectFollowScaleX = serializedObject.FindProperty("effectFollowScaleX");
        effectFollowScaleY = serializedObject.FindProperty("effectFollowScaleY");
        effectFollowScaleZ = serializedObject.FindProperty("effectFollowScaleZ");
        effectFollowRotation = serializedObject.FindProperty("effectFollowRotation");
        effectFollowColor = serializedObject.FindProperty("effectFollowColor");

        script = target as FilledRenderer3D;
    }
示例#2
0
 static void TryApplyExampleTextures(FilledRenderer3D bar) {
     var textureBar = AssetDatabase.LoadAssetAtPath(
         AssetDatabase.GUIDToAssetPath("cc23715e311bb5944bf44bc1d2fa3aa4"), typeof(Texture2D)) as Texture2D;
     var textureFg = AssetDatabase.LoadAssetAtPath(
         AssetDatabase.GUIDToAssetPath("85dd12640060b1d4285d11cb0f60b8a7"), typeof(Texture2D)) as Texture2D;
     
     if (textureBar != null && textureFg != null) {
         bar.textureBar = textureBar;
         var tex = new EnergyBarBase.Tex();
         tex.texture = textureFg;
         tex.color = Color.white;
         
         bar.texturesBackground = new EnergyBarBase.Tex[1];
         bar.texturesBackground[0] = tex;
     } else {
         Debug.LogWarning("Failed to locate example textures. This is not something bad, but have you changed "
                          + "your Energy Bar Toolkit directory location?");
     }
 }
 static void TryApplyExampleTextures(FilledRenderer3D bar) {
     var textureBar = AssetDatabase.LoadAssetAtPath(
         "Assets/Energy Bar Toolkit/Progress Bar Pack 1/Textures/bar1_bar.png", typeof(Texture2D)) as Texture2D;
     var textureFg = AssetDatabase.LoadAssetAtPath(
         "Assets/Energy Bar Toolkit/Progress Bar Pack 1/Textures/bar1_fg.png", typeof(Texture2D)) as Texture2D;
     
     if (textureBar != null && textureFg != null) {
         bar.textureBar = textureBar;
         var tex = new EnergyBarBase.Tex();
         tex.texture = textureFg;
         tex.color = Color.white;
         
         bar.texturesBackground = new EnergyBarBase.Tex[1];
         bar.texturesBackground[0] = tex;
     } else {
         Debug.LogWarning("Failed to locate example textures. This is not something bad, but have you changed "
                          + "your Energy Bar Toolkit directory location?");
     }
 }
 static void TryApplyExampleTextures(FilledRenderer3D bar) {
     var textureBar = AssetDatabase.LoadAssetAtPath(
         AssetDatabase.GUIDToAssetPath("cc23715e311bb5944bf44bc1d2fa3aa4"), typeof(Texture2D)) as Texture2D;
     var textureFg = AssetDatabase.LoadAssetAtPath(
         AssetDatabase.GUIDToAssetPath("85dd12640060b1d4285d11cb0f60b8a7"), typeof(Texture2D)) as Texture2D;
     
     if (textureBar != null && textureFg != null) {
         bar.textureBar = textureBar;
         var tex = new EnergyBarBase.Tex();
         tex.texture = textureFg;
         tex.color = Color.white;
         
         bar.texturesBackground = new EnergyBarBase.Tex[1];
         bar.texturesBackground[0] = tex;
     } else {
         Debug.LogWarning("Failed to locate example textures. This is not something bad, but have you changed "
                          + "your Energy Bar Toolkit directory location?");
     }
 }
 static void TryApplyExampleTextures(FilledRenderer3D bar) {
     var textureBar = AssetDatabase.LoadAssetAtPath(
         "Assets/Energy Bar Toolkit/Progress Bar Pack 1/Textures/bar1_bar.png", typeof(Texture2D)) as Texture2D;
     var textureFg = AssetDatabase.LoadAssetAtPath(
         "Assets/Energy Bar Toolkit/Progress Bar Pack 1/Textures/bar1_fg.png", typeof(Texture2D)) as Texture2D;
     
     if (textureBar != null && textureFg != null) {
         bar.textureBar = textureBar;
         var tex = new EnergyBarBase.Tex();
         tex.texture = textureFg;
         tex.color = Color.white;
         
         bar.texturesBackground = new EnergyBarBase.Tex[1];
         bar.texturesBackground[0] = tex;
     } else {
         Debug.LogWarning("Failed to locate example textures. This is not something bad, but have you changed "
                          + "your Energy Bar Toolkit directory location?");
     }
 }
    // ===========================================================
    // Constructors (Including Static Constructors)
    // ===========================================================

    // ===========================================================
    // Getters / Setters
    // ===========================================================

    // ===========================================================
    // Methods for/from SuperClass/Interfaces
    // ===========================================================
    
    public override void OnEnable() {
        base.OnEnable();
        
        textureBar = serializedObject.FindProperty("textureBar");
        atlasTextureBarGUID = serializedObject.FindProperty("atlasTextureBarGUID");
        
        textureBarColorType = serializedObject.FindProperty("textureBarColorType");
        textureBarColor = serializedObject.FindProperty("textureBarColor");
        textureBarGradient = serializedObject.FindProperty("textureBarGradient");
        
        growDirection = serializedObject.FindProperty("growDirection");
        
        radialOffset = serializedObject.FindProperty("radialOffset");
        radialLength = serializedObject.FindProperty("radialLength");
        
        effectBurn = serializedObject.FindProperty("effectBurn");
        effectBurnTextureBar = serializedObject.FindProperty("effectBurnTextureBar");
        atlasEffectBurnTextureBarGUID = serializedObject.FindProperty("atlasEffectBurnTextureBarGUID");
        effectBurnTextureBarColor = serializedObject.FindProperty("effectBurnTextureBarColor");
        
        effectBlink = serializedObject.FindProperty("effectBlink");
        effectBlinkValue = serializedObject.FindProperty("effectBlinkValue");
        effectBlinkRatePerSecond = serializedObject.FindProperty("effectBlinkRatePerSecond");
        effectBlinkColor = serializedObject.FindProperty("effectBlinkColor");
        
        effectFollow = serializedObject.FindProperty("effectFollow");
        effectFollowObject = serializedObject.FindProperty("effectFollowObject");
        effectFollowScaleX = serializedObject.FindProperty("effectFollowScaleX");
        effectFollowScaleY = serializedObject.FindProperty("effectFollowScaleY");
        effectFollowScaleZ = serializedObject.FindProperty("effectFollowScaleZ");
        effectFollowRotation = serializedObject.FindProperty("effectFollowRotation");
        effectFollowColor = serializedObject.FindProperty("effectFollowColor");

        script = target as FilledRenderer3D;
    }
示例#7
0
 void OnEnable()
 {
     filled = GetComponent <FilledRenderer3D>();
 }
    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();

            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();
        }
示例#10
0
 void OnEnable()
 {
     filled = GetComponent<FilledRenderer3D>();
 }