MLValueDrawer.cs 1004 B

123456789101112131415161718192021222324252627
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [CustomPropertyDrawer(typeof(MLValue), true)]
  7. public class MLValueDrawer : BasePropertyDrawer
  8. {
  9. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  10. {
  11. Rect drawRect = pos;
  12. drawRect.height = EditorGUIUtility.singleLineHeight;
  13. SerializedProperty m_Percent = prop.FindPropertyRelative("m_Type");
  14. SerializedProperty m_Color = prop.FindPropertyRelative("m_Value");
  15. ChartEditorHelper.MakeTwoField(ref drawRect, drawRect.width, m_Percent, m_Color, prop.displayName);
  16. drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
  17. }
  18. public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
  19. {
  20. return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
  21. }
  22. }
  23. }