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
    XRGazeInteractor
    Inherited Members
    XRBaseControllerInteractor.selectActionTrigger
    XRBaseControllerInteractor.hideControllerOnSelect
    XRBaseControllerInteractor.allowHoveredActivate
    XRBaseControllerInteractor.targetPriorityMode
    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.allowHoverAudioWhileSelecting
    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.allowHoverHapticsWhileSelecting
    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)
    XRBaseInteractor.registered
    XRBaseInteractor.unregistered
    XRBaseInteractor.interactionManager
    XRBaseInteractor.containingGroup
    XRBaseInteractor.interactionLayers
    XRBaseInteractor.attachTransform
    XRBaseInteractor.keepSelectedTargetValid
    XRBaseInteractor.disableVisualsWhenBlockedInGroup
    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.startingHoverFilters
    XRBaseInteractor.hoverFilters
    XRBaseInteractor.startingSelectFilters
    XRBaseInteractor.selectFilters
    XRBaseInteractor.largestInteractionStrength
    XRBaseInteractor.Reset()
    XRBaseInteractor.Start()
    XRBaseInteractor.OnDestroy()
    XRBaseInteractor.GetAttachTransform(IXRInteractable)
    XRBaseInteractor.GetAttachPoseOnSelect(IXRSelectInteractable)
    XRBaseInteractor.GetLocalAttachPoseOnSelect(IXRSelectInteractable)
    XRBaseInteractor.isHoverActive
    XRBaseInteractor.targetsForSelection
    XRBaseInteractor.IsHovering(IXRHoverInteractable)
    XRBaseInteractor.IsSelecting(IXRSelectInteractable)
    XRBaseInteractor.IsHovering(IXRInteractable)
    XRBaseInteractor.IsSelecting(IXRInteractable)
    XRBaseInteractor.selectedInteractableMovementTypeOverride
    XRBaseInteractor.CaptureAttachPose(IXRSelectInteractable)
    XRBaseInteractor.GetInteractionStrength(IXRInteractable)
    XRBaseInteractor.IXRInteractionStrengthInteractor.ProcessInteractionStrength(XRInteractionUpdateOrder.UpdatePhase)
    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.ProcessInteractionStrength(XRInteractionUpdateOrder.UpdatePhase)
    XRBaseInteractor.StartManualInteraction(IXRSelectInteractable)
    XRBaseInteractor.EndManualInteraction()
    XRBaseInteractor.ProcessHoverFilters(IXRHoverInteractable)
    XRBaseInteractor.ProcessSelectFilters(IXRSelectInteractable)
    XRBaseInteractor.IXRGroupMember.OnRegisteringAsGroupMember(IXRInteractionGroup)
    XRBaseInteractor.IXRGroupMember.OnRegisteringAsNonGroupMember()
    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.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, Boolean)
    Component.GetComponentInParent(Type)
    UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
    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
    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.FindObjectsOfType(Type, Boolean)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    UnityEngine.Object.FindFirstObjectByType<T>()
    UnityEngine.Object.FindAnyObjectByType<T>()
    UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
    UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    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.3/api/UnityEngine.XR.Interaction.Toolkit.XRRayInteractor.html")]
    public class XRRayInteractor : XRBaseControllerInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, 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

    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

    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
    anchorRotationMode

    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)
    RotateAnchor(Transform, Vector2, Quaternion)

    anchorRotationMode

    Gets or sets how the anchor rotation is controlled.

    Declaration
    public XRRayInteractor.AnchorRotationMode anchorRotationMode { get; set; }
    Property Value
    Type Description
    XRRayInteractor.AnchorRotationMode
    See Also
    allowAnchorControl
    XRRayInteractor.AnchorRotationMode

    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

    autoDeselect

    Whether this Interactor will automatically deselect an Interactable after selecting it via hover for a period of time.

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

    This only applies when an interactable is selected due to hoverToSelect.

    See Also
    timeToAutoDeselect

    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

    currentNearestValidTarget

    The nearest IXRInteractable object hit by the ray that was inserted into the valid targets list when not selecting anything.

    Declaration
    protected IXRInteractable currentNearestValidTarget { get; }
    Property Value
    Type Description
    IXRInteractable
    Remarks

    Updated during PreprocessInteractor(XRInteractionUpdateOrder.UpdatePhase).

    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

    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 XRRayInteractor.QuerySnapVolumeInteraction raycastSnapVolumeInteraction { get; set; }
    Property Value
    Type Description
    XRRayInteractor.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

    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 when anchorRotationMode is set to RotateOverTime.

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

    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

    timeToAutoDeselect

    Number of seconds for which this Interactor will keep an Interactable selected before automatically deselecting it.

    Declaration
    public float timeToAutoDeselect { get; set; }
    Property Value
    Type Description
    Single
    Remarks

    This only applies when an interactable is selected due to hoverToSelect.

    See Also
    hoverToSelect

    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

    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)

    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)

    GetHoverTimeToSelect(IXRInteractable)

    Gets the number of seconds for which this interactor must hover over the interactable to select it if hoverToSelect is enabled.

    Declaration
    protected virtual float GetHoverTimeToSelect(IXRInteractable interactable)
    Parameters
    Type Name Description
    IXRInteractable interactable

    The interactable to get the duration for.

    Returns
    Type Description
    Single

    Returns the number of seconds for which this Interactor must hover over an Interactable to select it.

    See Also
    hoverTimeToSelect

    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)

    GetTimeToAutoDeselect(IXRInteractable)

    Gets the number of seconds for which this interactor will keep the interactable selected before automatically deselecting it.

    Declaration
    protected virtual float GetTimeToAutoDeselect(IXRInteractable interactable)
    Parameters
    Type Name Description
    IXRInteractable interactable

    The interactable to get the duration for.

    Returns
    Type Description
    Single

    Returns the number of seconds for which this Interactor will keep an Interactable selected before automatically deselecting it.

    See Also
    timeToAutoDeselect

    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 currently 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 or containing IXRInteractionGroup 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 or containing IXRInteractionGroup 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.

    RotateAnchor(Transform, Vector2, Quaternion)

    Rotates the attach anchor for this interactor to match a given direction. This can be useful to compute a direction angle for teleportation.

    Declaration
    protected virtual void RotateAnchor(Transform anchor, Vector2 direction, Quaternion referenceRotation)
    Parameters
    Type Name Description
    Transform anchor

    The attach transform of the interactor.

    Vector2 direction

    The directional input.

    Quaternion referenceRotation

    The reference rotation to define the up axis for rotation.

    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)

    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

    XRGroupMemberExtensions.GetTopLevelContainingGroup(IXRGroupMember)
    XRHoverInteractorExtensions.GetOldestInteractableHovered(IXRHoverInteractor)
    XRInteractorExtensions.IsBlockedByInteractionWithinGroup(IXRInteractor)
    XRSelectInteractorExtensions.GetOldestInteractableSelected(IXRSelectInteractor)
    Back to top
    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