From 8263edd59284aba390aca011d25b79efecef4c48 Mon Sep 17 00:00:00 2001 From: pryazha Date: Wed, 2 Jul 2025 08:46:23 -0700 Subject: init --- .../1.14.3/Controller/Scripts/ActionToAxis.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs (limited to 'Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs') 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(); + } +} -- cgit v1.2.3-70-g09d2