faken faken - 1 year ago 383
Javascript Question

Interacting with WorldSpace UI with raycast in Unity

I'm creating mobile vr game for google daydream and I want to add WorldSpace UI to my game and interact wit it. There is controller(works like Wii conroller) that tracks rotation, so I have rotating pivot in my game. There is example of how this controller works. I thought that good way of doing this is using raycast to interact with UI(it would be shot form pivot), but after searching I haven't found anything helpful. Maybe there is another simpler way to do it?

Answer Source

Steps to setup Gaze Interaction in Google VR.

  1. Add Gaze Input Module to EventSystem object:


  2. Add Graphic Raycaster component to Canvas(all canvases) and Assign MainCamera (child of Head) as Event Camera in the canvas component :


  3. Add GvrReticle prefab as child of Main Camera. It should look like this:


Now your UI will respond to clicks (Input.GetMouseButtonDown(0)) as usual. UI under Retical/Gaze will be clicked. All you have to do is map controller's input to click button in Input Manager

Hope this will help :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download