Skip to content

Commit 78c83e8

Browse files
authored
Merge pull request #248 from De-Panther/fix_no_controllers_hittest
Fixed no reference to controllers in SceneHitTest
2 parents 0ca32c3 + 95240fa commit 78c83e8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Packages/webxr-interactions/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- No reference to controllers in SceneHitTest.
11+
912
## [0.16.0] - 2023-02-02
1013
### Added
1114
- Spectator Camera.

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public class SceneHitTest : MonoBehaviour
66
{
77
public Transform originTransform;
88
public GameObject visual;
9+
[SerializeField]
910
private WebXRController leftController;
11+
[SerializeField]
1012
private WebXRController rightController;
1113

1214
private bool isFollowing = false;
@@ -16,6 +18,29 @@ public class SceneHitTest : MonoBehaviour
1618

1719
private Transform arCameraTransform;
1820

21+
void Start()
22+
{
23+
if (leftController == null || rightController == null)
24+
{
25+
var controllers = FindObjectsOfType<WebXRController>();
26+
for (int i = 0; i < controllers.Length; i++)
27+
{
28+
if (controllers[i].hand == WebXRControllerHand.LEFT)
29+
{
30+
leftController ??= controllers[i];
31+
}
32+
else if (controllers[i].hand == WebXRControllerHand.RIGHT)
33+
{
34+
rightController ??= controllers[i];
35+
}
36+
if (leftController != null && rightController != null)
37+
{
38+
return;
39+
}
40+
}
41+
}
42+
}
43+
1944
void OnEnable()
2045
{
2146
isFollowing = false;

0 commit comments

Comments
 (0)