Class XRRaycastSubsystem
Base class for a raycast subsystem.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public class XRRaycastSubsystem : TrackingSubsystem<XRRaycast, XRRaycastSubsystem, XRRaycastSubsystemDescriptor, XRRaycastSubsystem.Provider>, ISubsystem
Remarks
This abstract class should be implemented by an XR provider and instantiated using the SubsystemManager
to enumerate the available XRRaycastSubsystemDescriptors.
Constructors
XRRaycastSubsystem()
Constructor. Do not invoke directly; use the SubsystemManager
to enumerate the available XRRaycastSubsystemDescriptors
and call Create
on the desired descriptor.
Declaration
public XRRaycastSubsystem()
Methods
GetChanges(Allocator)
Get the changes to the tracked raycasts (arrays of added, updated and removed) since the last call to this method.
Declaration
public override TrackableChanges<XRRaycast> GetChanges(Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
Unity.Collections.Allocator | allocator | An allocator to use for the returned container. |
Returns
Type | Description |
---|---|
TrackableChanges<XRRaycast> | The set of changes since the last call to this method. The caller owns the data and is responsible for calling Dispose() on it. |
Overrides
Raycast(Ray, TrackableType, Allocator)
Casts ray
against trackables specified with trackableTypeMask
.
Declaration
public NativeArray<XRRaycastHit> Raycast(Ray ray, TrackableType trackableTypeMask, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | ray | A ray in session space. |
TrackableType | trackableTypeMask | The types of trackables to test for ray intersections. |
Unity.Collections.Allocator | allocator | The |
Returns
Type | Description |
---|---|
Unity.Collections.NativeArray<XRRaycastHit> | A |
Raycast(Vector2, TrackableType, Allocator)
Casts a ray originating from screenPoint
against trackables specified with trackableTypeMask
.
Declaration
public NativeArray<XRRaycastHit> Raycast(Vector2 screenPoint, TrackableType trackableTypeMask, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | screenPoint | A point on the screen in normalized screen coordinates (0, 0) - (1, 1). |
TrackableType | trackableTypeMask | The types of trackables to test for ray intersections. |
Unity.Collections.Allocator | allocator | The |
Returns
Type | Description |
---|---|
Unity.Collections.NativeArray<XRRaycastHit> | A |
RemoveRaycast(TrackableId)
Removes an existing raycast by its TrackableId.
Declaration
public void RemoveRaycast(TrackableId trackableId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | trackableId | The unique identifier for the raycast to remove. |
TryAddRaycast(Ray, Single, out XRRaycast)
Attempts to add a new persistent raycast. The raycast will be updated automatically until this subsystem is stopped or destroyed, or the the raycast is removed with RemoveRaycast(TrackableId).
Declaration
public bool TryAddRaycast(Ray ray, float estimatedDistance, out XRRaycast raycast)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | ray | A ray relative to the XR origin defining the raycast. |
Single | estimatedDistance | The estimated distance to the raycast target. For example, an average human height might be used to estimate the distance to the floor. |
XRRaycast | raycast | The newly added raycast. All spatial data is relative to the XR origin. |
Returns
Type | Description |
---|---|
Boolean |
|
TryAddRaycast(Vector2, Single, out XRRaycast)
Attempts to add a new persistent raycast. The raycast will be updated automatically until this subsystem is stopped or destroyed, or the the raycast is removed with RemoveRaycast(TrackableId).
Declaration
public bool TryAddRaycast(Vector2 screenPoint, float estimatedDistance, out XRRaycast raycast)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector2 | screenPoint | A point on the screen, in normalized screen coorindates (0, 0)..(1, 1). |
Single | estimatedDistance | The estimated distance to the raycast target. For example, an average human height might be used to estimate the distance to the floor. |
XRRaycast | raycast | The newly added raycast. All spatial data is relative to the XR origin. |
Returns
Type | Description |
---|---|
Boolean |
|