docs.unity.cn
Search Results for

    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
    XRBaseInputInteractor
    XRRayInteractor
    XRGazeInteractor
    Implements
    IXRHoverInteractor
    IXRSelectInteractor
    IXRTargetPriorityInteractor
    IXRGroupMember
    IXRInteractionStrengthInteractor
    IXRActivateInteractor
    IXRInteractor
    IAdvancedLineRenderable
    ILineRenderable
    IUIHoverInteractor
    IUIInteractor
    IXRRayProvider
    IXRScaleValueProvider
    Inherited Members
    XRBaseInputInteractor.forceDeprecatedInput
    XRBaseInputInteractor.selectInput
    XRBaseInputInteractor.activateInput
    XRBaseInputInteractor.selectActionTrigger
    XRBaseInputInteractor.allowHoveredActivate
    XRBaseInputInteractor.targetPriorityMode
    XRBaseInputInteractor.allowActivate
    XRBaseInputInteractor.shouldActivate
    XRBaseInputInteractor.shouldDeactivate
    XRBaseInputInteractor.logicalSelectState
    XRBaseInputInteractor.logicalActivateState
    XRBaseInputInteractor.buttonReaders
    XRBaseInputInteractor.valueReaders
    XRBaseInputInteractor.SetInputProperty(ref XRInputButtonReader, XRInputButtonReader)
    XRBaseInputInteractor.SetInputProperty<TValue>(ref XRInputValueReader<TValue>, XRInputValueReader<TValue>)
    XRBaseInputInteractor.GetActivateTargets(List<IXRActivateInteractable>)
    XRBaseInputInteractor.SendHapticImpulse(float, float)
    XRBaseInputInteractor.PlayAudio(AudioClip)
    XRBaseInputInteractor.OnHoverEntering(HoverEnterEventArgs)
    XRBaseInputInteractor.OnHoverExiting(HoverExitEventArgs)
    XRBaseInteractor.registered
    XRBaseInteractor.unregistered
    XRBaseInteractor.interactionManager
    XRBaseInteractor.containingGroup
    XRBaseInteractor.interactionLayers
    XRBaseInteractor.handedness
    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.CreateAttachTransform()
    XRBaseInteractor.GetInteractionStrength(IXRInteractable)
    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)
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Assembly: solution.dll
    Syntax
    [DisallowMultipleComponent]
    [AddComponentMenu("XR/XR Ray Interactor", 11)]
    [HelpURL("https://docs.unity.cn/Packages/com.unity.xr.interaction.toolkit@3.0/api/UnityEngine.XR.Interaction.Toolkit.XRRayInteractor.html")]
    public class XRRayInteractor : XRBaseInputInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRActivateInteractor, IXRInteractor, IAdvancedLineRenderable, ILineRenderable, IUIHoverInteractor, IUIInteractor, IXRRayProvider, IXRScaleValueProvider

    Properties

    Name Description
    acceleration

    Gravity of the projectile in the reference frame.

    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.

    additionalGroundHeight

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

    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.

    autoDeselect

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

    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.

    blockUIOnInteractableSelection

    Enabling this option will block UI interaction when selecting interactables.

    coneCastAngle

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

    controlPointDistance

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

    controlPointHeight

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

    currentNearestValidTarget

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

    directionalManipulationInput

    Input to use for rotating the attach point to match the direction of the input. This effectively rotates the selected grab interactable or teleport target to match the direction of the input.

    enableARRaycasting

    Gets or sets whether this interactor is able to raycast against AR environment trackables.

    enableUIInteraction

    Enable to affect Unity UI GameObjects in a way that is similar to a mouse pointer. Requires the XR UI Input Module on the Event System.

    endPointDistance

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

    endPointHeight

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

    hitClosestOnly

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

    hitDetectionType

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

    hoverTimeToSelect

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

    hoverToSelect

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

    isSelectActive

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

    lineType

    Gets or sets the type of ray cast.

    manipulateAttachTransform

    Allows the user to move the Attach Transform using the thumbstick.

    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.

    occludeARHitsWith2DObjects

    Gets or sets whether AR raycast hits will be occluded by 2D world space objects such as UI.

    occludeARHitsWith3DObjects

    Gets or sets whether AR raycast hits will be occluded by 3D objects.

    rayEndPoint

    The last endpoint of this ray, either its maximum distance or a collision point.

    rayEndTransform

    The Transform of the object this ray has collided with, if any.

    rayOriginTransform

    The starting position and direction of any ray casts.

    raycastMask

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

    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.

    raycastTriggerInteraction

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

    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.

    rotateManipulationInput

    Input to use for rotating the attach point over time. This effectively rotates the selected grab interactable while the input is pushed in either direction.

    rotateMode

    How the Attach Transform rotation manipulation is controlled.

    rotateReferenceFrame

    The optional reference frame to define the up axis when rotating the Attach Transform. When not set, rotates about the local up axis of the Attach Transform.

    rotateSpeed

    Speed that the Attach Transform is rotated when rotateMode is set to RotateOverTime.

    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.

    scaleDistanceDeltaInput

    The input to use for providing a scale value to grab transformers for scaling based on a distance delta from last frame. This input is typically used for scaling with a pinch gesture on mobile AR.

    scaleMode

    Property representing the scale mode that is supported by the implementation of the interface.

    scaleOverTimeInput

    The input to use for providing a scale value to grab transformers for scaling over time. This effectively scales the selected grab interactable while the input is pushed in either direction.

    scaleToggleInput

    The input to use for toggling between Attach Transform manipulation modes to either scale or translate/rotate.

    scaleValue

    This is the current scale value for the specified scale mode. This value should be updated by the implementing class when other inputs are handled during the standard interaction processing loop.

    sphereCastRadius

    Gets or sets radius used for sphere casting.

    timeToAutoDeselect

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

    trackableType

    The ARTrackable types that will taken into consideration with the performed ARRaycast.

    translateManipulationInput

    Input to use for translating the attach point closer or further away from the interactor. This effectively moves the selected grab interactable along the ray.

    translateSpeed

    Speed that the Attach Transform is translated along the ray.

    uiHoverEntered

    The event that is called when the Interactor begins hovering over a UI element.

    uiHoverExited

    The event that is called when this Interactor ends hovering over a UI element.

    uiPressInput

    Input to use for pressing UI elements. Functions like a mouse button when pointing over UI.

    uiScrollInput

    Input to use for scrolling UI elements. Functions like a mouse scroll wheel when pointing over UI.

    useForceGrab

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

    velocity

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

    Methods

    Name Description
    Awake()

    See MonoBehaviour.

    CanHover(IXRHoverInteractable)

    Determines if the Interactable is valid for hover this frame.

    CanSelect(IXRSelectInteractable)

    Determines if the Interactable is valid for selection this frame.

    GetHoverTimeToSelect(IXRInteractable)

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

    GetLineOriginAndDirection(out Vector3, out Vector3)

    Gets the line origin and direction. Origin and Direction are in world space coordinates.

    GetLinePoints(ref NativeArray<Vector3>, out int, Ray?)

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

    GetLinePoints(ref Vector3[], out int)

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

    GetTimeToAutoDeselect(IXRInteractable)

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

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

    IsOverUIGameObject()

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

    OnDisable()

    See MonoBehaviour.

    OnDrawGizmosSelected()

    See MonoBehaviour.

    OnEnable()

    See MonoBehaviour.

    OnSelectEntering(SelectEnterEventArgs)

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

    OnSelectExiting(SelectExitEventArgs)

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

    OnUIHoverEntered(UIHoverEventArgs)

    The XRUIInputModule calls this method when the Interactor begins hovering over a UI element.

    OnUIHoverExited(UIHoverEventArgs)

    The XRUIInputModule calls this method when the Interactor ends hovering over a UI element.

    OnValidate()

    See MonoBehaviour.

    PreprocessInteractor(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.

    ProcessInteractor(UpdatePhase)

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

    RotateAttachTransform(Transform, float)

    Rotates the Attach Transform for this interactor. This can be useful to rotate a held object.

    RotateAttachTransform(Transform, Vector2, Quaternion)

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

    TranslateAttachTransform(Transform, Transform, float)

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

    TryGetCurrent3DRaycastHit(out RaycastHit)

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

    TryGetCurrent3DRaycastHit(out RaycastHit, out int)

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

    TryGetCurrentARRaycastHit(out ARRaycastHit)
    TryGetCurrentARRaycastHit(out ARRaycastHit, out int)

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

    TryGetCurrentRaycast(out RaycastHit?, out int, out RaycastResult?, out int, out bool)

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

    TryGetCurrentRaycast(out RaycastHit?, out int, out RaycastResult?, out int, out bool, out ARRaycastHit?, out int, out bool)

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

    TryGetCurrentUIRaycastResult(out RaycastResult)

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

    TryGetCurrentUIRaycastResult(out RaycastResult, out int)

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

    TryGetHitInfo(out Vector3, out Vector3, out int, out bool)

    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.

    TryGetUIModel(out TrackedDeviceModel)

    Attempts to retrieve the current UI Model.

    UpdateUIModel(ref TrackedDeviceModel)

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

    Extension Methods

    XRGroupMemberExtensions.GetTopLevelContainingGroup(IXRGroupMember)
    XRHoverInteractorExtensions.GetOldestInteractableHovered(IXRHoverInteractor)
    XRInteractorExtensions.IsBlockedByInteractionWithinGroup(IXRInteractor)
    XRSelectInteractorExtensions.GetOldestInteractableSelected(IXRSelectInteractor)
    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)