diff options
| author | chai <chaifix@163.com> | 2020-11-26 20:52:34 +0800 | 
|---|---|---|
| committer | chai <chaifix@163.com> | 2020-11-26 20:52:34 +0800 | 
| commit | 5b158af90739dcbb89c1538a6cb8c65a875dce80 (patch) | |
| tree | f0437fff6efaab91ac850152a08aef288d572aab /Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs | |
| parent | bc4d5201fc537f70cdcb576b57aaeb5d96527112 (diff) | |
*misc
Diffstat (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs')
| -rw-r--r-- | Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs | 45 | 
1 files changed, 45 insertions, 0 deletions
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs new file mode 100644 index 00000000..640cfed7 --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs @@ -0,0 +1,45 @@ +// Cristian Pop - https://boxophobic.com/
 +
 +using UnityEngine;
 +using UnityEditor;
 +using System;
 +
 +namespace Boxophobic.StyledGUI
 +{
 +    public class StyledCategoryDrawer : MaterialPropertyDrawer
 +    {
 +        public string category;
 +
 +        public StyledCategoryDrawer(string category)
 +        {
 +            this.category = category;
 +        }
 +
 +        public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materiaEditor)
 +        {
 +            if (prop.floatValue < 0)
 +            {
 +                GUI.enabled = true;
 +                EditorGUI.indentLevel = 0;
 +            }
 +            else
 +            {
 +                GUI.enabled = true;
 +                EditorGUI.indentLevel = 0;
 +                StyledGUI.DrawInspectorCategory(position, category);
 +            }
 +        }
 +
 +        public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
 +        {
 +            if (prop.floatValue < 0)
 +            {
 +                return -2;
 +            }
 +            else
 +            {
 +                return 40;
 +            }
 +        }
 +    }
 +}
  | 
