screenPoint | The screen point from which to cast. |
hitResults | The resulting list of XRRaycastHit. |
trackableTypeMask | An optional mask of TrackableType to raycast against. |
Casts a ray from a screen point against selected trackables (e.g., planes and feature points).
Casts a ray from a screen position against selected trackables in the scene. trackableTypeMask
defaults to TrackableType.All.
#pragma strict public class RaycastExample extends MonoBehaviour { public var xrRaycast: XRRaycast; private var m_RaycastHits: List.<XRRaycastHit> = new List.<XRRaycastHit>(); function Update() { if (Input.GetMouseButton(0)) { // Only raycast against feature points and the exact plane boundries var hitMask: var = TrackableType.FeaturePoint | TrackableType.PlaneWithinPolygon; if (xrRaycast.Raycast(Input.mousePosition, m_RaycastHits, hitMask)) { Debug.Log("Hit something!"); } } } }
using System.Collections.Generic; using UnityEngine; using UnityEngine.Experimental.XR; public class RaycastExample : MonoBehaviour { public XRRaycast xrRaycast; private List<XRRaycastHit> m_RaycastHits = new List<XRRaycastHit>(); void Update() { if (Input.GetMouseButton(0)) { // Only raycast against feature points and the exact plane boundries var hitMask = TrackableType.FeaturePoint | TrackableType.PlaneWithinPolygon; if (xrRaycast.Raycast(Input.mousePosition, m_RaycastHits, hitMask)) { Debug.Log("Hit something!"); } } } }
ray | The Ray to use. |
depthSubsystem | The XRDepthSubsystem to raycast against. May be null . |
planeSubsystem | The XRPlaneSubsystem to raycast against. May be null . |
hitResults | The resulting list of XRRaycastHit. |
trackableTypeMask | An optional mask of TrackableType to raycast against. |
pointCloudRaycastAngleInDegrees | When raycasting against feature points, cast a cone with this angle. |
Casts a ray using ray
against selected trackables (e.g., planes and feature points).
Use this method to raycast against selected trackables in the scene. trackableTypeMask
defaults to TrackableType.All.
When raycasting against TrackableType.FeaturePoint, Unity uses a cone defined by pointCloudRaycastAngleInDegrees
. It defaults to 5 degrees.
Did you find this page useful? Please give it a rating: