docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CurveInteractionCaster

    A specialized interaction caster that extends InteractionCasterBase to support curved ray casting. This class implements the IUIModelUpdater interface to facilitate world-space UI interactions based on the generated sample points. It handles complex ray casting scenarios using curves, allowing for a more flexible interaction approach.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    InteractionCasterBase
    CurveInteractionCaster
    Implements
    ICurveInteractionCaster
    IInteractionCaster
    IUIModelUpdater
    Inherited Members
    InteractionCasterBase.isInitialized
    InteractionCasterBase.castOrigin
    InteractionCasterBase.effectiveCastOrigin
    InteractionCasterBase.enableStabilization
    InteractionCasterBase.positionStabilization
    InteractionCasterBase.angleStabilization
    InteractionCasterBase.aimTarget
    InteractionCasterBase.OnValidate()
    InteractionCasterBase.InitializeStabilization()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.Interaction.Toolkit.Interactors.Casters
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [DisallowMultipleComponent]
    [AddComponentMenu("XR/Interactors/Curve Interaction Caster", 22)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@3.2/api/UnityEngine.XR.Interaction.Toolkit.Interactors.Casters.CurveInteractionCaster.html")]
    public class CurveInteractionCaster : InteractionCasterBase, ICurveInteractionCaster, IInteractionCaster, IUIModelUpdater
    Remarks

    The caster supports different types of hit detection, including sphere and cone casting, alongside the standard ray casting. It allows customization of parameters like the number of curve segments, casting distance, and the size of the casting radius.

    Properties

    castDistance

    Maximum distance for all physics casts.

    Declaration
    public float castDistance { get; set; }
    Property Value
    Type Description
    float

    coneCastAngle

    Gets or sets the angle in degrees of the cone used for cone casting. Will use regular ray casting if set to 0.

    Declaration
    public float coneCastAngle { get; set; }
    Property Value
    Type Description
    float

    hitDetectionType

    Gets or sets which type of hit detection to use for the ray cast.

    Declaration
    public CurveInteractionCaster.HitDetectionType hitDetectionType { get; set; }
    Property Value
    Type Description
    CurveInteractionCaster.HitDetectionType

    isDestroyed

    Indicates whether OnDestroy has been called on this object.

    Declaration
    protected bool isDestroyed { get; }
    Property Value
    Type Description
    bool

    lastSamplePoint

    Gets the sample point at the last index of samplePoints.

    Declaration
    public Vector3 lastSamplePoint { get; }
    Property Value
    Type Description
    Vector3

    liveConeCastDebugVisuals

    If enabled, more detailed cone cast gizmos will be displayed in the editor.

    Declaration
    public bool liveConeCastDebugVisuals { get; set; }
    Property Value
    Type Description
    bool

    raycastMask

    Gets or sets layer mask used for limiting ray cast targets.

    Declaration
    public LayerMask raycastMask { get; set; }
    Property Value
    Type Description
    LayerMask

    raycastSnapVolumeInteraction

    Whether ray cast should include or ignore hits on trigger colliders that are snap volume colliders, even if the ray cast is set to ignore triggers. If you are not using gaze assistance or XR Interactable Snap Volume components, you should set this property to Ignore to avoid the performance cost.

    Declaration
    public CurveInteractionCaster.QuerySnapVolumeInteraction raycastSnapVolumeInteraction { get; set; }
    Property Value
    Type Description
    CurveInteractionCaster.QuerySnapVolumeInteraction
    Remarks

    When set to Collide when raycastTriggerInteraction is set to ignore trigger colliders (when set to Ignore or when set to UseGlobal while queriesHitTriggers is false), the ray cast query will be modified to include trigger colliders, but then this behavior will ignore any trigger collider hits that are not snap volumes.
    When set to Ignore when raycastTriggerInteraction is set to hit trigger colliders (when set to Collide or when set to UseGlobal while queriesHitTriggers is true), this behavior will ignore any trigger collider hits that are snap volumes.

    See Also
    raycastTriggerInteraction
    snapCollider

    raycastTriggerInteraction

    Gets or sets type of interaction with trigger colliders via ray cast.

    Declaration
    public QueryTriggerInteraction raycastTriggerInteraction { get; set; }
    Property Value
    Type Description
    QueryTriggerInteraction
    Remarks

    When set to UseGlobal, the value of Queries Hit Triggers (queriesHitTriggers) in Edit > Project Settings > Physics will be used.

    raycastUIDocumentTriggerInteraction

    Whether ray cast should include or ignore hits on trigger colliders that are UI Toolkit UI Document colliders, even if the ray cast is set to ignore triggers. If you are not using UI Toolkit, you should set this property to Ignore to avoid the performance cost.

    Declaration
    public QueryUIDocumentInteraction raycastUIDocumentTriggerInteraction { get; set; }
    Property Value
    Type Description
    QueryUIDocumentInteraction
    Remarks

    When set to Collide when raycastTriggerInteraction is set to ignore trigger colliders (when set to Ignore or when set to UseGlobal while queriesHitTriggers is false), the ray cast query will be modified to include trigger colliders, but then this behavior will ignore any trigger collider hits that are not UI Toolkit UI Documents.
    When set to Ignore when raycastTriggerInteraction is set to hit trigger colliders (when set to Collide or when set to UseGlobal while queriesHitTriggers is true), this behavior will ignore any trigger collider hits that are UI Toolkit UI Documents.

    See Also
    raycastTriggerInteraction

    samplePoints

    Gets the curve sample points used to determine interaction results.

    Declaration
    public NativeArray<Vector3> samplePoints { get; protected set; }
    Property Value
    Type Description
    NativeArray<Vector3>

    sphereCastRadius

    Gets or sets radius used for sphere casting.

    Declaration
    public float sphereCastRadius { get; set; }
    Property Value
    Type Description
    float
    See Also
    SphereCast
    hitDetectionType

    targetNumCurveSegments

    Gets or sets the number of segments to sample along the curve. This also determines the length of the samplePoints array.

    Declaration
    public int targetNumCurveSegments { get; set; }
    Property Value
    Type Description
    int

    Methods

    Awake()

    See MonoBehaviour.

    Declaration
    protected override void Awake()
    Overrides
    InteractionCasterBase.Awake()

    CheckCollidersBetweenPoints(in XRInteractionManager, Vector3, Vector3, Vector3, RaycastHit[])

    Checks for colliders between specified points using a raycast, sphere cast, or cone cast based on the current configuration. Returns the count of hits detected.

    Declaration
    protected virtual int CheckCollidersBetweenPoints(in XRInteractionManager interactionManager, Vector3 from, Vector3 to, Vector3 origin, RaycastHit[] raycastHits)
    Parameters
    Type Name Description
    XRInteractionManager interactionManager

    The XR interaction manager used to help filter colliders

    Vector3 from

    The starting point of the check.

    Vector3 to

    The ending point of the check.

    Vector3 origin

    The origin point for the casting.

    RaycastHit[] raycastHits

    Array to store the results of the raycast hits.

    Returns
    Type Description
    int

    The number of colliders detected between the given points.

    InitializeCaster()

    Tries to initialize the caster.

    Declaration
    protected override bool InitializeCaster()
    Returns
    Type Description
    bool

    Returns true if successful or already initialized.

    Overrides
    InteractionCasterBase.InitializeCaster()

    OnDestroy()

    See MonoBehaviour.

    Declaration
    protected override void OnDestroy()
    Overrides
    InteractionCasterBase.OnDestroy()

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected virtual void OnDisable()

    OnDrawGizmosSelected()

    See MonoBehaviour.

    Declaration
    protected virtual void OnDrawGizmosSelected()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected virtual void OnEnable()

    TryGetColliderTargets(XRInteractionManager, List<Collider>)

    Gets an unsorted list of collider targets

    Declaration
    public override bool TryGetColliderTargets(XRInteractionManager interactionManager, List<Collider> targets)
    Parameters
    Type Name Description
    XRInteractionManager interactionManager

    XR Interaction manager reference

    List<Collider> targets

    List of target colliders to populate.

    Returns
    Type Description
    bool

    Returns true if collider targets were found.

    Overrides
    InteractionCasterBase.TryGetColliderTargets(XRInteractionManager, List<Collider>)

    TryGetColliderTargets(XRInteractionManager, List<Collider>, List<RaycastHit>)

    Tries to get a list of collider targets based on the interaction caster's current state, sorted by their distance from the cast origin.

    Declaration
    public bool TryGetColliderTargets(XRInteractionManager interactionManager, List<Collider> targets, List<RaycastHit> raycastHits)
    Parameters
    Type Name Description
    XRInteractionManager interactionManager

    The XR interaction manager.

    List<Collider> targets
    List<RaycastHit> raycastHits

    List of raycast hits lined up to the list of colliders.

    Returns
    Type Description
    bool

    True if targets are successfully detected.

    UpdateInternalData()

    Updates internal state for the caster.

    Declaration
    protected override void UpdateInternalData()
    Overrides
    InteractionCasterBase.UpdateInternalData()

    UpdatePhysicscastHits(in XRInteractionManager)

    Performs physics casting to update hits based on the current sample points. Returns a boolean indicating whether any hits were recorded.

    Declaration
    protected virtual bool UpdatePhysicscastHits(in XRInteractionManager interactionManager)
    Parameters
    Type Name Description
    XRInteractionManager interactionManager

    The XR interaction manager used to help filter colliders

    Returns
    Type Description
    bool

    True if any raycast hits were found; otherwise, false.

    UpdateSamplePoints()

    Updates sample points for casting, based on the current, potentially stabilized cast origin and direction.

    Declaration
    protected virtual void UpdateSamplePoints()

    UpdateSamplePoints(in Vector3, in Vector3, float, NativeArray<Vector3>)

    Updates a set of sample points for casting, given the origin, direction, total distance, and an array of points. Base implementation does a simple linear interpolation between the origin and the end point.

    Declaration
    protected virtual void UpdateSamplePoints(in Vector3 origin, in Vector3 direction, float totalDistance, NativeArray<Vector3> points)
    Parameters
    Type Name Description
    Vector3 origin

    The starting point of the cast.

    Vector3 direction

    The direction in which the cast is performed.

    float totalDistance

    The total distance of the cast.

    NativeArray<Vector3> points

    The array of points to be updated for the cast.

    UpdateUIModel(ref TrackedDeviceModel, bool, in Vector2)

    Updates the UI data model based on the implementer of this interface.

    Declaration
    public bool UpdateUIModel(ref TrackedDeviceModel uiModel, bool isSelectActive, in Vector2 scrollDelta)
    Parameters
    Type Name Description
    TrackedDeviceModel uiModel

    UI data model to update.

    bool isSelectActive

    UI select input state to write into the UI data model.

    Vector2 scrollDelta

    UI scroll input state to write into the UI data model.

    Returns
    Type Description
    bool

    Returns true if UI data model was updated successfully.

    Implements

    ICurveInteractionCaster
    IInteractionCaster
    IUIModelUpdater
    In This Article
    Back to top
    Copyright © 2025 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)