AnimationTriggersDrawer.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. namespace UnityEditor.UI
  4. {
  5. [CustomPropertyDrawer(typeof(AnimationTriggers), true)]
  6. /// <summary>
  7. /// This is a PropertyDrawer for AnimationTriggers. It is implemented using the standard Unity PropertyDrawer framework.
  8. /// </summary>
  9. public class AnimationTriggersDrawer : PropertyDrawer
  10. {
  11. public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
  12. {
  13. Rect drawRect = rect;
  14. drawRect.height = EditorGUIUtility.singleLineHeight;
  15. SerializedProperty normalTrigger = prop.FindPropertyRelative("m_NormalTrigger");
  16. SerializedProperty higlightedTrigger = prop.FindPropertyRelative("m_HighlightedTrigger");
  17. SerializedProperty pressedTrigger = prop.FindPropertyRelative("m_PressedTrigger");
  18. SerializedProperty selectedTrigger = prop.FindPropertyRelative("m_SelectedTrigger");
  19. SerializedProperty disabledTrigger = prop.FindPropertyRelative("m_DisabledTrigger");
  20. EditorGUI.PropertyField(drawRect, normalTrigger);
  21. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  22. EditorGUI.PropertyField(drawRect, higlightedTrigger);
  23. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  24. EditorGUI.PropertyField(drawRect, pressedTrigger);
  25. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  26. EditorGUI.PropertyField(drawRect, selectedTrigger);
  27. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  28. EditorGUI.PropertyField(drawRect, disabledTrigger);
  29. }
  30. public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
  31. {
  32. return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
  33. }
  34. }
  35. }