cancel
Showing results for 
Search instead for 
Did you mean: 

Mouse Cursor in Demo Scene

hmiri
Explorer
I understand the Unity 5 Virtual Reality Supported check-box does not currently turn the mouse cursor into a World Space or even Stereoscopic cursor.

So, because the regular mouse is not a 3D object in space, it cannot be used for VR interactions.

Is this all correct and accurate?

How come there is a use-able mouse cursor in the demo scene of the Configuration Utility then?
5 REPLIES 5

cybereality
Grand Champion
You could hide the Windows cursor and make your own 3D cursor in world space (which is what the Config Util does).
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

hmiri
Explorer
Thanks cybereality.

Can you please tell me where I could learn more on how to do this; e.g. tutorial page or blog post?

Any pointers on get me started is appreciated.

cybereality
Grand Champion
Here is how you hide the Windows cursor.

Cursor.visible = false;


http://docs.unity3d.com/ScriptReference ... sible.html

In order to make a stereo cursor, it's a little more involved though. You would want to use the UI Canvas for this, so that way you can interact with buttons and other UI elements. I don't have all the code for this, but I found this Unity Asset that may help you (paid, but cheap):

https://www.assetstore.unity3d.com/en/#!/content/27022

If you don't want to use the mouse, but just need to select via gazing, you can look at this code.

https://answers.oculus.com/questions/10 ... in-vr.html
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

owenwp
Expert Protege
To do it yourself, the important API is Input.mousePosition, which gives you the position of the visible or invisible mouse cursor inside your window in a range of 0 to Screen.width/height. Once you have that, you can use it to drive the position of a 3D object in your scene which will be your new cursor. Then just use the mouse click events as normal. The UI system won't be able to handle this, so you would need to use colliders or something to handle button events.

You can also set Cursor.lockState to keep it from going outside the window frame and clicking on other windows by accident. You don't really need to hide the windows mouse cursor either because you won't see it in VR anyway.

hmiri
Explorer
Thank you all very much.