- Home /
Gear VR UI Input
Hello there guys!
I am completely desperate to be honest. I've searched every corner on the internet, but I can't find anything that is working for me.
The only thing I want is to get my UI elements working in Unity. I only want to be able to click on buttons. Nothing more. But no Tutorial I've done so far seems to work. Maybe because I am working with Gear VR? I don't know.
Could anyone tell me how I write a functioning Inputscript for UI in the Gear VR?
Thank you! :)
[PS: Please don't link me to this Post: (https://forums.oculus.com/viewtopic.php?t=16710) I've tried this and it just doesn't work for me]
Can you expand on why that specific solution doesn't work for you?
Hi. That is exactly my problem. I don't know why. I followed all the steps and it just doesn't work. It doesn't respond. There are no errors or anything.
Answer by alishka · Jan 23, 2016 at 05:20 PM
Hey, do not despair!
Have you checked out Unity Technologies' own VR example project?. I've used their assets to build my own demo app for the Samsung Gear at work a couple of days ago.
This project is a demonstration of the UnityEngine.VR library that ships in the new Unity update.
Basically what you need from this project is their camera prefab that has all the interaction scripts, and two other scripts to add to your objects (of any type) so that you could interact with them.
Technically, the camera would be dispatching events every time a raycast condition is met from one side. And from the other side, your interactive objects (which hold the relevant scripts) would be subscribed (listening to) these events, and would be ready to execute user-defined functions when required.
So, once you download and import the project, you can import their VR camera by dragging: VRSampleScenes > Prefabs > Utils > MainCamera.prefab into your scene.
To make a desired GameObject interactive, you have to add the VRInteractiveItem
component to it from: VRStandardAssets > Scripts, you then have to add the ExampleInteractiveItem
component from: VRSampleScenes > Scripts > Examples`, and reference the materials (for the sake of the example), and the object's MeshRenderer
and VRInteractiveItem
components.
You can then change what happens when you interact with your interactive GameObject by modifying the ExampleInteractiveItem script that you've added to it. (You are better off copying this script and renaming it)
P.S.: Unity VR requires version 5.3+, so make sure your editor is up to date
Cheers!
Hi! :) Thank you so much for your extensive answer :D
I'm sure it works. Unfortunally right now I have a pretty tight deadline and I don't really have the time to try this out. But I will in the future. For now I've rebuilt my project so I don't need to use UI.
Awesome! Let me know when you're at it, mention me here or anything. I've assembled a stripped-down package for the VR camera, and I'd be glad to share it with you.
Cheers!