StyledButtonDrawer.cs 755 B

123456789101112131415161718192021222324252627282930313233
  1. // Cristian Pop - https://boxophobic.com/
  2. using UnityEngine;
  3. using UnityEditor;
  4. namespace Boxophobic.StyledGUI
  5. {
  6. [CustomPropertyDrawer(typeof(StyledButton))]
  7. public class StyledButtonAttributeDrawer : PropertyDrawer
  8. {
  9. StyledButton a;
  10. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  11. {
  12. a = (StyledButton)attribute;
  13. GUILayout.Space(a.Top);
  14. if (GUILayout.Button(a.Text))
  15. {
  16. property.boolValue = true;
  17. }
  18. GUILayout.Space(a.Down);
  19. }
  20. public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
  21. {
  22. return -2;
  23. }
  24. }
  25. }