Class XRRaycastSubsystem.Provider
An interface to be implemented by providers of this subsystem.
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public class Provider
Methods
Destroy()
Called when the subsystem is destroyed. Stop() will be called first if the subsystem is running.
Declaration
public virtual void Destroy()
GetChanges(XRRaycast, Allocator)
Get the changes (arrays of added, updated, and removed) raycasts since the last call to this method.
Declaration
public virtual TrackableChanges<XRRaycast> GetChanges(XRRaycast defaultRaycast, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRRaycast | defaultRaycast | A default value for XRRaycasts. For backwards compatibility, this should be used to initialized the returned NativeArrays. |
Allocator | allocator | The Allocator to use when allocating the returned NativeArrays. |
Returns
Type | Description |
---|---|
TrackableChanges<XRRaycast> | Arrays of added, updated, and removed raycasts since the last call to this method. The
changes should be allocated using |
Raycast(XRRaycastHit, Ray, TrackableType, Allocator)
Performs a raycast from an arbitrary ray against the types
specified by trackableTypeMask
. Results
should be sorted by distance from the ray origin.
Declaration
public virtual NativeArray<XRRaycastHit> Raycast(XRRaycastHit defaultRaycastHit, Ray ray, TrackableType trackableTypeMask, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRRaycastHit | defaultRaycastHit | The default raycast hit that should be used as a template when populating the returned |
Ray | ray | A ray in session space from which to raycast. |
TrackableType | trackableTypeMask | The types to raycast against. |
Allocator | allocator | The allocator with which to allocate the returned |
Returns
Type | Description |
---|---|
NativeArray<XRRaycastHit> | A |
Raycast(XRRaycastHit, Vector2, TrackableType, Allocator)
Performs a raycast from the camera against the types
specified by trackableTypeMask
. Results
should be sorted by distance from the ray origin.
Declaration
public virtual NativeArray<XRRaycastHit> Raycast(XRRaycastHit defaultRaycastHit, Vector2 screenPoint, TrackableType trackableTypeMask, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRRaycastHit | defaultRaycastHit | The default raycast hit that should be used as a template when populating the returned |
Vector2 | screenPoint | A point on the screen in normalized (0...1) coordinates |
TrackableType | trackableTypeMask | The types to raycast against. |
Allocator | allocator | The allocator with which to allocate the returned |
Returns
Type | Description |
---|---|
NativeArray<XRRaycastHit> | A |
RemoveRaycast(TrackableId)
Removes a raycast previously added with TryAddRaycast(Vector2, Single, out XRRaycast) or TryAddRaycast(Ray, Single, out XRRaycast)
Declaration
public virtual void RemoveRaycast(TrackableId trackableId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | trackableId | The unique identifier associated with the raycast to remove. |
Start()
Called when the subsystem is started. Will not be called again until Stop().
Declaration
public virtual void Start()
Stop()
Called when the subsystem is stopped. Will not be called before Start().
Declaration
public virtual void Stop()
TryAddRaycast(Ray, Single, out XRRaycast)
Adds a new persistent raycast. Persistent raycasts should be updated automatically until this provider is stopped or destroyed or the raycast is removed with RemoveRaycast(TrackableId).
Declaration
public virtual bool TryAddRaycast(Ray ray, float estimatedDistance, out XRRaycast raycast)
Parameters
Type | Name | Description |
---|---|---|
Ray | ray | A ray in session-space defining the raycast |
Single | estimatedDistance | The estimated distance to the raycast target. |
XRRaycast | raycast | The newly added raycast. All spatial data should be reported relative to the session origin. |
Returns
Type | Description |
---|---|
Boolean |
|
TryAddRaycast(Vector2, Single, out XRRaycast)
Adds a new persistent raycast. Persistent raycasts should be updated automatically until this provider is stopped or destroyed or the raycast is removed with RemoveRaycast(TrackableId).
Declaration
public virtual bool TryAddRaycast(Vector2 screenPoint, float estimatedDistance, out XRRaycast raycast)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | screenPoint | A position on the screen in normalized screen coordinates (0, 0)..(1, 1) |
Single | estimatedDistance | The estimated distance to the raycast target. |
XRRaycast | raycast | The newly added raycast. All spatial data should be reported relative to the session origin. |
Returns
Type | Description |
---|---|
Boolean |
|