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
|
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
using System;
namespace Boxophobic.StyledGUI
{
public class StyledMessageDrawer : MaterialPropertyDrawer
{
public string type;
public string message;
public string keyword;
public float value;
public float top;
public float down;
MessageType mType;
public StyledMessageDrawer(string t, string m, float top, float down)
{
type = t;
message = m;
keyword = null;
this.top = top;
this.down = down;
}
public StyledMessageDrawer(string t, string m, string k, float v, float top, float down)
{
type = t;
message = m;
keyword = k;
value = v;
this.top = top;
this.down = down;
}
public override void OnGUI(Rect position, MaterialProperty prop, String label, MaterialEditor materialEditor)
{
Material material = materialEditor.target as Material;
if (type == "None")
{
mType = MessageType.None;
}
else if (type == "Info")
{
mType = MessageType.Info;
}
else if (type == "Warning")
{
mType = MessageType.Warning;
}
else if (type == "Error")
{
mType = MessageType.Error;
}
if (keyword != null)
{
if (material.HasProperty(keyword))
{
if (material.GetFloat(keyword) == value)
{
GUILayout.Space(top);
//EditorGUI.DrawRect(new Rect(position.x, position.y + Top, position.width, position.height), new Color(1,0,0,0.3f));
EditorGUILayout.HelpBox(message, mType);
//EditorGUI.HelpBox(new Rect(position.x, position.y + top, position.width, position.height), message, mType);
GUILayout.Space(down);
}
}
}
else
{
GUILayout.Space(top);
EditorGUILayout.HelpBox(message, mType);
GUILayout.Space(down);
}
}
public override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
{
return -2;
}
}
}
|