Skip to content

Commit 97d72e3

Browse files
committed
Support Input Actions in MixedRealityCaptureController
1 parent a4a0ead commit 97d72e3

File tree

4 files changed

+7742
-3216
lines changed

4 files changed

+7742
-3216
lines changed

Packages/webxr-interactions/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- WebXRControllerModel to load WebXR Input Profiles model when using Unity Input System.
1414
- HandMenu to override XR Interaction Toolkit one, as it's missing an option to set camera transform.
1515
- WebXR + XR Interaction Toolkit Sample.
16+
- Support Input Actions in MixedRealityCaptureController.
1617

1718
## [0.18.0] - 2023-08-29
1819
### Changed

Packages/webxr-interactions/Runtime/Scripts/MixedRealityCaptureController.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ private enum ControllerState
106106
private WebXRController leftController;
107107
[SerializeField]
108108
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
109121
[SerializeField]
110122
private int webcamFramesDelaySize = 0;
111123

@@ -306,7 +318,14 @@ private void Ended()
306318

307319
private void SetPoint(Transform point, GameObject hint, ControllerState nextState, GameObject nextHint, Transform nextPoint)
308320
{
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+
}
310329
if (GetControllersButtonDown())
311330
{
312331
hint.SetActive(false);
@@ -319,7 +338,9 @@ private void SetPoint(Transform point, GameObject hint, ControllerState nextStat
319338
private void SetBottomPoint()
320339
{
321340
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;
323344
calibrationPointBottom.position = calibrationPointCamera.position + cameraToBottomDirection * cameraToTopDistance;
324345
if (GetControllersButtonDown())
325346
{
@@ -385,6 +406,14 @@ private void SetCameraPositionRotation()
385406

386407
private bool GetControllersButtonDown()
387408
{
409+
if (useInputSystem)
410+
{
411+
if (leftTrigger.action.ReadValue<bool>())
412+
{
413+
return true;
414+
}
415+
return rightTrigger.action.ReadValue<bool>();
416+
}
388417
bool leftDown = (leftController.isHandActive || leftController.isControllerActive)
389418
&& leftController.GetButtonDown(WebXRController.ButtonTypes.Trigger);
390419
if (leftDown)

Packages/webxr-interactions/Runtime/Scripts/WebXR.Interactions.asmdef

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"rootNamespace": "",
44
"references": [
55
"GUID:fd4abe4ffe74ef1448afe15c6cb36bb7",
6-
"GUID:84a2d09f0bb073f40922f5ea5362abe7"
6+
"GUID:84a2d09f0bb073f40922f5ea5362abe7",
7+
"GUID:75469ad4d38634e559750d17036d5f7c"
78
],
89
"includePlatforms": [],
910
"excludePlatforms": [],
@@ -27,6 +28,11 @@
2728
"name": "Unity",
2829
"expression": "2022.3",
2930
"define": "HAS_POSITION_AND_ROTATION"
31+
},
32+
{
33+
"name": "com.unity.inputsystem",
34+
"expression": "1.4.4",
35+
"define": "UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER"
3036
}
3137
],
3238
"noEngineReferences": false

0 commit comments

Comments
 (0)