Unity VR XR Socket Interactor - What can connect -Layer Mask
In this Unity VR XR Toolkit tutorial, I'll show how to set up an Interaction Layer Mask for the XR Socket Interactor to control what can connect and what can't connect. I'll also show adding a custom hover material. ► Art Assets - Polygon City - Low Poly https://bit.ly/3ScOYa1 My discord link ► h
By default an XR Socket Interactor is not picky: any object with an XR Grab Interactable will snap into it. This guide restricts a socket so only the intended object can attach, using XR interaction layer masks, and finishes with a custom hover material that visually signals when an object can connect.
The problem
In the demo scene, the light box is meant to attach to the light pole base's socket - and it does. But grab one of the paper balls and it sockets just as happily, which is not the design. Both objects are grab interactables sitting on the Default interaction layer, and the socket currently accepts anything on Default. Press Play and try it yourself to see the issue before fixing it.
Step 1 - Add an interaction layer
Select the light pole base and find the Interaction Layer Mask option on its XR Socket Interactor. Open the layer list - it is a long list with nothing in it beyond Default - and add a new layer called Light Socket. Note that this is the XR Interaction Toolkit's own interaction layer list, separate from Unity's regular physics layers.
Step 2 - Restrict the socket
Back on the socket interactor's Interaction Layer Mask, select Nothing first to clear it, then tick only Light Socket. This step matters: simply adding the new layer is not enough, because with Default still ticked, any game object on the default layer can still attach to the socket.
Step 3 - Match the layer on the interactable
Select the light box and find its XR Grab Interactable - the same component that makes the object grabbable also carries an Interaction Layer Mask. Change it from Default to Light Socket, again by choosing Nothing first and then selecting only Light Socket. Now the socket and the light box speak the same layer. Hit Play: the light box still attaches exactly as before, but the paper balls now refuse to connect.
Bonus - a custom hover mesh material
The XR Socket Interactor also exposes a Hover Mesh Material slot, empty by default, which controls the preview mesh shown when a valid object hovers near the socket. Any material you like can go there. This one is a URP Lit material set to Metallic with a Transparent surface, with the see-through look dialed in through the alpha of the base color. Drag it into the Hover Mesh Material slot on the light pole base and that color becomes the at-a-glance cue that the hovering object can actually interact with the socket.





