summaryrefslogtreecommitdiff
path: root/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts
diff options
context:
space:
mode:
authorpryazha <pryadeiniv@mail.ru>2025-07-02 08:46:23 -0700
committerpryazha <pryadeiniv@mail.ru>2025-07-02 08:46:23 -0700
commit8263edd59284aba390aca011d25b79efecef4c48 (patch)
tree6346e2afaaabd32156601cafaf20d4ee813befaf /Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts
Diffstat (limited to 'Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts')
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs23
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs17
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs45
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs87
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs70
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs.meta3
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs28
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs31
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs56
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs21
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs60
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs40
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs42
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs66
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef24
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef.meta7
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs68
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs49
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs.meta11
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs102
-rw-r--r--Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs.meta11
34 files changed, 1004 insertions, 0 deletions
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs
new file mode 100644
index 0000000..0865739
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs
@@ -0,0 +1,23 @@
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionAssetEnabler : MonoBehaviour
+ {
+ [SerializeField]
+ InputActionAsset m_ActionAsset;
+ public InputActionAsset actionAsset
+ {
+ get => m_ActionAsset;
+ set => m_ActionAsset = value;
+ }
+
+ private void OnEnable()
+ {
+ if (m_ActionAsset != null)
+ {
+ m_ActionAsset.Enable();
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs.meta
new file mode 100644
index 0000000..486ca22
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionAssetEnabler.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b90eaae8ee7f6bf46be1c8ad060bd48d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
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>();
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs.meta
new file mode 100644
index 0000000..ed6fa4f
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToAxis.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 38137e6c2a95274448387b2203e288e2
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs
new file mode 100644
index 0000000..f537800
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections;
+using UnityEngine.InputSystem;
+using UnityEngine.UI;
+using UnityEngine.XR.Management;
+using UnityEngine.XR.OpenXR.Input;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToButton : ActionToControl
+ {
+ [SerializeField] private Image _image = null;
+
+ [SerializeField] private Color _normalColor = Color.red;
+
+ [SerializeField] private Color _pressedColor = Color.green;
+
+ private void Awake()
+ {
+ if (_image != null)
+ {
+ _image.enabled = false;
+ _image.color = _normalColor;
+ }
+ }
+
+ protected override void OnActionStarted(InputAction.CallbackContext ctx)
+ {
+ if (_image != null)
+ _image.color = _pressedColor;
+ }
+
+ protected override void OnActionCanceled(InputAction.CallbackContext ctx)
+ {
+ if (_image != null)
+ _image.color = _normalColor;
+ }
+
+ protected override void OnActionBound()
+ {
+ if (_image != null)
+ _image.enabled = true;
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs.meta
new file mode 100644
index 0000000..ba0284c
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButton.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9d563bef222bbc74ab2244cbbd138dfe
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs
new file mode 100644
index 0000000..5860af3
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs
@@ -0,0 +1,87 @@
+using System;
+using UnityEngine.InputSystem;
+using UnityEngine.UI;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToButtonISX : MonoBehaviour
+ {
+ [SerializeField]
+ private InputActionReference m_ActionReference;
+ public InputActionReference actionReference { get => m_ActionReference; set => m_ActionReference = value; }
+
+ [SerializeField]
+ Color enabledColor = Color.green;
+
+ [SerializeField]
+ Color disabledColor = Color.red;
+
+ [SerializeField]
+ Image image = null;
+
+ Graphic graphic = null;
+ Graphic[] graphics = new Graphic[] { };
+
+ private void OnEnable()
+ {
+ if (image == null)
+ Debug.LogWarning("ActionToButton Monobehaviour started without any associated image. This input will not be reported.", this);
+
+ graphic = gameObject.GetComponent<Graphic>();
+ graphics = gameObject.GetComponentsInChildren<Graphic>();
+ }
+
+ Type lastActiveType = null;
+
+ void Update()
+ {
+ if (actionReference != null && actionReference.action != null && image != null && actionReference.action.enabled && actionReference.action.controls.Count > 0)
+ {
+ SetVisible(true);
+
+ Type typeToUse = null;
+
+ if (actionReference.action.activeControl != null)
+ {
+ typeToUse = actionReference.action.activeControl.valueType;
+ }
+ else
+ {
+ typeToUse = lastActiveType;
+ }
+
+ if (typeToUse == typeof(bool))
+ {
+ lastActiveType = typeof(bool);
+ bool value = actionReference.action.ReadValue<bool>();
+ image.color = value ? enabledColor : disabledColor;
+ }
+ else if (typeToUse == typeof(float))
+ {
+ lastActiveType = typeof(float);
+ float value = actionReference.action.ReadValue<float>();
+ image.color = value > 0.5 ? enabledColor : disabledColor;
+ }
+ else
+ {
+ image.color = disabledColor;
+ }
+ }
+ else
+ {
+ SetVisible(false);
+ }
+ }
+
+ void SetVisible(bool visible)
+ {
+ if (graphic != null)
+ graphic.enabled = visible;
+
+ for (int i = 0; i < graphics.Length; i++)
+ {
+ graphics[i].enabled = visible;
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs.meta
new file mode 100644
index 0000000..14e0430
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToButtonISX.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 576c44685553a8b4c8ef9ed81b0d703c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs
new file mode 100644
index 0000000..fa87578
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs
@@ -0,0 +1,70 @@
+using System.Collections;
+using UnityEngine.InputSystem;
+using UnityEngine.UI;
+using UnityEngine.XR.OpenXR.Input;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToControl : MonoBehaviour
+ {
+ [Tooltip("Action Reference that represents the control")]
+ [SerializeField] private InputActionReference _actionReference = null;
+
+ [Tooltip("Optional text element that will be set to the name of the action")]
+ [SerializeField] private Text _text = null;
+
+ protected virtual void OnEnable()
+ {
+ if (_actionReference == null || _actionReference.action == null)
+ return;
+
+ _actionReference.action.started += OnActionStarted;
+ _actionReference.action.performed += OnActionPerformed;
+ _actionReference.action.canceled += OnActionCanceled;
+
+ StartCoroutine(UpdateBinding());
+ }
+
+ protected virtual void OnDisable()
+ {
+ if (_actionReference == null || _actionReference.action == null)
+ return;
+
+ _actionReference.action.started -= OnActionStarted;
+ _actionReference.action.performed -= OnActionPerformed;
+ _actionReference.action.canceled -= OnActionCanceled;
+ }
+
+ private IEnumerator UpdateBinding()
+ {
+ if (null != _text)
+ _text.text = _actionReference.action.name;
+
+ while (isActiveAndEnabled)
+ {
+ if (_actionReference.action != null &&
+ _actionReference.action.controls.Count > 0 &&
+ _actionReference.action.controls[0].device != null &&
+ OpenXRInput.TryGetInputSourceName(_actionReference.action, 0, out var actionName, OpenXRInput.InputSourceNameFlags.Component, _actionReference.action.controls[0].device))
+ {
+ if (null != _text && !string.IsNullOrEmpty(actionName))
+ _text.text = actionName;
+ OnActionBound();
+ break;
+ }
+
+ yield return new WaitForSeconds(1.0f);
+ }
+ }
+
+ protected virtual void OnActionStarted(InputAction.CallbackContext ctx) { }
+
+ protected virtual void OnActionPerformed(InputAction.CallbackContext ctx) { }
+
+ protected virtual void OnActionCanceled(InputAction.CallbackContext ctx) { }
+
+ protected virtual void OnActionBound()
+ {
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs.meta
new file mode 100644
index 0000000..e4c084b
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToControl.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 646a6a8731544edd90500029f44f456c
+timeCreated: 1618941418 \ No newline at end of file
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()))}";
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs.meta
new file mode 100644
index 0000000..9cfc6aa
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToDeviceInfo.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 20e49cce4b183e449a86a4daa814f3a6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs
new file mode 100644
index 0000000..df0c95d
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs
@@ -0,0 +1,31 @@
+using UnityEngine.InputSystem;
+using UnityEngine.XR.OpenXR.Input;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToHaptics : MonoBehaviour
+ {
+ public InputActionReference action;
+ public InputActionReference hapticAction;
+ public float _amplitude = 1.0f;
+ public float _duration = 0.1f;
+ public float _frequency = 0.0f;
+
+ private void Start()
+ {
+ if (action == null || hapticAction == null)
+ return;
+
+ action.action.Enable();
+ hapticAction.action.Enable();
+ action.action.performed += (ctx) =>
+ {
+ var control = action.action.activeControl;
+ if (null == control)
+ return;
+
+ OpenXRInput.SendHapticImpulse(hapticAction.action, _amplitude, _frequency, _duration, control.device);
+ };
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs.meta
new file mode 100644
index 0000000..25236db
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToHaptics.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 63da2ac4abc1dc64594aa5c751083a11
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs
new file mode 100644
index 0000000..02a1e88
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs
@@ -0,0 +1,56 @@
+using UnityEngine.UI;
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToSliderISX : MonoBehaviour
+ {
+ [SerializeField]
+ private InputActionReference m_ActionReference;
+ public InputActionReference actionReference { get => m_ActionReference; set => m_ActionReference = value; }
+
+ [SerializeField]
+ Slider slider = null;
+
+ Graphic graphic = null;
+ Graphic[] graphics = new Graphic[] { };
+
+ private void OnEnable()
+ {
+ if (slider == null)
+ Debug.LogWarning("ActionToSlider Monobehaviour started without any associated slider. This input will not be reported.", this);
+
+ graphic = gameObject.GetComponent<Graphic>();
+ graphics = gameObject.GetComponentsInChildren<Graphic>();
+ }
+
+ void Update()
+ {
+ if (actionReference != null && actionReference.action != null && slider != null)
+ {
+ if (actionReference.action.enabled)
+ {
+ SetVisible(true);
+ }
+
+ float value = actionReference.action.ReadValue<float>();
+ slider.value = value;
+ }
+ else
+ {
+ SetVisible(false);
+ }
+ }
+
+ void SetVisible(bool visible)
+ {
+ if (graphic != null)
+ graphic.enabled = visible;
+
+ for (int i = 0; i < graphics.Length; i++)
+ {
+ graphics[i].enabled = visible;
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs.meta
new file mode 100644
index 0000000..e6986dd
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToSliderISX.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 790e565304cffa1459a059a3f83619fc
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs
new file mode 100644
index 0000000..cb7e274
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs
@@ -0,0 +1,21 @@
+using UnityEngine.UI;
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToVector2 : ActionToControl
+ {
+ [SerializeField] public RectTransform _handle = null;
+
+ protected override void OnActionPerformed(InputAction.CallbackContext ctx) => UpdateHandle(ctx);
+
+ protected override void OnActionStarted(InputAction.CallbackContext ctx) => UpdateHandle(ctx);
+
+ protected override void OnActionCanceled(InputAction.CallbackContext ctx) => UpdateHandle(ctx);
+
+ private void UpdateHandle(InputAction.CallbackContext ctx)
+ {
+ _handle.anchorMin = _handle.anchorMax = (ctx.ReadValue<Vector2>() + Vector2.one) * 0.5f;
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs.meta
new file mode 100644
index 0000000..a56f5e3
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fafe7132773ee4c459df58c5ef9bba92
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs
new file mode 100644
index 0000000..60fce5b
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs
@@ -0,0 +1,60 @@
+using UnityEngine.UI;
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToVector2SliderISX : MonoBehaviour
+ {
+ [SerializeField]
+ private InputActionReference m_ActionReference;
+ public InputActionReference actionReference { get => m_ActionReference; set => m_ActionReference = value; }
+
+ [SerializeField]
+ public Slider xAxisSlider = null;
+
+ [SerializeField]
+ public Slider yAxisSlider = null;
+
+
+ private void OnEnable()
+ {
+ if (xAxisSlider == null)
+ Debug.LogWarning("ActionToSlider Monobehaviour started without any associated X-axis slider. This input won't be reported.", this);
+
+ if (yAxisSlider == null)
+ Debug.LogWarning("ActionToSlider Monobehaviour started without any associated Y-axis slider. This input won't be reported.", this);
+ }
+
+ void Update()
+ {
+ if (actionReference != null && actionReference.action != null && xAxisSlider != null && yAxisSlider != null)
+ {
+ if (actionReference.action.enabled)
+ {
+ SetVisible(gameObject, true);
+ }
+
+ Vector2 value = actionReference.action.ReadValue<Vector2>();
+ xAxisSlider.value = value.x;
+ yAxisSlider.value = value.y;
+ }
+ else
+ {
+ SetVisible(gameObject, false);
+ }
+ }
+
+ void SetVisible(GameObject go, bool visible)
+ {
+ Graphic graphic = go.GetComponent<Graphic>();
+ if (graphic != null)
+ graphic.enabled = visible;
+
+ Graphic[] graphics = go.GetComponentsInChildren<Graphic>();
+ for (int i = 0; i < graphics.Length; i++)
+ {
+ graphics[i].enabled = visible;
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs.meta
new file mode 100644
index 0000000..3fa07c5
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVector2SliderISX.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 080f821afb95c994fb2e1988766beedf
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs
new file mode 100644
index 0000000..b178975
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs
@@ -0,0 +1,40 @@
+using System.Collections;
+using UnityEngine.InputSystem;
+using UnityEngine.XR.OpenXR.Input;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToVisibility : MonoBehaviour
+ {
+ [SerializeField] private InputActionReference _actionReference = null;
+
+ [SerializeField] private GameObject _target = null;
+
+ private void OnEnable()
+ {
+ if (null == _target)
+ _target = gameObject;
+
+ _target.SetActive(false);
+
+ if (_actionReference != null && _actionReference.action != null)
+ StartCoroutine(UpdateVisibility());
+ }
+
+ private IEnumerator UpdateVisibility()
+ {
+ while (isActiveAndEnabled)
+ {
+ if (_actionReference.action != null &&
+ _actionReference.action.controls.Count > 0 &&
+ _actionReference.action.controls[0].device != null &&
+ OpenXRInput.TryGetInputSourceName(_actionReference.action, 0, out var actionName, OpenXRInput.InputSourceNameFlags.Component, _actionReference.action.controls[0].device))
+ {
+ _target.SetActive(true);
+ break;
+ }
+ yield return new WaitForSeconds(1.0f);
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs.meta
new file mode 100644
index 0000000..832f692
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibility.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 00af11ffcda1ca346ba8d727adb83ec8
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs
new file mode 100644
index 0000000..ab8d7ae
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs
@@ -0,0 +1,42 @@
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class ActionToVisibilityISX : MonoBehaviour
+ {
+ [SerializeField]
+ InputActionProperty m_ActionReference;
+ public InputActionProperty actionReference { get => m_ActionReference; set => m_ActionReference = value; }
+
+
+ [SerializeField]
+ GameObject m_TargetGameobject = null;
+ public GameObject targetGameObject { get => m_TargetGameobject; set => m_TargetGameobject = value; }
+
+ private void Start()
+ {
+ if (m_ActionReference != null && m_ActionReference.action != null)
+ m_ActionReference.action.Enable();
+ }
+
+ void Update()
+ {
+ if (m_TargetGameobject == null)
+ return;
+
+ if (m_ActionReference != null
+ && m_ActionReference.action != null
+ && m_ActionReference.action.controls.Count > 0
+ && m_ActionReference.action.enabled == true)
+ {
+ m_TargetGameobject.SetActive(true);
+ return;
+ }
+ else
+ {
+ // No Matching devices:
+ m_TargetGameobject.SetActive(false);
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs.meta
new file mode 100644
index 0000000..0f1bcbe
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: edf1613ec3545e1498d0788f3dd81107
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs
new file mode 100644
index 0000000..7605a2d
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class AutomaticTrackingModeChanger : MonoBehaviour
+ {
+ [SerializeField]
+ float m_ChangeInterval = 5.0f;
+
+ private float m_TimeRemainingTillChange;
+
+ static List<XRInputSubsystem> s_InputSubsystems = new List<XRInputSubsystem>();
+ static List<TrackingOriginModeFlags> s_SupportedTrackingOriginModes = new List<TrackingOriginModeFlags>();
+
+ void OnEnable()
+ {
+ m_TimeRemainingTillChange = m_ChangeInterval;
+ }
+
+ void Update()
+ {
+ m_TimeRemainingTillChange -= Time.deltaTime;
+ if (m_TimeRemainingTillChange <= 0.0f)
+ {
+ List<XRInputSubsystem> inputSubsystems = new List<XRInputSubsystem>();
+ SubsystemManager.GetSubsystems(inputSubsystems);
+ XRInputSubsystem subsystem = inputSubsystems?[0];
+ if (subsystem != null)
+ {
+ UpdateSupportedTrackingOriginModes(subsystem);
+ SetToNextMode(subsystem);
+ }
+ m_TimeRemainingTillChange += m_ChangeInterval;
+ }
+ }
+
+ void UpdateSupportedTrackingOriginModes(XRInputSubsystem subsystem)
+ {
+ TrackingOriginModeFlags supportedOriginModes = subsystem.GetSupportedTrackingOriginModes();
+ s_SupportedTrackingOriginModes.Clear();
+ for (int i = 0; i < 31; i++)
+ {
+ uint modeToCheck = 1u << i;
+ if ((modeToCheck & ((UInt32)supportedOriginModes)) != 0)
+ {
+ s_SupportedTrackingOriginModes.Add((TrackingOriginModeFlags)modeToCheck);
+ }
+ }
+ }
+
+ void SetToNextMode(XRInputSubsystem subsystem)
+ {
+ TrackingOriginModeFlags currentOriginMode = subsystem.GetTrackingOriginMode();
+ for (int i = 0; i < s_SupportedTrackingOriginModes.Count; i++)
+ {
+ if (currentOriginMode == s_SupportedTrackingOriginModes[i])
+ {
+ int nextModeIndex = (i + 1) % s_SupportedTrackingOriginModes.Count;
+ subsystem.TrySetTrackingOriginMode(s_SupportedTrackingOriginModes[nextModeIndex]);
+ break;
+ }
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs.meta
new file mode 100644
index 0000000..367c1da
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/AutomaticTrackingModeChanger.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d3724322d23523e42aad1efb9735340e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef
new file mode 100644
index 0000000..bebdf53
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef
@@ -0,0 +1,24 @@
+{
+ "name": "ControllerSample",
+ "references": [
+ "GUID:4847341ff46394e83bb78fbd0652937e",
+ "GUID:75469ad4d38634e559750d17036d5f7c",
+ "GUID:ba171b3dd2a51234ab864770f99741a5",
+ "GUID:e40ba710768534012815d3193fa296cb"
+ ],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [
+ {
+ "name": "com.unity.inputsystem",
+ "expression": "",
+ "define": "UNITY_INPUT_SYSTEM"
+ }
+ ],
+ "noEngineReferences": false
+} \ No newline at end of file
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef.meta
new file mode 100644
index 0000000..d43c304
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ControllerSample.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: bf832b71721410545bfdee57a474f71c
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs
new file mode 100644
index 0000000..606d244
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs
@@ -0,0 +1,68 @@
+using UnityEngine.UI;
+using UnityEngine.InputSystem;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class DisplayDeviceInfoFromActionISX : MonoBehaviour
+ {
+ [SerializeField]
+ InputActionProperty m_Property;
+ public InputActionProperty property { get => m_Property; set => m_Property = value; }
+
+ [SerializeField]
+ GameObject m_RootObject = null;
+ public GameObject rootObject { get { return m_RootObject; } set { m_RootObject = value; } }
+
+ [SerializeField]
+ Text m_TargetText;
+ public Text targetText { get { return m_TargetText; } set { m_TargetText = value; } }
+
+ void OnEnable()
+ {
+ if (targetText == null)
+ Debug.LogWarning("DisplayDeviceInfo Monobehaviour has no Target Text set. No information will be displayed.");
+ }
+
+ void Update()
+ {
+ if (m_Property != null && m_Property.action != null && m_Property.action.controls.Count > 0)
+ {
+ if (m_RootObject != null)
+ m_RootObject.SetActive(true);
+
+
+ var device = m_Property.action.controls[0].device;
+ if (targetText != null)
+ {
+ m_TargetText.text = $"{device.name}\n{device.deviceId}\n";
+ bool useComma = false;
+ foreach (var usg in device.usages)
+ {
+ if (!useComma)
+ {
+ useComma = true;
+ m_TargetText.text += $"{usg}";
+ }
+ else
+ {
+ m_TargetText.text += $"{usg},";
+ }
+ }
+
+ if (m_TargetText.text.Length > 30)
+ m_TargetText.text = m_TargetText.text.Substring(0, 30);
+ }
+ return;
+ }
+ else
+ {
+ if (m_RootObject != null)
+ m_RootObject.SetActive(false);
+
+ // No Matching devices:
+ if (m_TargetText != null)
+ m_TargetText.text = "<No Device Connected>";
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs.meta
new file mode 100644
index 0000000..89381ce
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/DisplayDeviceInfoFromActionISX.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4d377864210d87a4a9d98b7dee9ab5b1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs
new file mode 100644
index 0000000..e5cad59
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs
@@ -0,0 +1,49 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.XR;
+using UnityEngine.XR.OpenXR.Input;
+using UnityEngine.InputSystem;
+
+/// <summary>
+/// Example code for Vulkan Late latching support. For use cases example, please check out Controller Sample - Head object, LeftHand/Aim object and RightHand/Grip object.
+/// See: https://docs.unity3d.com/ScriptReference/XR.XRDisplaySubsystem.MarkTransformLateLatched.html
+/// </summary>
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class MarkLateLatchNode : MonoBehaviour
+ {
+ private XRDisplaySubsystem m_DisplaySubsystem = null;
+ public UnityEngine.XR.XRDisplaySubsystem.LateLatchNode lateLatchNode;
+ //Set one pose type InputAction for each hand to be late latched - e.g.: Aim or Grip. For head node, leave it unset.
+ [SerializeField] private InputActionReference _ActionReference = null;
+
+ // Start is called before the first frame update
+ void Start()
+ {
+ List<XRDisplaySubsystem> subsys = new List<XRDisplaySubsystem>();
+ SubsystemManager.GetSubsystems<XRDisplaySubsystem>(subsys);
+
+ if (subsys.Count >= 1)
+ m_DisplaySubsystem = subsys[0];
+ if (_ActionReference != null)
+ {
+ bool result = OpenXRInput.TrySetControllerLateLatchAction(_ActionReference.action);
+ Debug.LogFormat("TrySetControllerLateLatchAction returns {0} for action {1}.", result, _ActionReference);
+ }
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+ if (m_DisplaySubsystem != null)
+ {
+ transform.position += new Vector3(0.00001f, 0, 0);
+ Quaternion rot = transform.rotation;
+ rot.x += 0.00001f;
+ transform.rotation = rot;
+ m_DisplaySubsystem.MarkTransformLateLatched(transform, lateLatchNode);
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs.meta
new file mode 100644
index 0000000..adcea92
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/MarkLateLatchNode.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1cc7f7343d6e839448320ad3382947b6
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs
new file mode 100644
index 0000000..d72c0c5
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs
@@ -0,0 +1,102 @@
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+using UnityEngine.XR;
+
+namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
+{
+ public class TrackingModeOrigin : MonoBehaviour
+ {
+ [SerializeField]
+ Image m_RecenteredImage = null;
+
+ [SerializeField]
+ Color m_RecenteredOffColor = Color.red;
+
+ [SerializeField]
+ Color m_RecenteredColor = Color.green;
+
+ [SerializeField]
+ float m_RecenteredColorResetTime = 1.0f;
+
+ float m_LastRecenteredTime = 0.0f;
+
+ [SerializeField]
+ TrackingOriginModeFlags m_CurrentTrackingOriginMode;
+ public TrackingOriginModeFlags currentTrackingOriginMode { get { return m_CurrentTrackingOriginMode; } }
+
+ [SerializeField]
+ Text m_CurrentTrackingOriginModeDisplay = null;
+
+ [SerializeField]
+ TrackingOriginModeFlags m_DesiredTrackingOriginMode;
+ public TrackingOriginModeFlags desiredTrackingOriginMode { get { return m_DesiredTrackingOriginMode; } set { m_DesiredTrackingOriginMode = value; } }
+
+ [SerializeField]
+ TrackingOriginModeFlags m_SupportedTrackingOriginModes;
+ public TrackingOriginModeFlags supportedTrackingOriginModes { get { return m_SupportedTrackingOriginModes; } }
+
+ static List<XRInputSubsystem> s_InputSubsystems = new List<XRInputSubsystem>();
+
+ private void OnEnable()
+ {
+ SubsystemManager.GetSubsystems(s_InputSubsystems);
+ for (int i = 0; i < s_InputSubsystems.Count; i++)
+ {
+ s_InputSubsystems[i].trackingOriginUpdated += TrackingOriginUpdated;
+ }
+
+#if !ENABLE_INPUT_SYSTEM
+ Debug.LogWarning("This sample is not expected to work without the Input System backend enabled (Project Settings > Player > Other Settings > Configuration > Active Input Handling).");
+#endif
+ }
+
+ private void OnDisable()
+ {
+ SubsystemManager.GetSubsystems(s_InputSubsystems);
+ for (int i = 0; i < s_InputSubsystems.Count; i++)
+ {
+ s_InputSubsystems[i].trackingOriginUpdated -= TrackingOriginUpdated;
+ }
+ }
+
+ public void OnDesiredSelectionChanged(int newValue)
+ {
+ desiredTrackingOriginMode = (TrackingOriginModeFlags)(newValue == 0 ? 0 : (1 << (newValue - 1)));
+ }
+
+ private void TrackingOriginUpdated(XRInputSubsystem obj)
+ {
+ m_LastRecenteredTime = Time.time;
+ }
+
+ void Update()
+ {
+ XRInputSubsystem subsystem = null;
+
+ SubsystemManager.GetSubsystems(s_InputSubsystems);
+ if (s_InputSubsystems.Count > 0)
+ {
+ subsystem = s_InputSubsystems[0];
+ }
+
+ m_SupportedTrackingOriginModes = subsystem?.GetSupportedTrackingOriginModes() ?? TrackingOriginModeFlags.Unknown;
+
+ if (m_CurrentTrackingOriginMode != m_DesiredTrackingOriginMode & m_DesiredTrackingOriginMode != TrackingOriginModeFlags.Unknown)
+ {
+ subsystem?.TrySetTrackingOriginMode(m_DesiredTrackingOriginMode);
+ }
+ m_CurrentTrackingOriginMode = subsystem?.GetTrackingOriginMode() ?? TrackingOriginModeFlags.Unknown;
+
+ if (m_CurrentTrackingOriginModeDisplay != null)
+ m_CurrentTrackingOriginModeDisplay.text = m_CurrentTrackingOriginMode.ToString();
+
+ if (m_RecenteredImage != null)
+ {
+ float lerp = (Time.time - m_LastRecenteredTime) / m_RecenteredColorResetTime;
+ lerp = Mathf.Clamp(lerp, 0.0f, 1.0f);
+ m_RecenteredImage.color = Color.Lerp(m_RecenteredColor, m_RecenteredOffColor, lerp);
+ }
+ }
+ }
+}
diff --git a/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs.meta b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs.meta
new file mode 100644
index 0000000..1310fec
--- /dev/null
+++ b/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/TrackingModeOrigin.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 60d238e9c86f8bb42b9eb88baeed50b0
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: