Class XRSocketInteractor
Interactor used for holding interactables via a socket.
Implements
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit
Assembly: solution.dll
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("XR/XR Socket Interactor", 11)]
[HelpURL("https://docs.unity.cn/Packages/com.unity.xr.interaction.toolkit@3.0/api/UnityEngine.XR.Interaction.Toolkit.XRSocketInteractor.html")]
public class XRSocketInteractor : XRBaseInteractor, IXRHoverInteractor, IXRSelectInteractor, IXRTargetPriorityInteractor, IXRGroupMember, IXRInteractionStrengthInteractor, IXRInteractor
Remarks
A socket is defined as the target for a specific interactable, such as a keyhole for a key
or a battery socket for a battery. Not to be confused with network programming.
This component is not designed to use input (thus does not derive from XRBaseInputInteractor)
and instead will always attempt to select an interactable that it is hovering over.
Properties
| Name | Description |
|---|---|
| ejectExistingSocketsWhenSnapping | Determines if when snapping to a socket, any existing sockets should be ejected. |
| fixedScale | Scale factor applied to the interactable when scale mode is set to Fixed. |
| hoverSocketSnapping | Determines if the interactable should snap to the socket's attach transform when hovering. Note this will cause z-fighting with the hover mesh visuals, so it is recommended to disable showInteractableHoverMeshes if this is active. If enabled, hover recycle delay functionality is disabled to prevent snap flickering. |
| 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). |
| interactableHoverMeshMaterial | Material used for rendering interactable meshes on hover (a default material will be created if none is supplied). |
| interactableHoverScale | Scale at which to render hovered Interactable. |
| isHoverActive | (Read Only) Indicates whether this Interactor is in a state where it could hover. |
| isSelectActive | (Read Only) Indicates whether this Interactor is in a state where it could select. |
| recycleDelayTime | Sets the amount of time the socket will refuse hovers after an object is removed. |
| selectedInteractableMovementTypeOverride | (Read Only) Overriding movement type of the selected Interactable's movement. By default, this does not override the movement type. |
| showInteractableHoverMeshes | Whether this socket should show a mesh at socket's attach point for Interactables that it is hovering over. |
| socketActive | Whether socket interaction is enabled. |
| socketScaleMode | Scale mode used to calculate the scale factor applied to the interactable when hovering. |
| socketSnappingLimit | Maximum number of interactables this interactor can socket. Used for hover socket snapping evaluation. |
| socketSnappingRadius | When socket snapping is enabled, this is the radius within which the interactable will snap to the socket's attach transform while hovering. |
| targetBoundsSize | Bounds size used to calculate the scale factor applied to the interactable when scale mode is set to StretchedToFitSize. |
| unsortedValidTargets | The set of Interactables that this Interactor could possibly interact with this frame. This list is not sorted by priority. |
Methods
| Name | Description |
|---|---|
| Awake() | See MonoBehaviour. |
| CanHover(IXRHoverInteractable) | Determines if the Interactable is valid for hover this frame. |
| CanHoverSnap(IXRInteractable) | Determines whether the specified IXRInteractable object can hover snap. |
| CanSelect(IXRSelectInteractable) | Determines if the Interactable is valid for selection this frame. |
| CreateDefaultHoverMaterials() | Creates the default hover materials for interactableHoverMeshMaterial and interactableCantHoverMeshMaterial if necessary. |
| DrawHoveredInteractables() | Unity calls this method automatically in order to draw the Interactables that are currently being hovered over. |
| EndSocketSnapping(XRGrabInteractable) | Ends socket snapping for a specified XRGrabInteractable object. |
| GetHoveredInteractableMaterial(IXRHoverInteractable) | Gets the material used to draw the given hovered Interactable. |
| 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). |
| OnDisable() | See MonoBehaviour. |
| OnEnable() | See MonoBehaviour. |
| OnHoverEntered(HoverEnterEventArgs) | The XRInteractionManager calls this method when the Interactor first initiates hovering over an Interactable in a second pass. |
| OnHoverEntering(HoverEnterEventArgs) | The XRInteractionManager calls this method right before the Interactor first initiates hovering over an Interactable in a first pass. |
| OnHoverExiting(HoverExitEventArgs) | The XRInteractionManager calls this method right before the Interactor ends hovering over an Interactable in a first pass. |
| OnRegistered(InteractorRegisteredEventArgs) | The XRInteractionManager calls this method when this Interactor is registered with it. |
| OnSelectEntered(SelectEnterEventArgs) | The XRInteractionManager calls this method when the Interactor first initiates selection of an Interactable in a second pass. |
| OnSelectExited(SelectExitEventArgs) | The XRInteractionManager calls this method when the Interactor ends selection of an Interactable in a second pass. |
| OnSelectExiting(SelectExitEventArgs) | The XRInteractionManager calls this method right before the Interactor ends selection of an Interactable in a first pass. |
| OnTriggerEnter(Collider) | See MonoBehaviour. |
| OnTriggerExit(Collider) | See MonoBehaviour. |
| OnTriggerStay(Collider) | See MonoBehaviour. |
| OnUnregistered(InteractorUnregisteredEventArgs) | The XRInteractionManager calls this method when this Interactor is unregistered from it. |
| OnValidate() | See MonoBehaviour. |
| ProcessInteractor(UpdatePhase) | The XRInteractionManager or containing IXRInteractionGroup calls this method to update the Interactor after interaction events occur. |
| ShouldDrawHoverMesh(MeshFilter, Renderer, Camera) | Unity calls this method automatically in order to determine whether the mesh should be drawn. |
| StartSocketSnapping(XRGrabInteractable) | Initiates socket snapping for a specified XRGrabInteractable object. |