- Home /
Interacting with a world space GUI in VR
Hey everyone,
So I'm trying to create a GUI interface for this VR app I am creating. I'm trying to use Unity's UI system and created a canvas and several buttons, all in world space as suggested by Unity. Now along with this I created a reticle in the center of the player's camera, with the idea being that the player can aim at what button they want to press, and then press the "A" button on the controller to press it.
Now here's the issue. The raycast I have on my camera does not seem to detect any of the GUI elements, passing right through it and not giving me any output on my Raycasthit variable. Other surfaces and objects detect just fine though. I've been searching all over as to what this might be; adding the main camera as event camera, checking raycast targets on the GUI objects, checking if there's any collider in the way, but nothing seems to work. I looked up the way Unity did it in their VR samples project, but they don't even seem to be using their own GUI system for the main menu.
It is sort of important to get this working with Unity's GUI system, as most of the work I've done and plugins I use are dependent on this. If anyone could help me out with this, that would be great!
Answer by Arvank · Jul 27, 2016 at 07:07 PM
I'm pretty sure I just stumbled onto my own answer. Turns out that when you add a box collider to the GUI element, the resulting collider is incredibly tiny compared to the button. I didn't even see it at first, thinking it was just sized up to the border of the element itself and being hidden underneath it as you sometimes see when you have a mesh and a collider beneath it.
I adjusted the collider sizes of the elements and the raycast is now hitting properly. Next up is going to get the interaction going, but I guess this answers the question in this post. Marking as answered for any future devs who might have issues with this.
Cheers!
Your answer
Follow this Question
Related Questions
How to handle UI/Space mixed scene? 2 Answers
Detect If Pointer Is Over Any UI Element 6 Answers
UI elements don't show up in Vive? 1 Answer
uGUI input text in world space 0 Answers
test gear vr touch input in editor 1 Answer