AnimationDrawer.cs 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationInfo), true)]
  7. public class AnimationInfoDrawer : BasePropertyDrawer
  8. {
  9. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  10. {
  11. base.OnGUI(pos, prop, label);
  12. if (MakeComponentFoldout(prop, "m_Enable", true))
  13. {
  14. ++EditorGUI.indentLevel;
  15. PropertyField(prop, "m_Delay");
  16. PropertyField(prop, "m_Duration");
  17. --EditorGUI.indentLevel;
  18. }
  19. }
  20. }
  21. [CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationChange), true)]
  22. public class AnimationChangeDrawer : BasePropertyDrawer
  23. {
  24. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  25. {
  26. base.OnGUI(pos, prop, label);
  27. if (MakeComponentFoldout(prop, "m_Enable", true))
  28. {
  29. ++EditorGUI.indentLevel;
  30. PropertyField(prop, "m_Duration");
  31. --EditorGUI.indentLevel;
  32. }
  33. }
  34. }
  35. [CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationAddition), true)]
  36. public class AnimationAdditionDrawer : BasePropertyDrawer
  37. {
  38. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  39. {
  40. base.OnGUI(pos, prop, label);
  41. if (MakeComponentFoldout(prop, "m_Enable", true))
  42. {
  43. ++EditorGUI.indentLevel;
  44. PropertyField(prop, "m_Duration");
  45. --EditorGUI.indentLevel;
  46. }
  47. }
  48. }
  49. [CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationInteraction), true)]
  50. public class AnimationInteractionDrawer : BasePropertyDrawer
  51. {
  52. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  53. {
  54. base.OnGUI(pos, prop, label);
  55. if (MakeComponentFoldout(prop, "m_Enable", true))
  56. {
  57. ++EditorGUI.indentLevel;
  58. PropertyField(prop, "m_Duration");
  59. PropertyField(prop, "m_Width");
  60. PropertyField(prop, "m_Radius");
  61. PropertyField(prop, "m_Offset");
  62. --EditorGUI.indentLevel;
  63. }
  64. }
  65. }
  66. [CustomPropertyDrawer(typeof(AnimationStyle), true)]
  67. public class AnimationDrawer : BasePropertyDrawer
  68. {
  69. public override string ClassName { get { return "Animation"; } }
  70. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  71. {
  72. base.OnGUI(pos, prop, label);
  73. if (MakeComponentFoldout(prop, "m_Enable", true))
  74. {
  75. ++EditorGUI.indentLevel;
  76. PropertyField(prop, "m_Type");
  77. PropertyField(prop, "m_UnscaledTime");
  78. PropertyField(prop, "m_FadeIn");
  79. PropertyField(prop, "m_FadeOut");
  80. PropertyField(prop, "m_Change");
  81. PropertyField(prop, "m_Addition");
  82. PropertyField(prop, "m_Interaction");
  83. --EditorGUI.indentLevel;
  84. }
  85. }
  86. }
  87. }