Skip to content

Commit 5d870e0

Browse files
authored
Merge pull request #323 from De-Panther/fix_inputsystem_errors
Fix errors when not implementing all the required packages for XRI
2 parents 69624a9 + 341888d commit 5d870e0

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using Unity.XR.CoreUtils.Bindings;
33
using Unity.XR.CoreUtils.Bindings.Variables;
44
using UnityEngine.Assertions;
5+
#endif
6+
#if HAS_XR_INTERACTION_TOOLKIT
57
using UnityEngine.XR.Interaction.Toolkit.Inputs;
68
using UnityEngine.XR.Interaction.Toolkit.Utilities;
79
using UnityEngine.XR.Interaction.Toolkit.Utilities.Tweenables.Primitives;
@@ -28,7 +30,7 @@ namespace WebXR.InputSystem
2830
/// </remarks>
2931
public class HandMenu : MonoBehaviour
3032
{
31-
#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
33+
#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER && HAS_XR_INTERACTION_TOOLKIT
3234
/// <summary>
3335
/// Enum dictating the up direction used in hand menu calculations.
3436
/// </summary>

Packages/webxr-interactions/Runtime/InputSystem/WebXR.InputSystem.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
"name": "Unity",
4343
"expression": "2022.3",
4444
"define": "HAS_POSITION_AND_ROTATION"
45+
},
46+
{
47+
"name": "com.unity.xr.interaction.toolkit",
48+
"expression": "2.5.2",
49+
"define": "HAS_XR_INTERACTION_TOOLKIT"
4550
}
4651
],
4752
"noEngineReferences": false

Packages/webxr-interactions/Runtime/InputSystem/WebXRControllerModel.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
55
using UnityEngine.InputSystem;
66
using UnityEngine.InputSystem.LowLevel;
7-
using UnityEngine.XR.Hands;
7+
#endif
8+
#if HAS_XR_INTERACTION_TOOLKIT
89
using UnityEngine.XR.Interaction.Toolkit;
910
#endif
1011
#if WEBXR_INPUT_PROFILES
@@ -132,10 +133,10 @@ public UpdateType updateType
132133

133134
[SerializeField] private GameObject rigOrigin;
134135

135-
[SerializeField] private Handedness hand;
136-
136+
[SerializeField] private WebXRControllerHand hand;
137+
#if HAS_XR_INTERACTION_TOOLKIT
137138
[SerializeField] private XRBaseController xrController;
138-
139+
#endif
139140
[SerializeField] private InputActionProperty positionActionProperty;
140141
[SerializeField] private InputActionProperty rotationActionProperty;
141142
[SerializeField] private InputActionProperty trackingStateActionProperty;
@@ -402,10 +403,10 @@ protected void OnEnable()
402403
m_IsFirstUpdate = true;
403404
switch (hand)
404405
{
405-
case Handedness.Left:
406+
case WebXRControllerHand.LEFT:
406407
WebXRInputSystem.OnLeftControllerProfiles += HandleOnControllerProfiles;
407408
break;
408-
case Handedness.Right:
409+
case WebXRControllerHand.RIGHT:
409410
WebXRInputSystem.OnRightControllerProfiles += HandleOnControllerProfiles;
410411
break;
411412
}
@@ -421,18 +422,20 @@ protected void OnDisable()
421422
InputSystem.onAfterUpdate -= UpdateCallback;
422423
switch (hand)
423424
{
424-
case Handedness.Left:
425+
case WebXRControllerHand.LEFT:
425426
WebXRInputSystem.OnLeftControllerProfiles -= HandleOnControllerProfiles;
426427
break;
427-
case Handedness.Right:
428+
case WebXRControllerHand.RIGHT:
428429
WebXRInputSystem.OnRightControllerProfiles -= HandleOnControllerProfiles;
429430
break;
430431
}
432+
#if HAS_XR_INTERACTION_TOOLKIT
431433
if (xrController != null && xrControllerOldModel != null)
432434
{
433435
xrController.model = xrControllerOldModel;
434436
xrController.hideControllerModel = false;
435437
}
438+
#endif
436439
}
437440

438441
/// <summary>
@@ -597,10 +600,10 @@ public void HandleOnControllerProfiles()
597600
string[] profiles = null;
598601
switch (hand)
599602
{
600-
case Handedness.Left:
603+
case WebXRControllerHand.LEFT:
601604
profiles = WebXRInputSystem.GetLeftProfiles();
602605
break;
603-
case Handedness.Right:
606+
case WebXRControllerHand.RIGHT:
604607
profiles = WebXRInputSystem.GetRightProfiles();
605608
break;
606609
}
@@ -650,13 +653,14 @@ private void HandleModelLoaded(bool success)
650653
inputProfileModelTransform.localPosition = Vector3.zero;
651654
inputProfileModelTransform.localRotation = Quaternion.identity;
652655
inputProfileModelTransform.localScale = Vector3.one;
656+
#if HAS_XR_INTERACTION_TOOLKIT
653657
if (xrController != null && xrController.model != null)
654658
{
655659
xrControllerOldModel = xrController.model;
656660
xrController.hideControllerModel = true;
657661
xrController.model = null;
658662
}
659-
663+
#endif
660664
if (m_CurrentTrackingState == TrackingStates.None)
661665
{
662666
inputProfileModel.gameObject.SetActive(false);

Packages/webxr-interactions/Samples~/XRInteractionToolkit/Scenes/WebXRInteractionToolkit.unity

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14907,6 +14907,21 @@ PrefabInstance:
1490714907
propertyPath: m_LocalEulerAnglesHint.z
1490814908
value: 0
1490914909
objectReference: {fileID: 0}
14910+
- target: {fileID: 7403072356979171074, guid: ed5fdb8d3e523e94ca6d8a239d40615a,
14911+
type: 3}
14912+
propertyPath: m_Enabled
14913+
value: 0
14914+
objectReference: {fileID: 0}
14915+
- target: {fileID: 7403072356979171076, guid: ed5fdb8d3e523e94ca6d8a239d40615a,
14916+
type: 3}
14917+
propertyPath: m_Enabled
14918+
value: 0
14919+
objectReference: {fileID: 0}
14920+
- target: {fileID: 7403072356979171077, guid: ed5fdb8d3e523e94ca6d8a239d40615a,
14921+
type: 3}
14922+
propertyPath: m_Enabled
14923+
value: 0
14924+
objectReference: {fileID: 0}
1491014925
- target: {fileID: 7403072357328242341, guid: ed5fdb8d3e523e94ca6d8a239d40615a,
1491114926
type: 3}
1491214927
propertyPath: m_Camera

0 commit comments

Comments
 (0)