IntSliderDrawer.cs 807 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. using UnityEditor;
  3. using BehaviorDesigner.Runtime;
  4. using BehaviorDesigner.Runtime.ObjectDrawers;
  5. namespace BehaviorDesigner.Editor.ObjectDrawers
  6. {
  7. [CustomObjectDrawer(typeof(IntSliderAttribute))]
  8. public class IntSliderDrawer : ObjectDrawer
  9. {
  10. public override void OnGUI(GUIContent label)
  11. {
  12. var intSliderAttribute = (IntSliderAttribute)attribute;
  13. if (value is SharedInt) {
  14. var sharedFloat = value as SharedInt;
  15. sharedFloat.Value = EditorGUILayout.IntSlider(label, sharedFloat.Value, intSliderAttribute.min, intSliderAttribute.max);
  16. } else {
  17. value = EditorGUILayout.IntSlider(label, (int)value, intSliderAttribute.min, intSliderAttribute.max);
  18. }
  19. }
  20. }
  21. }