docs.unity3d.com
    Show / Hide Table of Contents

    Class XRRayInteractor

    Interactor used for interacting with interactables at a distance. This is handled via ray casts that update the current set of valid targets for this interactor.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRBaseInteractor
    XRBaseControllerInteractor
    XRRayInteractor
    Inherited Members
    XRBaseControllerInteractor.selectActionTrigger
    XRBaseControllerInteractor.hideControllerOnSelect
    XRBaseControllerInteractor.allowHoveredActivate
    XRBaseControllerInteractor.playAudioClipOnSelectEntered
    XRBaseControllerInteractor.audioClipForOnSelectEntered
    XRBaseControllerInteractor.playAudioClipOnSelectExited
    XRBaseControllerInteractor.audioClipForOnSelectExited
    XRBaseControllerInteractor.playAudioClipOnSelectCanceled
    XRBaseControllerInteractor.audioClipForOnSelectCanceled
    XRBaseControllerInteractor.playAudioClipOnHoverEntered
    XRBaseControllerInteractor.audioClipForOnHoverEntered
    XRBaseControllerInteractor.playAudioClipOnHoverExited
    XRBaseControllerInteractor.audioClipForOnHoverExited
    XRBaseControllerInteractor.playAudioClipOnHoverCanceled
    XRBaseControllerInteractor.audioClipForOnHoverCanceled
    XRBaseControllerInteractor.playHapticsOnSelectEntered
    XRBaseControllerInteractor.hapticSelectEnterIntensity
    XRBaseControllerInteractor.hapticSelectEnterDuration
    XRBaseControllerInteractor.playHapticsOnSelectExited
    XRBaseControllerInteractor.hapticSelectExitIntensity
    XRBaseControllerInteractor.hapticSelectExitDuration
    XRBaseControllerInteractor.playHapticsOnSelectCanceled
    XRBaseControllerInteractor.hapticSelectCancelIntensity
    XRBaseControllerInteractor.hapticSelectCancelDuration
    XRBaseControllerInteractor.playHapticsOnHoverEntered
    XRBaseControllerInteractor.hapticHoverEnterIntensity
    XRBaseControllerInteractor.hapticHoverEnterDuration
    XRBaseControllerInteractor.playHapticsOnHoverExited
    XRBaseControllerInteractor.hapticHoverExitIntensity
    XRBaseControllerInteractor.hapticHoverExitDuration
    XRBaseControllerInteractor.playHapticsOnHoverCanceled
    XRBaseControllerInteractor.hapticHoverCancelIntensity
    XRBaseControllerInteractor.hapticHoverCancelDuration
    XRBaseControllerInteractor.allowActivate
    XRBaseControllerInteractor.xrController
    XRBaseControllerInteractor.isUISelectActive
    XRBaseControllerInteractor.shouldActivate
    XRBaseControllerInteractor.shouldDeactivate
    XRBaseControllerInteractor.GetActivateTargets(List<IXRActivateInteractable>)
    XRBaseControllerInteractor.OnHoverEntering(HoverEnterEventArgs)
    XRBaseControllerInteractor.OnHoverExiting(HoverExitEventArgs)
    XRBaseControllerInteractor.SendHapticImpulse(Single, Single)
    XRBaseControllerInteractor.PlayAudio(AudioClip)
    XRBaseControllerInteractor.playAudioClipOnSelectEnter
    XRBaseControllerInteractor.audioClipForOnSelectEnter
    XRBaseControllerInteractor.AudioClipForOnSelectEnter
    XRBaseControllerInteractor.playAudioClipOnSelectExit
    XRBaseControllerInteractor.audioClipForOnSelectExit
    XRBaseControllerInteractor.AudioClipForOnSelectExit
    XRBaseControllerInteractor.playAudioClipOnHoverEnter
    XRBaseControllerInteractor.audioClipForOnHoverEnter
    XRBaseControllerInteractor.AudioClipForOnHoverEnter
    XRBaseControllerInteractor.playAudioClipOnHoverExit
    XRBaseControllerInteractor.audioClipForOnHoverExit
    XRBaseControllerInteractor.AudioClipForOnHoverExit
    XRBaseControllerInteractor.playHapticsOnSelectEnter
    XRBaseControllerInteractor.playHapticsOnSelectExit
    XRBaseControllerInteractor.playHapticsOnHoverEnter
    XRBaseControllerInteractor.validTargets
    XRBaseInteractor.registered
    XRBaseInteractor.unregistered
    XRBaseInteractor.interactionManager
    XRBaseInteractor.interactionLayers
    XRBaseInteractor.attachTransform
    XRBaseInteractor.keepSelectedTargetValid
    XRBaseInteractor.startingSelectedInteractable
    XRBaseInteractor.startingTargetFilter
    XRBaseInteractor.hoverEntered
    XRBaseInteractor.hoverExited
    XRBaseInteractor.selectEntered
    XRBaseInteractor.selectExited
    XRBaseInteractor.targetFilter
    XRBaseInteractor.allowHover
    XRBaseInteractor.allowSelect
    XRBaseInteractor.isPerformingManualInteraction
    XRBaseInteractor.interactablesHovered
    XRBaseInteractor.hasHover
    XRBaseInteractor.interactablesSelected
    XRBaseInteractor.firstInteractableSelected
    XRBaseInteractor.hasSelection
    XRBaseInteractor.Reset()
    XRBaseInteractor.Start()
    XRBaseInteractor.OnDestroy()
    XRBaseInteractor.GetAttachTransform(IXRInteractable)
    XRBaseInteractor.GetAttachPoseOnSelect(IXRSelectInteractable)
    XRBaseInteractor.GetLocalAttachPoseOnSelect(IXRSelectInteractable)
    XRBaseInteractor.isHoverActive
    XRBaseInteractor.IsHovering(IXRHoverInteractable)
    XRBaseInteractor.IsSelecting(IXRSelectInteractable)
    XRBaseInteractor.IsHovering(IXRInteractable)
    XRBaseInteractor.IsSelecting(IXRInteractable)
    XRBaseInteractor.selectedInteractableMovementTypeOverride
    XRBaseInteractor.CaptureAttachPose(IXRSelectInteractable)
    XRBaseInteractor.IXRInteractor.OnRegistered(InteractorRegisteredEventArgs)
    XRBaseInteractor.IXRInteractor.OnUnregistered(InteractorUnregisteredEventArgs)
    XRBaseInteractor.IXRHoverInteractor.CanHover(IXRHoverInteractable)
    XRBaseInteractor.IXRHoverInteractor.OnHoverEntering(HoverEnterEventArgs)
    XRBaseInteractor.IXRHoverInteractor.OnHoverEntered(HoverEnterEventArgs)
    XRBaseInteractor.IXRHoverInteractor.OnHoverExiting(HoverExitEventArgs)
    XRBaseInteractor.IXRHoverInteractor.OnHoverExited(HoverExitEventArgs)
    XRBaseInteractor.IXRSelectInteractor.CanSelect(IXRSelectInteractable)
    XRBaseInteractor.IXRSelectInteractor.OnSelectEntering(SelectEnterEventArgs)
    XRBaseInteractor.IXRSelectInteractor.OnSelectEntered(SelectEnterEventArgs)
    XRBaseInteractor.IXRSelectInteractor.OnSelectExiting(SelectExitEventArgs)
    XRBaseInteractor.IXRSelectInteractor.OnSelectExited(SelectExitEventArgs)
    XRBaseInteractor.OnRegistered(InteractorRegisteredEventArgs)
    XRBaseInteractor.OnUnregistered(InteractorUnregisteredEventArgs)
    XRBaseInteractor.OnHoverEntered(HoverEnterEventArgs)
    XRBaseInteractor.OnHoverExited(HoverExitEventArgs)
    XRBaseInteractor.OnSelectEntered(SelectEnterEventArgs)
    XRBaseInteractor.OnSelectExited(SelectExitEventArgs)
    XRBaseInteractor.StartManualInteraction(IXRSelectInteractable)
    XRBaseInteractor.EndManualInteraction()
    XRBaseInteractor.interactionLayerMask
    XRBaseInteractor.enableInteractions
    XRBaseInteractor.onHoverEntered
    XRBaseInteractor.onHoverExited
    XRBaseInteractor.onSelectEntered
    XRBaseInteractor.onSelectExited
    XRBaseInteractor.onHoverEnter
    XRBaseInteractor.onHoverExit
    XRBaseInteractor.onSelectEnter
    XRBaseInteractor.onSelectExit
    XRBaseInteractor.OnHoverEntering(XRBaseInteractable)
    XRBaseInteractor.OnHoverEntered(XRBaseInteractable)
    XRBaseInteractor.OnHoverExiting(XRBaseInteractable)
    XRBaseInteractor.OnHoverExited(XRBaseInteractable)
    XRBaseInteractor.OnSelectEntering(XRBaseInteractable)
    XRBaseInteractor.OnSelectEntered(XRBaseInteractable)
    XRBaseInteractor.OnSelectExiting(XRBaseInteractable)
    XRBaseInteractor.OnSelectExited(XRBaseInteractable)
    XRBaseInteractor.selectTarget
    XRBaseInteractor.hoverTargets
    XRBaseInteractor.GetHoverTargets(List<XRBaseInteractable>)
    XRBaseInteractor.GetValidTargets(List<XRBaseInteractable>)
    XRBaseInteractor.requireSelectExclusive
    XRBaseInteractor.StartManualInteraction(XRBaseInteractable)
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(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, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, 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
    Component.rigidbody
    Component.rigidbody2D
    Component.camera
    Component.light
    Component.animation
    Component.constantForce
    Component.renderer
    Component.audio
    Component.networkView
    Component.collider
    Component.collider2D
    Component.hingeJoint
    Component.particleSystem
    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, Boolean)
    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, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [DisallowMultipleComponent]
    [AddComponentMenu("XR/XR Ray Interactor", 11)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.1/api/UnityEngine.XR.Interaction.Toolkit.XRRayInteractor.html")]
    public class XRRayInteractor : XRBaseControllerInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRActivateInteractor, IXRInteractor, ILineRenderable, IUIInteractor

    Properties

    acceleration

    Gravity of the projectile in the reference frame.

    Declaration
    public float acceleration { get; set; }
    Property Value
    Type Description
    Single
    See Also
    ProjectileCurve

    Acceleration

    (Deprecated) Gravity of the projectile in the reference frame.

    Declaration
    [Obsolete("Acceleration has been deprecated. Use acceleration instead. (UnityUpgradable) -> acceleration")]
    public float Acceleration { get; set; }
    Property Value
    Type Description
    Single
    Remarks

    Acceleration has been deprecated. Use acceleration instead.

    See Also
    ProjectileCurve

    additionalFlightTime

    Additional flight time after the projectile lands at the adjusted ground level. Increasing this value will make the end point drop lower in height.

    Declaration
    public float additionalFlightTime { get; set; }
    Property Value
    Type Description
    Single
    See Also
    ProjectileCurve

    AdditionalFlightTime

    Additional flight time after the projectile lands at the adjusted ground level. Increasing this value will make the end point drop lower in height.

    Declaration
    [Obsolete("AdditionalFlightTime has been deprecated. Use additionalFlightTime instead. (UnityUpgradable) -> additionalFlightTime")]
    public float AdditionalFlightTime { get; set; }
    Property Value
    Type Description
    Single
    Remarks

    AdditionalFlightTime has been deprecated. Use additionalFlightTime instead.

    See Also
    ProjectileCurve

    additionalGroundHeight

    Additional height below ground level that the projectile will continue to. Increasing this value will make the end point drop lower in height.

    Declaration
    public float additionalGroundHeight { get; set; }
    Property Value
    Type Description
    Single
    See Also
    ProjectileCurve

    allowAnchorControl

    Allows the user to move the attach anchor point using the joystick.

    Declaration
    public bool allowAnchorControl { get; set; }
    Property Value
    Type Description
    Boolean
    See Also
    rotateSpeed
    translateSpeed
    anchorRotateReferenceFrame

    anchorRotateReferenceFrame

    The optional reference frame to define the up axis when rotating the attach anchor point. When not set, rotates about the local up axis of the attach transform.

    Declaration
    public Transform anchorRotateReferenceFrame { get; set; }
    Property Value
    Type Description
    Transform
    See Also
    allowAnchorControl
    RotateAnchor(Transform, Single)

    angle

    The launch angle of the Projectile Curve. More specifically, this is the signed angle in degrees between the original attach forward direction and the plane of the reference frame, with positive angles when pointing upward.

    Declaration
    public float angle { get; }
    Property Value
    Type Description
    Single

    Angle

    The launch angle of the Projectile Curve. More specifically, this is the signed angle in degrees between the original attach forward direction and the plane of the reference frame, with positive angles when pointing upward.

    Declaration
    [Obsolete("Angle has been deprecated. Use angle instead. (UnityUpgradable) -> angle")]
    public float Angle { get; }
    Property Value
    Type Description
    Single
    Remarks

    Angle has been deprecated. Use angle instead.

    blendVisualLinePoints

    Blend the line sample points Unity uses for ray casting with the current pose of the controller. Use this to make the line visual stay connected with the controller instead of lagging behind.

    Declaration
    public bool blendVisualLinePoints { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    When the controller is configured to sample tracking input directly before rendering to reduce input latency, the controller may be in a new position or rotation relative to the starting point of the sample curve used for ray casting.
    A value of false will make the line visual stay at a fixed reference frame rather than bending or curving towards the end of the ray cast line.

    controlPointDistance

    Increase this value to make the peak of the curve further from the start point.

    Declaration
    public float controlPointDistance { get; set; }
    Property Value
    Type Description
    Single
    See Also
    BezierCurve

    controlPointHeight

    Increase this value to make the peak of the curve higher relative to the start point.

    Declaration
    public float controlPointHeight { get; set; }
    Property Value
    Type Description
    Single
    See Also
    BezierCurve

    enableUIInteraction

    Gets or sets whether this Interactor is able to affect UI.

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

    endPointDistance

    Increase this value distance to make the end of the curve further from the start point.

    Declaration
    public float endPointDistance { get; set; }
    Property Value
    Type Description
    Single
    See Also
    BezierCurve

    endPointHeight

    Decrease this value to make the end of the curve drop lower relative to the start point.

    Declaration
    public float endPointHeight { get; set; }
    Property Value
    Type Description
    Single
    See Also
    BezierCurve

    hitClosestOnly

    Whether Unity considers only the closest Interactable as a valid target for interaction.

    Declaration
    public bool hitClosestOnly { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    Enable this to make only the closest Interactable receive hover events. Otherwise, all hit Interactables will be considered valid and this Interactor will multi-hover.

    See Also
    GetValidTargets(List<IXRInteractable>)

    hitDetectionType

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

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

    hoverTimeToSelect

    Number of seconds for which this Interactor must hover over an Interactable to select it if Hover To Select is enabled.

    Declaration
    public float hoverTimeToSelect { get; set; }
    Property Value
    Type Description
    Single
    See Also
    hoverToSelect

    hoverToSelect

    Whether this Interactor will automatically select an Interactable after hovering over it for a period of time.

    Declaration
    public bool hoverToSelect { get; set; }
    Property Value
    Type Description
    Boolean
    See Also
    hoverTimeToSelect

    isSelectActive

    (Read Only) Indicates whether this Interactor is in a state where it could select.

    Declaration
    public override bool isSelectActive { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    XRBaseControllerInteractor.isSelectActive

    lineType

    Gets or sets the type of ray cast.

    Declaration
    public XRRayInteractor.LineType lineType { get; set; }
    Property Value
    Type Description
    XRRayInteractor.LineType

    maxRaycastDistance

    Gets or sets the max distance of ray cast when the line type is a straight line. Increasing this value will make the line reach further.

    Declaration
    public float maxRaycastDistance { get; set; }
    Property Value
    Type Description
    Single
    See Also
    StraightLine

    originalAttachTransform

    The Transform that upon entering selection (when this Interactor first initiates selection of an Interactable), this Interactor will copy the pose of the attach Transform values into.

    Declaration
    [Obsolete("originalAttachTransform has been deprecated. Use rayOriginTransform instead. (UnityUpgradable) -> rayOriginTransform")]
    protected Transform originalAttachTransform { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    Automatically instantiated and set in Awake(). Setting this will not automatically destroy the previous object.
    originalAttachTransform has been deprecated. Use rayOriginTransform instead.

    See Also
    attachTransform

    raycastMask

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

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

    raycastTriggerInteraction

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

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

    rayOriginTransform

    The starting position and direction of any ray casts.

    Declaration
    public Transform rayOriginTransform { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    Automatically instantiated and set in Awake() if null and initialized with the pose of the attachTransform. Setting this will not automatically destroy the previous object.

    referenceFrame

    The reference frame of the curve to define the ground plane and up. If not set at startup it will try to find the Origin GameObject, and if that does not exist it will use global up and origin by default.

    Declaration
    public Transform referenceFrame { get; set; }
    Property Value
    Type Description
    Transform
    See Also
    ProjectileCurve
    BezierCurve

    rotateSpeed

    Speed that the anchor is rotated.

    Declaration
    public float rotateSpeed { get; set; }
    Property Value
    Type Description
    Single
    See Also
    allowAnchorControl
    translateSpeed

    sampleFrequency

    The number of sample points Unity uses to approximate curved paths. Larger values produce a better quality approximate at the cost of reduced performance due to the number of ray casts.

    Declaration
    public int sampleFrequency { get; set; }
    Property Value
    Type Description
    Int32
    Remarks

    A value of n will result in n - 1 line segments for ray cast. This property is not used when using StraightLine since the value would always be 2.

    See Also
    ProjectileCurve
    BezierCurve

    sphereCastRadius

    Gets or sets radius used for sphere casting. Will use regular ray casting if set to 0 or less.

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

    translateSpeed

    Speed that the anchor is translated.

    Declaration
    public float translateSpeed { get; set; }
    Property Value
    Type Description
    Single
    See Also
    allowAnchorControl
    rotateSpeed

    useForceGrab

    Force grab moves the object to your hand rather than interacting with it at a distance.

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

    velocity

    Initial velocity of the projectile. Increasing this value will make the curve reach further.

    Declaration
    public float velocity { get; set; }
    Property Value
    Type Description
    Single
    See Also
    ProjectileCurve

    Velocity

    (Deprecated) Initial velocity of the projectile. Increasing this value will make the curve reach further.

    Declaration
    [Obsolete("Velocity has been deprecated. Use velocity instead. (UnityUpgradable) -> velocity")]
    public float Velocity { get; set; }
    Property Value
    Type Description
    Single
    Remarks

    Velocity has been deprecated. Use velocity instead.

    See Also
    ProjectileCurve

    Methods

    Awake()

    See MonoBehaviour.

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

    CanHover(IXRHoverInteractable)

    Determines if the Interactable is valid for hover this frame.

    Declaration
    public override bool CanHover(IXRHoverInteractable interactable)
    Parameters
    Type Name Description
    IXRHoverInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the Interactable can be hovered over this frame.

    Overrides
    XRBaseInteractor.CanHover(IXRHoverInteractable)
    See Also
    IsHoverableBy(IXRHoverInteractor)

    CanHover(XRBaseInteractable)

    Determines if the Interactable is valid for hover this frame.

    Declaration
    [Obsolete("CanHover(XRBaseInteractable) has been deprecated. Use CanHover(IXRHoverInteractable) instead.")]
    public override bool CanHover(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the interactable can be hovered over this frame.

    Overrides
    XRBaseInteractor.CanHover(XRBaseInteractable)
    Remarks

    CanHover(XRBaseInteractable) has been deprecated. Use CanHover(IXRHoverInteractable) instead.

    See Also
    IsHoverableBy(XRBaseInteractor)

    CanSelect(IXRSelectInteractable)

    Determines if the Interactable is valid for selection this frame.

    Declaration
    public override bool CanSelect(IXRSelectInteractable interactable)
    Parameters
    Type Name Description
    IXRSelectInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the Interactable can be selected this frame.

    Overrides
    XRBaseInteractor.CanSelect(IXRSelectInteractable)
    See Also
    IsSelectableBy(IXRSelectInteractor)

    CanSelect(XRBaseInteractable)

    Determines if the Interactable is valid for selection this frame.

    Declaration
    [Obsolete("CanSelect(XRBaseInteractable) has been deprecated. Use CanSelect(IXRSelectInteractable) instead.")]
    public override bool CanSelect(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable to check.

    Returns
    Type Description
    Boolean

    Returns true if the Interactable can be selected this frame.

    Overrides
    XRBaseInteractor.CanSelect(XRBaseInteractable)
    Remarks

    CanSelect(XRBaseInteractable) has been deprecated. Use CanSelect(IXRSelectInteractable) instead.

    See Also
    IsSelectableBy(XRBaseInteractor)

    GetCurrentRaycastHit(out RaycastHit)

    Gets the first 3D ray cast hit, if any ray cast hits are available.

    Declaration
    [Obsolete("GetCurrentRaycastHit has been deprecated. Use TryGetCurrent3DRaycastHit instead. (UnityUpgradable) -> TryGetCurrent3DRaycastHit(*)")]
    public bool GetCurrentRaycastHit(out RaycastHit raycastHit)
    Parameters
    Type Name Description
    RaycastHit raycastHit
    Returns
    Type Description
    Boolean

    Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    Remarks

    GetCurrentRaycastHit has been deprecated. Use TryGetCurrent3DRaycastHit(out RaycastHit) instead.

    GetLinePoints(ref Vector3[], out Int32)

    Gets the polygonal chain represented by a list of endpoints which form line segments to approximate the curve. Positions are in world space coordinates.

    Declaration
    public bool GetLinePoints(ref Vector3[] linePoints, out int numPoints)
    Parameters
    Type Name Description
    Vector3[] linePoints

    When this method returns, contains the sample points if successful.

    Int32 numPoints

    When this method returns, contains the number of sample points if successful.

    Returns
    Type Description
    Boolean

    Returns true if the sample points form a valid line, such as by having at least two points. Otherwise, returns false.

    Implements
    ILineRenderable.GetLinePoints(ref Vector3[], out Int32)

    GetLinePoints(ref Vector3[], ref Int32, Int32)

    (Obsolete) Use GetLinePoints(ref Vector3[], out Int32) instead.

    Declaration
    [Obsolete("GetLinePoints with ref int parameter has been deprecated. Use signature with out int parameter instead.", true)]
    public bool GetLinePoints(ref Vector3[] linePoints, ref int numPoints, int _ = 0)
    Parameters
    Type Name Description
    Vector3[] linePoints

    Obsolete.

    Int32 numPoints

    Obsolete.

    Int32 _

    Dummy value to support old function signature.

    Returns
    Type Description
    Boolean

    Obsolete.

    Remarks

    GetLinePoints with ref int parameter has been deprecated. Use signature with out int parameter instead.

    GetValidTargets(List<IXRInteractable>)

    Retrieve the list of Interactables that this Interactor could possibly interact with this frame. This list is sorted by priority (with highest priority first).

    Declaration
    public override void GetValidTargets(List<IXRInteractable> targets)
    Parameters
    Type Name Description
    List<IXRInteractable> targets

    The results list to populate with Interactables that are valid for selection or hover.

    Overrides
    XRBaseInteractor.GetValidTargets(List<IXRInteractable>)
    Remarks

    When implementing this method, Unity expects you to clear targets before adding to it.

    IsOverUIGameObject()

    Use this to determine if the ray is currenlty hovering over a UI GameObject.

    Declaration
    public bool IsOverUIGameObject()
    Returns
    Type Description
    Boolean

    Returns true if hovering over a UI element. Otherwise, returns false.

    Remarks

    enableUIInteraction must be enabled, otherwise the function will always return false.

    See Also
    IsPointerOverGameObject(Int32)
    IsPointerOverGameObject(Int32)

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected override void OnDisable()
    Overrides
    XRBaseInteractor.OnDisable()

    OnDrawGizmosSelected()

    See MonoBehaviour.

    Declaration
    protected virtual void OnDrawGizmosSelected()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected override void OnEnable()
    Overrides
    XRBaseInteractor.OnEnable()

    OnSelectEntering(SelectEnterEventArgs)

    The XRInteractionManager calls this method right before the Interactor first initiates selection of an Interactable in a first pass.

    Declaration
    protected override void OnSelectEntering(SelectEnterEventArgs args)
    Parameters
    Type Name Description
    SelectEnterEventArgs args

    Event data containing the Interactable that is being selected.

    Overrides
    XRBaseControllerInteractor.OnSelectEntering(SelectEnterEventArgs)
    Remarks

    args is only valid during this method call, do not hold a reference to it.

    See Also
    OnSelectEntered(SelectEnterEventArgs)

    OnSelectExiting(SelectExitEventArgs)

    The XRInteractionManager calls this method right before the Interactor ends selection of an Interactable in a first pass.

    Declaration
    protected override void OnSelectExiting(SelectExitEventArgs args)
    Parameters
    Type Name Description
    SelectExitEventArgs args

    Event data containing the Interactable that is no longer selected.

    Overrides
    XRBaseControllerInteractor.OnSelectExiting(SelectExitEventArgs)
    Remarks

    args is only valid during this method call, do not hold a reference to it.

    See Also
    OnSelectExited(SelectExitEventArgs)

    OnValidate()

    See MonoBehaviour.

    Declaration
    protected void OnValidate()

    PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    The XRInteractionManager calls this method to update the Interactor before interaction events occur. Interactors should use this method to do tasks like determine their valid targets.

    Declaration
    public override void PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    Parameters
    Type Name Description
    XRInteractionUpdateOrder.UpdatePhase updatePhase

    The update phase this is called during.

    Overrides
    XRBaseControllerInteractor.PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase)
    Remarks

    Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.

    See Also
    XRInteractionUpdateOrder.UpdatePhase

    ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    The XRInteractionManager calls this method to update the Interactor after interaction events occur.

    Declaration
    public override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    Parameters
    Type Name Description
    XRInteractionUpdateOrder.UpdatePhase updatePhase

    The update phase this is called during.

    Overrides
    XRBaseControllerInteractor.ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)
    Remarks

    Please see the XRInteractionManager and XRInteractionUpdateOrder.UpdatePhase documentation for more details on update order.

    See Also
    XRInteractionUpdateOrder.UpdatePhase
    ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)

    RotateAnchor(Transform, Single)

    Rotates the attach anchor for this interactor. This can be useful to rotate a held object.

    Declaration
    protected virtual void RotateAnchor(Transform anchor, float directionAmount)
    Parameters
    Type Name Description
    Transform anchor

    The attach transform of the interactor.

    Single directionAmount

    The rotation amount.

    TranslateAnchor(Transform, Transform, Single)

    Translates the attach anchor for this interactor. This can be useful to move a held object closer or further away from the interactor.

    Declaration
    protected virtual void TranslateAnchor(Transform rayOrigin, Transform anchor, float directionAmount)
    Parameters
    Type Name Description
    Transform rayOrigin

    The starting position and direction of any ray casts.

    Transform anchor

    The attach transform of the interactor.

    Single directionAmount

    The translation amount.

    TryGetCurrent3DRaycastHit(out RaycastHit)

    Gets the first 3D ray cast hit, if any ray cast hits are available.

    Declaration
    public bool TryGetCurrent3DRaycastHit(out RaycastHit raycastHit)
    Parameters
    Type Name Description
    RaycastHit raycastHit
    Returns
    Type Description
    Boolean

    Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    TryGetCurrent3DRaycastHit(out RaycastHit, out Int32)

    Gets the first 3D ray cast hit, if any ray cast hits are available.

    Declaration
    public bool TryGetCurrent3DRaycastHit(out RaycastHit raycastHit, out int raycastEndpointIndex)
    Parameters
    Type Name Description
    RaycastHit raycastHit

    When this method returns, contains the ray cast hit if available; otherwise, the default value.

    Int32 raycastEndpointIndex

    When this method returns, contains the index of the sample endpoint if a hit occurred. Otherwise, a value of 0 if no hit occurred.

    Returns
    Type Description
    Boolean

    Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    TryGetCurrentRaycast(out Nullable<RaycastHit>, out Int32, out Nullable<RaycastResult>, out Int32, out Boolean)

    Gets the first 3D and UI ray cast hits, if any ray cast hits are available.

    Declaration
    public bool TryGetCurrentRaycast(out RaycastHit? raycastHit, out int raycastHitIndex, out RaycastResult? uiRaycastHit, out int uiRaycastHitIndex, out bool isUIHitClosest)
    Parameters
    Type Name Description
    Nullable<RaycastHit> raycastHit

    When this method returns, contains the ray cast hit if available; otherwise, the default value.

    Int32 raycastHitIndex

    When this method returns, contains the index of the sample endpoint if a hit occurred. Otherwise, a value of 0 if no hit occurred.

    Nullable<RaycastResult> uiRaycastHit

    When this method returns, contains the UI ray cast result if available; otherwise, the default value.

    Int32 uiRaycastHitIndex

    When this method returns, contains the index of the sample endpoint if a hit occurred. Otherwise, a value of 0 if no hit occurred.

    Boolean isUIHitClosest

    When this method returns, contains whether the UI ray cast result was the closest hit.

    Returns
    Type Description
    Boolean

    Returns true if either hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    TryGetCurrentUIRaycastResult(out RaycastResult)

    Gets the first UI ray cast result, if any ray cast results are available.

    Declaration
    public bool TryGetCurrentUIRaycastResult(out RaycastResult raycastResult)
    Parameters
    Type Name Description
    RaycastResult raycastResult
    Returns
    Type Description
    Boolean

    Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    TryGetCurrentUIRaycastResult(out RaycastResult, out Int32)

    Gets the first UI ray cast result, if any ray cast results are available.

    Declaration
    public bool TryGetCurrentUIRaycastResult(out RaycastResult raycastResult, out int raycastEndpointIndex)
    Parameters
    Type Name Description
    RaycastResult raycastResult

    When this method returns, contains the UI ray cast result if available; otherwise, the default value.

    Int32 raycastEndpointIndex

    When this method returns, contains the index of the sample endpoint if a hit occurred. Otherwise, a value of 0 if no hit occurred.

    Returns
    Type Description
    Boolean

    Returns true if a hit occurred, implying the ray cast hit information is valid. Otherwise, returns false.

    TryGetHitInfo(out Vector3, out Vector3, out Int32, out Boolean)

    Gets the current ray cast hit information, if a hit occurs. It returns the world position and the normal vector of the hit point, and its position in linePoints.

    Declaration
    public bool TryGetHitInfo(out Vector3 position, out Vector3 normal, out int positionInLine, out bool isValidTarget)
    Parameters
    Type Name Description
    Vector3 position

    When this method returns, contains the world position of the ray impact point if a hit occurred.

    Vector3 normal

    When this method returns, contains the world normal of the surface the ray hit if a hit occurred.

    Int32 positionInLine

    When this method returns, contains the index of the sample endpoint within the list of points returned by GetLinePoints(ref Vector3[], out Int32) where a hit occurred. Otherwise, a value of 0 if no hit occurred.

    Boolean isValidTarget

    When this method returns, contains whether both a hit occurred and it is a valid target for interaction.

    Returns
    Type Description
    Boolean

    Returns true if a hit occurs, implying the ray cast hit information is valid. Otherwise, returns false.

    Implements
    ILineRenderable.TryGetHitInfo(out Vector3, out Vector3, out Int32, out Boolean)

    TryGetHitInfo(ref Vector3, ref Vector3, ref Int32, ref Boolean, Int32)

    (Obsolete) Use TryGetHitInfo(out Vector3, out Vector3, out Int32, out Boolean) instead.

    Declaration
    [Obsolete("TryGetHitInfo with ref parameters has been deprecated. Use signature with out parameters instead.", true)]
    public bool TryGetHitInfo(ref Vector3 position, ref Vector3 normal, ref int positionInLine, ref bool isValidTarget, int _ = 0)
    Parameters
    Type Name Description
    Vector3 position

    Obsolete.

    Vector3 normal

    Obsolete.

    Int32 positionInLine

    Obsolete.

    Boolean isValidTarget

    Obsolete.

    Int32 _

    Dummy value to support old function signature.

    Returns
    Type Description
    Boolean

    Obsolete.

    Remarks

    TryGetHitInfo with ref parameters has been deprecated. Use signature with out parameters instead.

    TryGetUIModel(out TrackedDeviceModel)

    Attempts to retrieve the current UI Model.

    Declaration
    public bool TryGetUIModel(out TrackedDeviceModel model)
    Parameters
    Type Name Description
    TrackedDeviceModel model

    The returned model that reflects the UI state of this Interactor.

    Returns
    Type Description
    Boolean

    Returns true if the model was able to retrieved. Otherwise, returns false.

    Implements
    IUIInteractor.TryGetUIModel(out TrackedDeviceModel)

    UpdateUIModel(ref TrackedDeviceModel)

    Updates the current UI Model to match the state of the Interactor.

    Declaration
    public virtual void UpdateUIModel(ref TrackedDeviceModel model)
    Parameters
    Type Name Description
    TrackedDeviceModel model

    The returned model that will match this Interactor.

    Implements
    IUIInteractor.UpdateUIModel(ref TrackedDeviceModel)

    Extension Methods

    XRHoverInteractorExtensions.GetOldestInteractableHovered(IXRHoverInteractor)
    XRSelectInteractorExtensions.GetOldestInteractableSelected(IXRSelectInteractor)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023