blob: 3f321cbe1e0dc0881fc71459fe5184d056ca29ea (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using System;
namespace Boxophobic.StyledGUI
{
public class StyledInteractiveDrawer : MaterialPropertyDrawer
{
public string keyword;
public float value1 = -1f;
public float value2 = -1f;
public float value3 = -1f;
protected int type;
public StyledInteractiveDrawer(string k)
{
type = 0;
keyword = k;
}
public StyledInteractiveDrawer(string k, float v1)
{
type = 1;
keyword = k;
value1 = v1;
}
public StyledInteractiveDrawer(string k, float v1, float v2)
{
type = 1;
keyword = k;
value1 = v1;
value2 = v2;
}
public StyledInteractiveDrawer(string k, float v1, float v2, float v3)
{
type = 1;
keyword = k;
value1 = v1;
value2 = v2;
value3 = v3;
}
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
{
Material material = materialEditor.target as Material;
if (type == 1)
{
if (material.HasProperty(keyword))
{
if (value1 == material.GetFloat(keyword) || value2 == material.GetFloat(keyword) || value3 == material.GetFloat(keyword))
{
GUI.enabled = true;
}
else
{
GUI.enabled = false;
}
}
}
else if (type == 0)
{
if (keyword == "ON")
{
GUI.enabled = true;
}
else if (keyword == "OFF")
{
GUI.enabled = false;
}
else if (material.IsKeywordEnabled(keyword))
{
GUI.enabled = true;
}
else
{
GUI.enabled = false;
}
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
return -2;
}
}
}
|