docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRRaycastSubsystem.Provider

    An interface to be implemented by providers of this subsystem.

    Inheritance
    object
    SubsystemProvider
    SubsystemProvider<XRRaycastSubsystem>
    XRRaycastSubsystem.Provider
    Inherited Members
    SubsystemProvider<XRRaycastSubsystem>.TryInitialize()
    SubsystemProvider.running
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.ARSubsystems
    Assembly: Unity.XR.ARSubsystems.dll
    Syntax
    public class XRRaycastSubsystem.Provider : SubsystemProvider<XRRaycastSubsystem>

    Methods

    Destroy()

    Called when the subsystem is destroyed. Stop() will be called first if the subsystem is running.

    Declaration
    public override void Destroy()
    Overrides
    UnityEngine.SubsystemsImplementation.SubsystemProvider<UnityEngine.XR.ARSubsystems.XRRaycastSubsystem>.Destroy()

    GetChanges(XRRaycast, Allocator)

    Get the changes to raycasts (arrays of added, updated, and removed) 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 initialize 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 allocator. The caller owns the memory.

    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 NativeArray.

    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 NativeArray.

    Returns
    Type Description
    NativeArray<XRRaycastHit>

    A NativeArray of all the resulting ray intersections.

    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 NativeArray.

    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 NativeArray.

    Returns
    Type Description
    NativeArray<XRRaycastHit>

    A NativeArray of all the resulting ray intersections.

    RemoveRaycast(TrackableId)

    Removes a raycast previously added with TryAddRaycast(Vector2, float, out XRRaycast) or TryAddRaycast(Ray, float, 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 override void Start()
    Overrides
    UnityEngine.SubsystemsImplementation.SubsystemProvider<UnityEngine.XR.ARSubsystems.XRRaycastSubsystem>.Start()

    Stop()

    Called when the subsystem is stopped. Will not be called before Start().

    Declaration
    public override void Stop()
    Overrides
    UnityEngine.SubsystemsImplementation.SubsystemProvider<UnityEngine.XR.ARSubsystems.XRRaycastSubsystem>.Stop()

    TryAddRaycast(Ray, float, 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.

    float estimatedDistance

    The estimated distance to the raycast target.

    XRRaycast raycast

    The newly added raycast. All spatial data should be reported relative to the XR origin.

    Returns
    Type Description
    bool

    True if the raycast was added; otherwise false.

    TryAddRaycast(Vector2, float, 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).

    float estimatedDistance

    The estimated distance to the raycast target.

    XRRaycast raycast

    The newly added raycast. All spatial data should be reported relative to the XR origin.

    Returns
    Type Description
    bool

    True if the raycast was added; otherwise false.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)