blob: c2b02d6c7004f1f6030cb31cffe4d447a503d3b1 (
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
|
// Cristian Pop - https://boxophobic.com/
using UnityEngine;
using UnityEditor;
namespace Boxophobic.StyledGUI
{
[CustomPropertyDrawer(typeof(StyledMessage))]
public class StyledMessageAttributeDrawer : PropertyDrawer
{
StyledMessage a;
bool show;
MessageType messageType;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
show = property.boolValue;
if (show)
{
a = (StyledMessage)attribute;
if (a.Type == "None")
{
messageType = MessageType.None;
}
else if (a.Type == "Info")
{
messageType = MessageType.Info;
}
else if (a.Type == "Warning")
{
messageType = MessageType.Warning;
}
else if (a.Type == "Error")
{
messageType = MessageType.Error;
}
GUILayout.Space(a.Top);
EditorGUILayout.HelpBox(a.Message, messageType);
GUILayout.Space(a.Down);
}
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return -2;
}
}
}
|