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/StyledInspector/StyledMessageDrawer.cs | |
parent | bc4d5201fc537f70cdcb576b57aaeb5d96527112 (diff) |
*misc
Diffstat (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs')
-rw-r--r-- | Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs new file mode 100644 index 00000000..c2b02d6c --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledMessageDrawer.cs @@ -0,0 +1,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;
+ }
+ }
+}
|