docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IXRFocusInteractable

    An interface that represents an Interactable component which an Interactor component can persistently select.

    Inherited Members
    IXRInteractable.registered
    IXRInteractable.unregistered
    IXRInteractable.interactionLayers
    IXRInteractable.colliders
    IXRInteractable.transform
    IXRInteractable.GetAttachTransform(IXRInteractor)
    IXRInteractable.OnRegistered(InteractableRegisteredEventArgs)
    IXRInteractable.OnUnregistered(InteractableUnregisteredEventArgs)
    IXRInteractable.ProcessInteractable(XRInteractionUpdateOrder.UpdatePhase)
    IXRInteractable.GetDistanceSqrToInteractor(IXRInteractor)
    Namespace: UnityEngine.XR.Interaction.Toolkit.Interactables
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [MovedFrom("UnityEngine.XR.Interaction.Toolkit")]
    public interface IXRFocusInteractable : IXRInteractable

    Properties

    canFocus

    Indicates whether this Interactable can be focused.

    Declaration
    bool canFocus { get; }
    Property Value
    Type Description
    bool

    firstFocusEntered

    The event that is called only when the first Interaction Group gains focus on this Interactable as the sole focusing Interactor. Subsequent Interactors that gain focus will not cause this event to be invoked as long as any others are still focusing.

    Declaration
    FocusEnterEvent firstFocusEntered { get; }
    Property Value
    Type Description
    FocusEnterEvent
    Remarks

    The FocusEnterEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    lastFocusExited
    focusEntered

    firstInteractionGroupFocusing

    (Read Only) The first interaction group that is focused on this interactable since not being focused. The group may not currently be focusing this interactable, which would be the case when it released while multiple groups were focusing this interactable.

    Declaration
    IXRInteractionGroup firstInteractionGroupFocusing { get; }
    Property Value
    Type Description
    IXRInteractionGroup

    focusEntered

    The event that is called when an Interaction group gains focus on this Interactable.

    Declaration
    FocusEnterEvent focusEntered { get; }
    Property Value
    Type Description
    FocusEnterEvent
    Remarks

    The FocusEnterEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    focusExited

    focusExited

    The event that is called when an Interaction group loses focus on this Interactable.

    Declaration
    FocusExitEvent focusExited { get; }
    Property Value
    Type Description
    FocusExitEvent
    Remarks

    The FocusExitEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    focusEntered

    focusMode

    Indicates the focus policy of an Interactable.

    Declaration
    InteractableFocusMode focusMode { get; }
    Property Value
    Type Description
    InteractableFocusMode
    See Also
    InteractableFocusMode

    interactionGroupsFocusing

    (Read Only) The list of Interaction groups currently focusing on this Interactable (may by empty).

    Declaration
    List<IXRInteractionGroup> interactionGroupsFocusing { get; }
    Property Value
    Type Description
    List<IXRInteractionGroup>
    Remarks

    You should treat this as a read only view of the list and should not modify it. It is exposed as a List<T> rather than an IReadOnlyList<T> to avoid GC Allocations when enumerating the list.

    See Also
    isFocused

    isFocused

    (Read Only) Indicates whether this interactable is currently being focused by any interaction group.

    Declaration
    bool isFocused { get; }
    Property Value
    Type Description
    bool
    Remarks

    In other words, returns whether interactionGroupsFocusing contains any interaction groups.

    Examples
    interactionGroupsFocusing.Count > 0
    See Also
    interactionGroupsFocusing

    lastFocusExited

    The event that is called only when the last remaining focused Interaction group loses focus on this Interactable.

    Declaration
    FocusExitEvent lastFocusExited { get; }
    Property Value
    Type Description
    FocusExitEvent
    Remarks

    The FocusExitEventArgs passed to each listener is only valid while the event is invoked, do not hold a reference to it.

    See Also
    firstFocusEntered
    focusExited

    Methods

    OnFocusEntered(FocusEnterEventArgs)

    The XRInteractionManager calls this method when the Interaction group first gains focus of an Interactable in a second pass.

    Declaration
    void OnFocusEntered(FocusEnterEventArgs args)
    Parameters
    Type Name Description
    FocusEnterEventArgs args

    Event data containing the Interaction group that is initiating the focus.

    Remarks

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

    See Also
    OnFocusExited(FocusExitEventArgs)

    OnFocusEntering(FocusEnterEventArgs)

    The XRInteractionManager calls this method right before the Interaction group first gains focus of an Interactable in a first pass.

    Declaration
    void OnFocusEntering(FocusEnterEventArgs args)
    Parameters
    Type Name Description
    FocusEnterEventArgs args

    Event data containing the Interaction group that is initiating the focus.

    Remarks

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

    See Also
    OnFocusEntered(FocusEnterEventArgs)

    OnFocusExited(FocusExitEventArgs)

    The XRInteractionManager calls this method when the Interaction group loses focus of an Interactable in a second pass.

    Declaration
    void OnFocusExited(FocusExitEventArgs args)
    Parameters
    Type Name Description
    FocusExitEventArgs args

    Event data containing the Interaction group that is losing focus.

    Remarks

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

    See Also
    OnFocusEntered(FocusEnterEventArgs)

    OnFocusExiting(FocusExitEventArgs)

    The XRInteractionManager calls this method right before the Interaction group loses focus of an Interactable in a first pass.

    Declaration
    void OnFocusExiting(FocusExitEventArgs args)
    Parameters
    Type Name Description
    FocusExitEventArgs args

    Event data containing the Interaction group that is losing focus.

    Remarks

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

    See Also
    OnFocusExited(FocusExitEventArgs)

    Extension Methods

    XRFocusInteractableExtensions.GetOldestInteractorFocusing(IXRFocusInteractable)
    In This Article
    Back to top
    Copyright © 2025 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)