summaryrefslogtreecommitdiff
path: root/Assets/BOXOPHOBIC/Utils/Editor/StyledMaterial/StyledCategoryDrawer.cs
blob: 640cfed72df28930ecb80a640b26773d36dc1139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
            }
        }
    }
}