summaryrefslogtreecommitdiff
path: root/Client/Assets/Behavior Designer/Editor/Object Drawers/FloatSliderDrawer.cs
blob: ada9607b300547da1c27db596d080b5ceb59109f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using UnityEngine;
using UnityEditor;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.ObjectDrawers;

namespace BehaviorDesigner.Editor.ObjectDrawers
{
    [CustomObjectDrawer(typeof(FloatSliderAttribute))]
    public class FloatSliderDrawer : ObjectDrawer
    {
        public override void OnGUI(GUIContent label)
        {
            var floatSliderAttribute = (FloatSliderAttribute)attribute;
            if (value is SharedFloat) {
                var sharedFloat = value as SharedFloat;
                sharedFloat.Value = EditorGUILayout.Slider(label, sharedFloat.Value, floatSliderAttribute.min, floatSliderAttribute.max);
            } else {
                value = EditorGUILayout.Slider(label, (float)value, floatSliderAttribute.min, floatSliderAttribute.max);
            }
        }
    }
}