summaryrefslogtreecommitdiff
path: root/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs')
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs
new file mode 100644
index 0000000..7679092
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Linq;
+using UnityEngine.UI;
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToDeviceInfo : MonoBehaviour
+ {
+ [SerializeField] private InputActionReference _actionReference = null;
+
+ [SerializeField] private Text _text = null;
+
+ private void OnEnable()
+ {
+ UpdateText();
+ }
+
+ private void UpdateText()
+ {
+ if (null == _actionReference || null == _actionReference.action || _actionReference.action.controls.Count == 0 || _text == null)
+ return;
+
+ var device = _actionReference.action.controls[0].device;
+ _text.text = $"{device.name}\n{device.deviceId}\n{string.Join(",", device.usages.Select(u => u.ToString()))}";
+ }
+ }
+}