summaryrefslogtreecommitdiff
path: root/VRCSDK3Avatars/Assets/Resources/GestureManager/Scripts/Editor/Modules/Vrc3/Vrc3WeightController.cs
blob: b3f7d781f402ce713ff90d50878b563aa17f1c21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#if VRC_SDK_VRCSDK3
using GestureManager.Scripts.Core.Editor;
using UnityEngine;
using UnityEngine.UIElements;

namespace GestureManager.Scripts.Editor.Modules.Vrc3
{
    public class Vrc3WeightController
    {
        internal readonly ModuleVrc3 Module;

        private readonly Vrc3WeightSlider _lWeight;
        private readonly Vrc3WeightSlider _rWeight;
        internal bool Dragging => _lWeight.Drag || _rWeight.Drag;
        internal bool Active => _lWeight.Active || _rWeight.Active;

        public Vrc3WeightController(ModuleVrc3 module)
        {
            Module = module;
            _lWeight = new Vrc3WeightSlider(this, Vrc3DefaultParams.GestureLeftWeight);
            _rWeight = new Vrc3WeightSlider(this, Vrc3DefaultParams.GestureRightWeight);
        }

        public void RenderLeft(VisualElement root)
        {
            GUILayoutUtility.GetRect(new GUIContent(), GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(10));
            _lWeight.Render(root, GmgLayoutHelper.GetLastRect(ref _lWeight.Rect));
            _lWeight.ShowWeight();
        }

        public void RenderRight(VisualElement root)
        {
            GUILayoutUtility.GetRect(new GUIContent(), GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(10));
            _rWeight.Render(root, GmgLayoutHelper.GetLastRect(ref _rWeight.Rect));
            _rWeight.ShowWeight();
        }

        public void CheckCondition(ModuleVrc3 module, RadialMenu menu)
        {
            _lWeight.CheckCondition(module, menu);
            _rWeight.CheckCondition(module, menu);
        }

        public void StopRendering()
        {
            _lWeight.StopRendering();
            _rWeight.StopRendering();
        }

        public void DisableDrag()
        {
            _lWeight.Drag = false;
            _rWeight.Drag = false;
        }
    }
}
#endif