Class XRRayInteractor | XR Interaction Toolkit | 0.0.6-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class XRRayInteractor

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

    Inheritance
    Object
    XRBaseInteractor
    XRBaseControllerInteractor
    XRRayInteractor
    Inherited Members
    XRBaseControllerInteractor.toggleSelect
    XRBaseControllerInteractor.hideControllerOnSelect
    XRBaseControllerInteractor.playAudioClipOnSelectEnter
    XRBaseControllerInteractor.AudioClipForOnSelectEnter
    XRBaseControllerInteractor.playAudioClipOnSelectExit
    XRBaseControllerInteractor.AudioClipForOnSelectExit
    XRBaseControllerInteractor.playAudioClipOnHoverEnter
    XRBaseControllerInteractor.AudioClipForOnHoverEnter
    XRBaseControllerInteractor.playAudioClipOnHoverExit
    XRBaseControllerInteractor.AudioClipForOnHoverExit
    XRBaseControllerInteractor.playHapticsOnSelectEnter
    XRBaseControllerInteractor.hapticSelectEnterIntensity
    XRBaseControllerInteractor.hapticSelectEnterDuration
    XRBaseControllerInteractor.playHapticsOnSelectExit
    XRBaseControllerInteractor.hapticSelectExitIntensity
    XRBaseControllerInteractor.hapticSelectExitDuration
    XRBaseControllerInteractor.playHapticsOnHoverEnter
    XRBaseControllerInteractor.hapticHoverEnterIntensity
    XRBaseControllerInteractor.hapticHoverEnterDuration
    XRBaseControllerInteractor.playHapticsOnHoverExit
    XRBaseControllerInteractor.hapticHoverExitIntensity
    XRBaseControllerInteractor.hapticHoverExitDuration
    XRBaseControllerInteractor.Awake()
    XRBaseControllerInteractor.isSelectActive
    XRBaseControllerInteractor.OnSelectEnter(XRBaseInteractable)
    XRBaseControllerInteractor.OnSelectExit(XRBaseInteractable)
    XRBaseControllerInteractor.OnHoverEnter(XRBaseInteractable)
    XRBaseControllerInteractor.OnHoverExit(XRBaseInteractable)
    XRBaseControllerInteractor.SendHapticImpulse(Single, Single)
    XRBaseInteractor.interactionManager
    XRBaseInteractor.InteractionLayerMask
    XRBaseInteractor.attachTransform
    XRBaseInteractor.selectTarget
    XRBaseInteractor.m_HoverTargets
    XRBaseInteractor.startingSelectedInteractable
    XRBaseInteractor.interactionLayerMask
    XRBaseInteractor.onHoverEnter
    XRBaseInteractor.onHoverExit
    XRBaseInteractor.onSelectEnter
    XRBaseInteractor.onSelectExit
    XRBaseInteractor.allowHover
    XRBaseInteractor.allowSelect
    XRBaseInteractor.enableInteractions
    XRBaseInteractor.Reset()
    XRBaseInteractor.GetHoverTargets(List<XRBaseInteractable>)
    XRBaseInteractor.isHoverActive
    XRBaseInteractor.isSelectExclusive
    XRBaseInteractor.overrideSelectedInteractableMovement
    XRBaseInteractor.selectedInteractableMovementTypeOverride
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    public class XRRayInteractor : XRBaseControllerInteractor, ILineRenderable

    Properties

    Acceleration

    Gravity of the projectile in the reference frame.

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

    AdditionalFlightTime

    Additional flight time after the projectile lands at the same height of the start point in the tracking space. Increase this value will make the end point drop lower in height.

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

    Angle

    Gets the signed angle between the controller's forward direction and the tracking space.

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

    controlPointDistance

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

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

    controlPointHeight

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

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

    endPointDistance

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

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

    endPointHeight

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

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

    hitDetectionType

    Sets which type of hit detection to use for the raycast.

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

    hoverTimeToSelect

    Gets or sets the number of seconds for which this interactor must hover over an object to select it if Hover To Select is enabled.

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

    hoverToSelect

    Gets or sets whether this uses hovering for a time period to select the interactable being hovered.

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

    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. Increase this value will let you reach further.

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

    raycastMask

    Gets or sets layer mask used for limiting raycast targets.

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

    raycastTriggerInteraction

    Gets or sets type of interaction with trigger volumes via raycast.

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

    referenceFrame

    Gets or sets the reference frame of the projectile. If not set it will try to find the XRRig object, if the XRRig does not exist it will use self. ///

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

    sampleFrequency

    Gets or sets the number of sample points of the curve, should be at least 3, the higher the better quality.

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

    sphereCastRadius

    Gets or sets radius used for spherecasting. Will use regular raycasting if set to 0.0f or less.

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

    Velocity

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

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

    Methods

    CanHover(XRBaseInteractable)

    Determines if the interactable is valid for hover this frame.

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

    Interactable to check.

    Returns
    Type Description
    Boolean

    true if the interactable can be hovered over this frame.

    Overrides
    XRBaseInteractor.CanHover(XRBaseInteractable)

    CanSelect(XRBaseInteractable)

    Determines if the interactable is valid for selection this frame.

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

    Interactable to check.

    Returns
    Type Description
    Boolean

    true if the interactable can be selected this frame.

    Overrides
    XRBaseInteractor.CanSelect(XRBaseInteractable)

    GetCurrentRaycastHit(out RaycastHit)

    This function will return the first raycast result, if any raycast results are available.

    Declaration
    public bool GetCurrentRaycastHit(out RaycastHit raycastHit)
    Parameters
    Type Name Description
    RaycastHit raycastHit

    the raycastHit result that will be filled in by this function

    Returns
    Type Description
    Boolean

    true if the raycastHit parameter contains a valid raycast result

    GetLinePoints(ref Vector3[], ref Int32)

    This function implements the ILineRenderable interface and returns the sample points of the line.

    Declaration
    public bool GetLinePoints(ref Vector3[] linePoints, ref int noPoints)
    Parameters
    Type Name Description
    Vector3[] linePoints
    Int32 noPoints
    Returns
    Type Description
    Boolean

    GetValidTargets(List<XRBaseInteractable>)

    Retrieve the list of interactables that this interactor could possibly interact with this frame. This list is sorted by priority (in this case distance).

    Declaration
    public override void GetValidTargets(List<XRBaseInteractable> validTargets)
    Parameters
    Type Name Description
    List<XRBaseInteractable> validTargets

    Populated List of interactables that are valid for selection or hover.

    Overrides
    XRBaseInteractor.GetValidTargets(List<XRBaseInteractable>)

    OnDisable()

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

    OnEnable()

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

    ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

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

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

    This function implements the ILineRenderable interface, if there is a raycast hit, it will return the world position and the normal vector of the hit point, and its position in linePoints.

    Declaration
    public bool TryGetHitInfo(ref Vector3 position, ref Vector3 normal, ref int positionInLine, ref bool isValidTarget)
    Parameters
    Type Name Description
    Vector3 position
    Vector3 normal
    Int32 positionInLine
    Boolean isValidTarget
    Returns
    Type Description
    Boolean
    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