docs.unity3d.com
    Show / Hide Table of Contents

    Class XRSocketInteractor

    Interactor used for holding interactables via a socket. This component is not designed to be attached to a controller (thus does not derive from XRBaseControllerInteractor) and instead will always attempt to select an interactable that it is hovering over (though will not perform exclusive selection of that interactable).

    Inheritance
    Object
    XRBaseInteractor
    XRSocketInteractor
    Inherited Members
    XRBaseInteractor.registered
    XRBaseInteractor.unregistered
    XRBaseInteractor.interactionManager
    XRBaseInteractor.interactionLayerMask
    XRBaseInteractor.attachTransform
    XRBaseInteractor.startingSelectedInteractable
    XRBaseInteractor.hoverEntered
    XRBaseInteractor.hoverExited
    XRBaseInteractor.selectEntered
    XRBaseInteractor.selectExited
    XRBaseInteractor.allowHover
    XRBaseInteractor.allowSelect
    XRBaseInteractor.isPerformingManualInteraction
    XRBaseInteractor.selectTarget
    XRBaseInteractor.hoverTargets
    XRBaseInteractor.Reset()
    XRBaseInteractor.OnEnable()
    XRBaseInteractor.OnDisable()
    XRBaseInteractor.Start()
    XRBaseInteractor.OnDestroy()
    XRBaseInteractor.GetHoverTargets(List<XRBaseInteractable>)
    XRBaseInteractor.OnHoverEntered(HoverEnterEventArgs)
    XRBaseInteractor.OnHoverExited(HoverExitEventArgs)
    XRBaseInteractor.OnSelectEntering(SelectEnterEventArgs)
    XRBaseInteractor.OnSelectEntered(SelectEnterEventArgs)
    XRBaseInteractor.OnSelectExited(SelectExitEventArgs)
    XRBaseInteractor.StartManualInteraction(XRBaseInteractable)
    XRBaseInteractor.EndManualInteraction()
    XRBaseInteractor.enableInteractions
    XRBaseInteractor.onHoverEntered
    XRBaseInteractor.onHoverExited
    XRBaseInteractor.onSelectEntered
    XRBaseInteractor.onSelectExited
    XRBaseInteractor.onHoverEnter
    XRBaseInteractor.onHoverExit
    XRBaseInteractor.onSelectEnter
    XRBaseInteractor.onSelectExit
    XRBaseInteractor.OnHoverEntering(XRBaseInteractable)
    XRBaseInteractor.OnHoverEntered(XRBaseInteractable)
    XRBaseInteractor.OnHoverExiting(XRBaseInteractable)
    XRBaseInteractor.OnHoverExited(XRBaseInteractable)
    XRBaseInteractor.OnSelectEntering(XRBaseInteractable)
    XRBaseInteractor.OnSelectEntered(XRBaseInteractable)
    XRBaseInteractor.OnSelectExiting(XRBaseInteractable)
    XRBaseInteractor.OnSelectExited(XRBaseInteractable)
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    public class XRSocketInteractor : XRBaseInteractor

    Properties

    interactableCantHoverMeshMaterial

    Material used for rendering interactable meshes on hover when there is already a selected object in the socket (a default material will be created if none is supplied).

    Declaration
    public Material interactableCantHoverMeshMaterial { get; set; }
    Property Value
    Type Description
    Material

    interactableHoverMeshMaterial

    Material used for rendering interactable meshes on hover (a default material will be created if none is supplied).

    Declaration
    public Material interactableHoverMeshMaterial { get; set; }
    Property Value
    Type Description
    Material

    interactableHoverScale

    Scale at which to render hovered interactable.

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

    isHoverActive

    (Read Only) Indicates whether this interactor is in a state where it could hover (always true for sockets if active).

    Declaration
    public override bool isHoverActive { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    XRBaseInteractor.isHoverActive

    isSelectActive

    (Read Only) Indicates whether this interactor is in a state where it could select (always true for sockets if active).

    Declaration
    public override bool isSelectActive { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    XRBaseInteractor.isSelectActive

    recycleDelayTime

    Sets the amount of time the socket will refuse hovers after an object is removed.

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

    requireSelectExclusive

    (Read Only) Indicates whether this interactor requires exclusive selection of an interactable (always true for sockets).

    Declaration
    public override bool requireSelectExclusive { get; }
    Property Value
    Type Description
    Boolean
    Overrides
    XRBaseInteractor.requireSelectExclusive

    selectedInteractableMovementTypeOverride

    (Read Only) Overriding movement type of the selected Interactable's movement. By default, this does not override the movement type.

    Declaration
    public override XRBaseInteractable.MovementType? selectedInteractableMovementTypeOverride { get; }
    Property Value
    Type Description
    Nullable<XRBaseInteractable.MovementType>
    Overrides
    XRBaseInteractor.selectedInteractableMovementTypeOverride
    Remarks

    This can be used to change the effective movement type of an Interactable for different Interactors. An example would be having an Interactable use VelocityTracking so it does not move through geometry with a Collider when interacting with it using a Ray or Direct Interactor, but have a Socket Interactor override the movement type to be Instantaneous for reduced movement latency.

    See Also
    movementType

    showInteractableHoverMeshes

    Whether this socket should show a mesh at socket's attach point for interactables that it is hovering over.

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

    socketActive

    Whether socket interaction is enabled.

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

    Methods

    Awake()

    See .

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

    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

    Returns true if the interactable can be hovered over this frame.

    Overrides
    XRBaseInteractor.CanHover(XRBaseInteractable)
    See Also
    IsHoverableBy(XRBaseInteractor)

    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

    Returns true if the interactable can be selected this frame.

    Overrides
    XRBaseInteractor.CanSelect(XRBaseInteractable)
    See Also
    IsSelectableBy(XRBaseInteractor)

    CreateDefaultHoverMaterials()

    Create the default hover materials for interactableHoverMeshMaterial and interactableCantHoverMeshMaterial if necessary.

    Declaration
    protected virtual void CreateDefaultHoverMaterials()

    DrawHoveredInteractables()

    This method is called automatically in order to draw the interactables that are currently being hovered over.

    Declaration
    protected virtual void DrawHoveredInteractables()

    GetValidTargets(List<XRBaseInteractable>)

    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<XRBaseInteractable> targets)
    Parameters
    Type Name Description
    List<XRBaseInteractable> targets

    The results list to populate with Interactables that are valid for selection or hover.

    Overrides
    XRBaseInteractor.GetValidTargets(List<XRBaseInteractable>)

    OnHoverEntering(HoverEnterEventArgs)

    This method is called by the Interaction Manager right before the Interactor first initiates hovering over an Interactable in a first pass.

    Declaration
    protected override void OnHoverEntering(HoverEnterEventArgs args)
    Parameters
    Type Name Description
    HoverEnterEventArgs args

    Event data containing the Interactable that is being hovered over.

    Overrides
    XRBaseInteractor.OnHoverEntering(HoverEnterEventArgs)
    Remarks

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

    See Also
    OnHoverEntered(HoverEnterEventArgs)

    OnHoverExiting(HoverExitEventArgs)

    This method is called by the Interaction Manager right before the Interactor ends hovering over an Interactable in a first pass.

    Declaration
    protected override void OnHoverExiting(HoverExitEventArgs args)
    Parameters
    Type Name Description
    HoverExitEventArgs args

    Event data containing the Interactable that is no longer hovered over.

    Overrides
    XRBaseInteractor.OnHoverExiting(HoverExitEventArgs)
    Remarks

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

    See Also
    OnHoverExited(HoverExitEventArgs)

    OnRegistered(InteractorRegisteredEventArgs)

    This method is called by the Interaction Manager when this Interactor is registered with it.

    Declaration
    protected override void OnRegistered(InteractorRegisteredEventArgs args)
    Parameters
    Type Name Description
    InteractorRegisteredEventArgs args

    Event data containing the Interaction Manager that registered this Interactor.

    Overrides
    XRBaseInteractor.OnRegistered(InteractorRegisteredEventArgs)
    Remarks

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

    See Also
    RegisterInteractor(XRBaseInteractor)

    OnSelectExiting(SelectExitEventArgs)

    This method is called by the Interaction Manager 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
    XRBaseInteractor.OnSelectExiting(SelectExitEventArgs)
    Remarks

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

    See Also
    OnSelectExited(SelectExitEventArgs)

    OnTriggerEnter(Collider)

    See .

    Declaration
    protected void OnTriggerEnter(Collider other)
    Parameters
    Type Name Description
    Collider other

    The other involved in this collision.

    OnTriggerExit(Collider)

    See .

    Declaration
    protected void OnTriggerExit(Collider other)
    Parameters
    Type Name Description
    Collider other

    The other involved in this collision.

    OnUnregistered(InteractorUnregisteredEventArgs)

    This method is called by the Interaction Manager when this Interactor is unregistered from it.

    Declaration
    protected override void OnUnregistered(InteractorUnregisteredEventArgs args)
    Parameters
    Type Name Description
    InteractorUnregisteredEventArgs args

    Event data containing the Interaction Manager that unregistered this Interactor.

    Overrides
    XRBaseInteractor.OnUnregistered(InteractorUnregisteredEventArgs)
    Remarks

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

    See Also
    UnregisterInteractor(XRBaseInteractor)

    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 override void ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase updatePhase)
    Parameters
    Type Name Description
    XRInteractionUpdateOrder.UpdatePhase updatePhase

    The update phase this is called during.

    Overrides
    XRBaseInteractor.ProcessInteractor(XRInteractionUpdateOrder.UpdatePhase)

    ShouldDrawHoverMesh(MeshFilter, Renderer, Camera)

    This method is called automatically in order to determine whether the Mesh should be drawn.

    Declaration
    protected virtual bool ShouldDrawHoverMesh(MeshFilter meshFilter, Renderer meshRenderer, Camera mainCamera)
    Parameters
    Type Name Description
    MeshFilter meshFilter

    The which will be drawn when returning true.

    Renderer meshRenderer

    The on the same as the meshFilter.

    Camera mainCamera

    The Main Camera.

    Returns
    Type Description
    Boolean

    Returns true if the Mesh should be drawn. Otherwise, returns false.

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