Script used to make Unity UI interactable in VRChat. Requires a Unity UICanvas element on the same GameObject.
- Add a Canvas using the right-click menu in your hierarchy.
- Add a
VRC_UIShapecomponent to the Canvas.
- Set the Canvas Render Mode to World Space.
- Reduce the
zscale of the Canvas. Usually somewhere between
0.005will work well. This is the size in meters of a single pixel on the canvas.
- Set the Canvas GameObject layer to Default
- Add your UI elements to the Canvas
- The canvas must have a
VRC_UIShapecomponent on it
- The layer of the Canvas cannot be UI. Setting the canvas and all it's children to default will work.
- The object with the
VRC_UIShapemust have a box collider. If there is none, one will be added automatically after the world is uploaded. However if you have added a collider yourself, you must make sure that it is the correct size.
- The scene must have an EventSystem. This is added automatically when you make the canvas, so don't delete it.
- Make sure that interact-able elements are not covered by invisible elements. This often happens when a text box overlaps and covers a button. There's a few solutions: You can rearrange the button so it is on top (lower in the hierarchy), you can resize the text so that it does not cover the button, or you can set the text's "raycast target" to
- Some UI events get removed in VRChat for security reasons. Make sure that the events you are trying to use are on this list
- If you are using
SendCustomEvent, make sure to type the event exactly the same both in the UI button and in the UdonBehaviour's
- If something is wrong with an UdonBehaviour, it might halt which will stop it from doing anything. See this documentation for more details
Updated 9 months ago
Did this page help you?