2d UI elements in 3d world. How to make them interactive?

Godot Version

4.3

Question

I created a UI button in a 3d world on the screen using sprite3d with ViewportTexture and SubViewport.
Everything works fine, but I can’t interact with these buttons in any way. Clicking with the mouse does nothing. The texture only displays the UI elements, but does not allow interaction with them. Can anyone tell me how I can fix this?

You need to forward the input events from the main viewport of the 3D-scene to the SubViewport.
Have a look at the Gui in 3D Demo project, which demonstrates this use-case.
Link to the Source on Github
Link to the Asset Library

1 Like