From 5b158af90739dcbb89c1538a6cb8c65a875dce80 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 26 Nov 2020 20:52:34 +0800 Subject: *misc --- .../Editor/StyledInspector/StyledTextDrawer.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs (limited to 'Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs') diff --git a/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs new file mode 100644 index 00000000..3850da2e --- /dev/null +++ b/Assets/BOXOPHOBIC/Utils/Editor/StyledInspector/StyledTextDrawer.cs @@ -0,0 +1,45 @@ +// Cristian Pop - https://boxophobic.com/ + +using UnityEngine; +using UnityEditor; + +namespace Boxophobic.StyledGUI +{ + [CustomPropertyDrawer(typeof(StyledText))] + public class StyledTextAttributeDrawer : PropertyDrawer + { + StyledText a; + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + a = (StyledText)attribute; + + GUIStyle styleLabel = new GUIStyle(EditorStyles.label) + { + richText = true, + wordWrap = true + }; + + styleLabel.alignment = a.alignment; + + GUILayout.Space(a.top); + + if (a.disabled == true) + { + GUI.enabled = false; + } + + GUILayout.Label(property.stringValue, styleLabel); + + GUI.enabled = true; + + GUILayout.Space(a.down); + } + + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) + { + return -2; + } + } +} + -- cgit v1.1-26-g67d0