diff --git a/Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs b/Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs index 862365f9..dd24faa4 100644 --- a/Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs +++ b/Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs @@ -2,6 +2,8 @@ using Unity.XR.CoreUtils.Bindings; using Unity.XR.CoreUtils.Bindings.Variables; using UnityEngine.Assertions; +#endif +#if HAS_XR_INTERACTION_TOOLKIT using UnityEngine.XR.Interaction.Toolkit.Inputs; using UnityEngine.XR.Interaction.Toolkit.Utilities; using UnityEngine.XR.Interaction.Toolkit.Utilities.Tweenables.Primitives; @@ -28,7 +30,7 @@ namespace WebXR.InputSystem /// public class HandMenu : MonoBehaviour { -#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER +#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER && HAS_XR_INTERACTION_TOOLKIT /// /// Enum dictating the up direction used in hand menu calculations. /// diff --git a/Packages/webxr-interactions/Runtime/InputSystem/WebXR.InputSystem.asmdef b/Packages/webxr-interactions/Runtime/InputSystem/WebXR.InputSystem.asmdef index 2186f3b2..bcb64b8a 100644 --- a/Packages/webxr-interactions/Runtime/InputSystem/WebXR.InputSystem.asmdef +++ b/Packages/webxr-interactions/Runtime/InputSystem/WebXR.InputSystem.asmdef @@ -42,6 +42,11 @@ "name": "Unity", "expression": "2022.3", "define": "HAS_POSITION_AND_ROTATION" + }, + { + "name": "com.unity.xr.interaction.toolkit", + "expression": "2.5.2", + "define": "HAS_XR_INTERACTION_TOOLKIT" } ], "noEngineReferences": false diff --git a/Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs b/Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs index 550bc5bd..eefa5e44 100644 --- a/Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs +++ b/Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs @@ -4,7 +4,8 @@ #if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; -using UnityEngine.XR.Hands; +#endif +#if HAS_XR_INTERACTION_TOOLKIT using UnityEngine.XR.Interaction.Toolkit; #endif #if WEBXR_INPUT_PROFILES @@ -132,10 +133,10 @@ public UpdateType updateType [SerializeField] private GameObject rigOrigin; - [SerializeField] private Handedness hand; - + [SerializeField] private WebXRControllerHand hand; +#if HAS_XR_INTERACTION_TOOLKIT [SerializeField] private XRBaseController xrController; - +#endif [SerializeField] private InputActionProperty positionActionProperty; [SerializeField] private InputActionProperty rotationActionProperty; [SerializeField] private InputActionProperty trackingStateActionProperty; @@ -402,10 +403,10 @@ protected void OnEnable() m_IsFirstUpdate = true; switch (hand) { - case Handedness.Left: + case WebXRControllerHand.LEFT: WebXRInputSystem.OnLeftControllerProfiles += HandleOnControllerProfiles; break; - case Handedness.Right: + case WebXRControllerHand.RIGHT: WebXRInputSystem.OnRightControllerProfiles += HandleOnControllerProfiles; break; } @@ -421,18 +422,20 @@ protected void OnDisable() InputSystem.onAfterUpdate -= UpdateCallback; switch (hand) { - case Handedness.Left: + case WebXRControllerHand.LEFT: WebXRInputSystem.OnLeftControllerProfiles -= HandleOnControllerProfiles; break; - case Handedness.Right: + case WebXRControllerHand.RIGHT: WebXRInputSystem.OnRightControllerProfiles -= HandleOnControllerProfiles; break; } +#if HAS_XR_INTERACTION_TOOLKIT if (xrController != null && xrControllerOldModel != null) { xrController.model = xrControllerOldModel; xrController.hideControllerModel = false; } +#endif } /// @@ -597,10 +600,10 @@ public void HandleOnControllerProfiles() string[] profiles = null; switch (hand) { - case Handedness.Left: + case WebXRControllerHand.LEFT: profiles = WebXRInputSystem.GetLeftProfiles(); break; - case Handedness.Right: + case WebXRControllerHand.RIGHT: profiles = WebXRInputSystem.GetRightProfiles(); break; } @@ -650,13 +653,14 @@ private void HandleModelLoaded(bool success) inputProfileModelTransform.localPosition = Vector3.zero; inputProfileModelTransform.localRotation = Quaternion.identity; inputProfileModelTransform.localScale = Vector3.one; +#if HAS_XR_INTERACTION_TOOLKIT if (xrController != null && xrController.model != null) { xrControllerOldModel = xrController.model; xrController.hideControllerModel = true; xrController.model = null; } - +#endif if (m_CurrentTrackingState == TrackingStates.None) { inputProfileModel.gameObject.SetActive(false); diff --git a/Packages/webxr-interactions/Samples~/XRInteractionToolkit/Scenes/WebXRInteractionToolkit.unity b/Packages/webxr-interactions/Samples~/XRInteractionToolkit/Scenes/WebXRInteractionToolkit.unity index 18df67b2..89a637ed 100644 --- a/Packages/webxr-interactions/Samples~/XRInteractionToolkit/Scenes/WebXRInteractionToolkit.unity +++ b/Packages/webxr-interactions/Samples~/XRInteractionToolkit/Scenes/WebXRInteractionToolkit.unity @@ -14907,6 +14907,21 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 7403072356979171074, guid: ed5fdb8d3e523e94ca6d8a239d40615a, + type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7403072356979171076, guid: ed5fdb8d3e523e94ca6d8a239d40615a, + type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7403072356979171077, guid: ed5fdb8d3e523e94ca6d8a239d40615a, + type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} - target: {fileID: 7403072357328242341, guid: ed5fdb8d3e523e94ca6d8a239d40615a, type: 3} propertyPath: m_Camera