@@ -106,6 +106,18 @@ private enum ControllerState
106
106
private WebXRController leftController ;
107
107
[ SerializeField ]
108
108
private WebXRController rightController ;
109
+ #if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
110
+ [ SerializeField ]
111
+ #endif
112
+ private bool useInputSystem = false ;
113
+ #if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
114
+ [ SerializeField ]
115
+ private UnityEngine . InputSystem . InputActionProperty rightPosition ;
116
+ [ SerializeField ]
117
+ private UnityEngine . InputSystem . InputActionProperty leftTrigger ;
118
+ [ SerializeField ]
119
+ private UnityEngine . InputSystem . InputActionProperty rightTrigger ;
120
+ #endif
109
121
[ SerializeField ]
110
122
private int webcamFramesDelaySize = 0 ;
111
123
@@ -306,7 +318,14 @@ private void Ended()
306
318
307
319
private void SetPoint ( Transform point , GameObject hint , ControllerState nextState , GameObject nextHint , Transform nextPoint )
308
320
{
309
- point . position = rightController . transform . position ;
321
+ if ( useInputSystem )
322
+ {
323
+ point . position = rightPosition . action . ReadValue < Vector3 > ( ) ;
324
+ }
325
+ else
326
+ {
327
+ point . position = rightController . transform . position ;
328
+ }
310
329
if ( GetControllersButtonDown ( ) )
311
330
{
312
331
hint . SetActive ( false ) ;
@@ -319,7 +338,9 @@ private void SetPoint(Transform point, GameObject hint, ControllerState nextStat
319
338
private void SetBottomPoint ( )
320
339
{
321
340
float cameraToTopDistance = Vector3 . Distance ( calibrationPointCamera . position , calibrationPointTop . position ) ;
322
- Vector3 cameraToBottomDirection = ( rightController . transform . position - calibrationPointCamera . position ) . normalized ;
341
+ Vector3 cameraToBottomDirection = useInputSystem ?
342
+ ( rightPosition . action . ReadValue < Vector3 > ( ) - calibrationPointCamera . position ) . normalized
343
+ : ( rightController . transform . position - calibrationPointCamera . position ) . normalized ;
323
344
calibrationPointBottom . position = calibrationPointCamera . position + cameraToBottomDirection * cameraToTopDistance ;
324
345
if ( GetControllersButtonDown ( ) )
325
346
{
@@ -385,6 +406,14 @@ private void SetCameraPositionRotation()
385
406
386
407
private bool GetControllersButtonDown ( )
387
408
{
409
+ if ( useInputSystem )
410
+ {
411
+ if ( leftTrigger . action . ReadValue < bool > ( ) )
412
+ {
413
+ return true ;
414
+ }
415
+ return rightTrigger . action . ReadValue < bool > ( ) ;
416
+ }
388
417
bool leftDown = ( leftController . isHandActive || leftController . isControllerActive )
389
418
&& leftController . GetButtonDown ( WebXRController . ButtonTypes . Trigger ) ;
390
419
if ( leftDown )
0 commit comments