FloatSliderDrawer.cs 823 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(FloatSliderAttribute))]
  8. public class FloatSliderDrawer : ObjectDrawer
  9. {
  10. public override void OnGUI(GUIContent label)
  11. {
  12. var floatSliderAttribute = (FloatSliderAttribute)attribute;
  13. if (value is SharedFloat) {
  14. var sharedFloat = value as SharedFloat;
  15. sharedFloat.Value = EditorGUILayout.Slider(label, sharedFloat.Value, floatSliderAttribute.min, floatSliderAttribute.max);
  16. } else {
  17. value = EditorGUILayout.Slider(label, (float)value, floatSliderAttribute.min, floatSliderAttribute.max);
  18. }
  19. }
  20. }
  21. }