Skip to content

Commit

Permalink
Merge pull request #323 from De-Panther/fix_inputsystem_errors
Browse files Browse the repository at this point in the history
Fix errors when not implementing all the required packages for XRI
  • Loading branch information
De-Panther authored Nov 22, 2023
2 parents 69624a9 + 341888d commit 5d870e0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
4 changes: 3 additions & 1 deletion Packages/webxr-interactions/Runtime/InputSystem/HandMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,7 +30,7 @@ namespace WebXR.InputSystem
/// </remarks>
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
/// <summary>
/// Enum dictating the up direction used in hand menu calculations.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
}

/// <summary>
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5d870e0

Please sign in to comment.