Class XRBaseInteractor | XR Interaction Toolkit | 0.10.0-preview.7
docs.unity3d.com
    Show / Hide Table of Contents

    Class XRBaseInteractor

    Abstract base class from which all interactor behaviours derive. This class hooks into the interaction system (via XRInteractionManager) and provides base virtual methods for handling hover and selection.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRBaseInteractor
    XRBaseControllerInteractor
    XRSocketInteractor
    Inherited Members
    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
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [SelectionBase]
    [DisallowMultipleComponent]
    [DefaultExecutionOrder(-99)]
    public abstract class XRBaseInteractor : MonoBehaviour

    Properties

    allowHover

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

    allowSelect

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

    attachTransform

    The attach transform that is used as an attach point for interactables.

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

    Automatically instantiated and set in Awake(). Setting this will not automatically destroy the previous object.

    enableInteractions

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

    hoverTargets

    Target interactables that are currently being hovered over (may by empty).

    Declaration
    protected List<XRBaseInteractable> hoverTargets { get; }
    Property Value
    Type Description
    List<XRBaseInteractable>

    interactionLayerMask

    Only interactables with this layer mask will respond to this interactor.

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

    interactionManager

    The XRInteractionManager that this interactor will communicate with.

    Declaration
    public XRInteractionManager interactionManager { get; set; }
    Property Value
    Type Description
    XRInteractionManager

    isHoverActive

    (Read Only) Indicates whether this interactor is in a state where it could hover.

    Declaration
    public virtual bool isHoverActive { get; }
    Property Value
    Type Description
    Boolean

    isPerformingManualInteraction

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

    isSelectActive

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

    Declaration
    public virtual bool isSelectActive { get; }
    Property Value
    Type Description
    Boolean

    onHoverEnter

    Declaration
    [Obsolete("onHoverEnter has been deprecated. Use onHoverEntered instead. (UnityUpgradable) -> onHoverEntered")]
    public XRInteractorEvent onHoverEnter { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onHoverEntered

    Gets or sets the event that is called when this interactor begins hovering over an interactable.

    Declaration
    public XRInteractorEvent onHoverEntered { get; set; }
    Property Value
    Type Description
    XRInteractorEvent

    onHoverExit

    Declaration
    [Obsolete("onHoverExit has been deprecated. Use onHoverExited instead. (UnityUpgradable) -> onHoverExited")]
    public XRInteractorEvent onHoverExit { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onHoverExited

    Gets or sets the event that is called when this interactor stops hovering over an interactable.

    Declaration
    public XRInteractorEvent onHoverExited { get; set; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectEnter

    Declaration
    [Obsolete("onSelectEnter has been deprecated. Use onSelectEntered instead. (UnityUpgradable) -> onSelectEntered")]
    public XRInteractorEvent onSelectEnter { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectEntered

    Gets or sets the event that is called when this interactor begins selecting an interactable.

    Declaration
    public XRInteractorEvent onSelectEntered { get; set; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectExit

    Declaration
    [Obsolete("onSelectExit has been deprecated. Use onSelectExited instead. (UnityUpgradable) -> onSelectExited")]
    public XRInteractorEvent onSelectExit { get; }
    Property Value
    Type Description
    XRInteractorEvent

    onSelectExited

    Gets or sets the event that is called when this interactor stops selecting an interactable.

    Declaration
    public XRInteractorEvent onSelectExited { get; set; }
    Property Value
    Type Description
    XRInteractorEvent

    requireSelectExclusive

    (Read Only) Indicates whether this interactor requires exclusive selection of an interactable.

    Declaration
    public virtual bool requireSelectExclusive { get; }
    Property Value
    Type Description
    Boolean
    Remarks

    That is, this interactor will only be selected if exactly one interactor is trying to select it.

    selectedInteractableMovementTypeOverride

    (Read Only) Overriding movement type of the selected interactable's movement.

    Declaration
    public virtual XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride { get; }
    Property Value
    Type Description
    Nullable<XRBaseInteractable.MovementType>

    selectTarget

    Selected interactable for this interactor (may be null).

    Declaration
    public XRBaseInteractable selectTarget { get; protected set; }
    Property Value
    Type Description
    XRBaseInteractable

    startingSelectedInteractable

    The initial interactable that is selected by this interactor at startup (optional, may be null).

    Declaration
    public XRBaseInteractable startingSelectedInteractable { get; set; }
    Property Value
    Type Description
    XRBaseInteractable

    Methods

    Awake()

    Declaration
    protected virtual void Awake()

    CanHover(XRBaseInteractable)

    Determines if the interactable is valid for hover this frame.

    Declaration
    public virtual 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.

    CanSelect(XRBaseInteractable)

    Determines if the interactable is valid for selection this frame.

    Declaration
    public virtual 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.

    EndManualInteraction()

    Ends the manually initiated selection of an interactable.

    Declaration
    public virtual void EndManualInteraction()
    See Also
    StartManualInteraction(XRBaseInteractable)

    GetHoverTargets(List<XRBaseInteractable>)

    Retrieves a copy of the list of target interactables that are currently being hovered over.

    Declaration
    public void GetHoverTargets(List<XRBaseInteractable> targets)
    Parameters
    Type Name Description
    List<XRBaseInteractable> targets

    The list to store hover targets into.

    Remarks

    Clears targets before adding to it.

    GetValidTargets(List<XRBaseInteractable>)

    Retrieve the list of interactables that this interactor could possibly interact with this frame.

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

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

    OnDestroy()

    Declaration
    protected virtual void OnDestroy()

    OnDisable()

    Declaration
    protected virtual void OnDisable()

    OnEnable()

    Declaration
    protected virtual void OnEnable()

    OnHoverEntered(XRBaseInteractable)

    This method is called by the interaction manager when the interactor first initiates hovering over an interactable.

    Declaration
    protected virtual void OnHoverEntered(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being hovered over.

    See Also
    OnHoverExited(XRBaseInteractable)

    OnHoverEntering(XRBaseInteractable)

    This method is called by the interaction manager right before the interactor first initiates hovering over an interactable.

    Declaration
    protected virtual void OnHoverEntering(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being hovered over.

    See Also
    OnHoverEntered(XRBaseInteractable)

    OnHoverExited(XRBaseInteractable)

    This method is called by the interaction manager when the interactor ends hovering over an interactable.

    Declaration
    protected virtual void OnHoverExited(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer hovered over.

    See Also
    OnHoverEntered(XRBaseInteractable)

    OnHoverExiting(XRBaseInteractable)

    This method is called by the interaction manager right before the interactor ends hovering over an interactable.

    Declaration
    protected virtual void OnHoverExiting(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer hovered over.

    See Also
    OnHoverExited(XRBaseInteractable)

    OnSelectEntered(XRBaseInteractable)

    This method is called by the interaction manager when the interactor first initiates selection of an interactable.

    Declaration
    protected virtual void OnSelectEntered(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    OnSelectExited(XRBaseInteractable)

    OnSelectEntering(XRBaseInteractable)

    This method is called by the interaction manager right before the first initiates selection of an interactable.

    Declaration
    protected virtual void OnSelectEntering(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    OnSelectEntered(XRBaseInteractable)

    OnSelectExited(XRBaseInteractable)

    This method is called by the interaction manager when the interactor ends selection of an interactable.

    Declaration
    protected virtual void OnSelectExited(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer selected.

    See Also
    OnSelectEntered(XRBaseInteractable)

    OnSelectExiting(XRBaseInteractable)

    This method is called by the interaction manager right before the interactor ends selection of an interactable.

    Declaration
    protected virtual void OnSelectExiting(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is no longer selected.

    See Also
    OnSelectExited(XRBaseInteractable)

    ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    This method is called by the interaction manager to update the interactor. Please see the interaction manager documentation for more details on update order.

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

    Reset()

    Declaration
    [Conditional("UNITY_EDITOR")]
    protected virtual void Reset()

    Start()

    Declaration
    protected virtual void Start()

    StartManualInteraction(XRBaseInteractable)

    Manually initiate selection of an interactable.

    Declaration
    public virtual void StartManualInteraction(XRBaseInteractable interactable)
    Parameters
    Type Name Description
    XRBaseInteractable interactable

    Interactable that is being selected.

    See Also
    EndManualInteraction()
    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