StyledTextDrawer.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. namespace Boxophobic.StyledGUI
  5. {
  6. [CustomPropertyDrawer(typeof(StyledText))]
  7. public class StyledTextAttributeDrawer : PropertyDrawer
  8. {
  9. StyledText a;
  10. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  11. {
  12. a = (StyledText)attribute;
  13. GUIStyle styleLabel = new GUIStyle(EditorStyles.label)
  14. {
  15. richText = true,
  16. wordWrap = true
  17. };
  18. styleLabel.alignment = a.alignment;
  19. GUILayout.Space(a.top);
  20. if (a.disabled == true)
  21. {
  22. GUI.enabled = false;
  23. }
  24. GUILayout.Label(property.stringValue, styleLabel);
  25. GUI.enabled = true;
  26. GUILayout.Space(a.down);
  27. }
  28. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  29. {
  30. return -2;
  31. }
  32. }
  33. }