Skip to content

Commit 3b8b9ad

Browse files
authored
Merge pull request #191 from De-Panther/scenehittest_headsets_support
Added support for AR headsets in SceneHitTest
2 parents 1ade290 + 26922f9 commit 3b8b9ad

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Packages/webxr-interactions/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Support for AR headsets in SceneHitTest.
810

911
## [0.13.0] - 2021-10-18
1012
### Changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public class SceneHitTest : MonoBehaviour
66
{
77
public Transform originTransform;
88
public GameObject visual;
9+
private WebXRController leftController;
10+
private WebXRController rightController;
911

1012
private bool isFollowing = false;
1113

@@ -30,9 +32,16 @@ void OnDisable()
3032
WebXRManager.OnViewerHitTestUpdate -= HandleOnViewerHitTestUpdate;
3133
}
3234

35+
bool GetControllersButtonDown()
36+
{
37+
bool leftDown = (leftController.isHandActive || leftController.isControllerActive) && leftController.GetButtonDown(WebXRController.ButtonTypes.Trigger);
38+
bool rightDown = (rightController.isHandActive || rightController.isControllerActive) && rightController.GetButtonDown(WebXRController.ButtonTypes.Trigger);
39+
return leftDown || rightDown;
40+
}
41+
3342
void Update()
3443
{
35-
if (isFollowing && Input.GetMouseButtonDown(0))
44+
if (isFollowing && (Input.GetMouseButtonDown(0) || GetControllersButtonDown()))
3645
{
3746
isFollowing = false;
3847
visual.SetActive(false);

0 commit comments

Comments
 (0)