diff options
Diffstat (limited to 'Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs')
-rw-r--r-- | Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs new file mode 100644 index 0000000..b9a483e --- /dev/null +++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs @@ -0,0 +1,17 @@ +using UnityEngine.UI; +using UnityEngine.InputSystem; + +namespace UnityEngine.XR.OpenXR.Samples.ControllerSample +{ + public class ActionToAxis : ActionToControl + { + [Tooltip("Slider controlled by the action value")] + [SerializeField] private Slider _slider = null; + + protected override void OnActionPerformed(InputAction.CallbackContext ctx) => UpdateValue(ctx); + protected override void OnActionStarted(InputAction.CallbackContext ctx) => UpdateValue(ctx); + protected override void OnActionCanceled(InputAction.CallbackContext ctx) => UpdateValue(ctx); + + private void UpdateValue(InputAction.CallbackContext ctx) => _slider.value = ctx.ReadValue<float>(); + } +} |