cancel
Showing results for 
Search instead for 
Did you mean: 

Oculus Touch and UI how to guide for Unity.

spyderbyte
Explorer
Hey, guys! So I'm having a little trouble understanding and setting up the Oculus touch UI in my own game. I'm not new to Unity and I've downloaded and studied the Oculus Sample Frmwrk, yet I can't seem to understand the steps on how to implement the pointer scene sample in my own game to be able to click on the UI. I've tried a few things and managed to get the reticle working but not able to click on any world buttons. A walkthrough or explanation for the touch UI would be EXTREMELY appreciated. Thanks in advance! 🙂
7 REPLIES 7

spyderbyte
Explorer
Figured it out. I followed this link but I will still explain what I did. https://developer.oculus.com/blog/unitys-ui-system-in-vr/. I'm sure many did this but it doesn't explain how to use it for touch. Its just a simple fix.

SUMMARY
This tutorial is basically the same as the above link I provided, All I did was change the ray transform variable in the Event system and GazePointer to righthandAnchor but here are the steps anyway. Also make sure to set the Canvas event camera to CenterEyeAnchor. Hope it works and helps you. Feel free to make any corrections and/or mistakes. I'm no means a VR expert but this is what I did to get it up and working.


INSTALL OVR
1. Go to asset store and download the Oculus integration and the Oculus sample framework. You can alternatively download it from the Oculus dev site. 

POINTER SCENE
2. Navigate to Assets/SampleScenes/UI/ and click on the Pointer Scene and open it up. Here you can basically see get the jist if you follow along with the like I gave up above, but I'll still walk you through.

SAVE PREFABS FROM SCENE
3. I couldn't find a OVR camera rig prefab with touch controllers so I saved it as a prefab. (you can test it in another scene and you have touch controller movement.).
4. Also, find the GazePointerRing in the hierarchy and save that as a prefab. Maybe it's there already as a prefab but I didn't see it in the given prefabs so I made my own prefab.

NEW SCENE SETUP
5. Create a new scene and drag the prefabs you just saved into the scene(OVRCameraRig and GazePointerRing)
6.add a button to the scene
7. Set Canvas render mode to world Space

SCRIPTS and setup 
8. add OvrPhysicsRaycaster script to the OVRCamera 
-the event mask is there to interact with all layers or just UI elements. 
9. In the Hierarchy, navigate to your OVRCameraRig/TrackingSpace/CenterEyeAnchor. Drag the CenterEyeAnchor Gameobject to the EventCamera slot located in the Canvas.I think this allows you to see where you are pointing.
10. Add a script to the canvas called OVRRaycaster
-I want my ray cast to interact with all objects so I set Blocking Objects to all and Blocking  Mask I left as "everything" and left the others as default. 
11. in the OVRCAmeraRig find the RightHandAnchor game object and drag it to the following.
-Find the GazePointerRing and drag the RightHandAnchor to the Ray Transform variable.
-Find the EventSystem in the Hierarchy and drag the RightHandAnchor to the Ray transform in the OvrInputModule Script and if not set already set the JoypadClick button to "One". This is the "a" button on the Touch Controller and leaves all other variables alone.  
IMPORTANT! DELETE A FEW THINGS 
12. Make sure you Only have OVRCameraRig as your camera. Delete the default camera if you haven't already. You don't need it. 
13. In the event,system, make sure you delete the StandaloneInputModule component. OVRInputModule script replaces this. 
14. Remove the graphic raycaster component in Canvas. OVRRaycaster replaces this.
15. I think that's it! Press play and It should work :D! 



idrez
Explorer
I'm having one issue. How do you set the GazePointer to righthandAnchor locator if the variable type is OVRCameraRig

gmbdozlw4je9.png

idrez
Explorer
Wow, ok. So the scripts in https://developer.oculus.com/blog/unitys-ui-system-in-vr/ are not the same as the ones you can reference in "Oculus Sample Framework 1.15" on the unity store. The unity store version has the transform value time.

Also, bit of cool script in there, you can switch it on the fly for better controller support:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class ControlSwitch : MonoBehaviour {

// Input module
private OVRInputModule inputModule;
public OVRCameraRig cameraRig;

// Use this for initialization
void Start () {
AssignCameraRig ();
}

// Update is called once per frame
void Update () {
inputModule.rayTransform = OVRGazePointer.instance.rayTransform =
(OVRInput.GetActiveController() == OVRInput.Controller.Touch) ? cameraRig.rightHandAnchor :
(OVRInput.GetActiveController() == OVRInput.Controller.RTouch) ? cameraRig.rightHandAnchor :
(OVRInput.GetActiveController() == OVRInput.Controller.LTouch) ? cameraRig.leftHandAnchor :
cameraRig.centerEyeAnchor;
}
public void AssignCameraRig()
{
EventSystem eventSystem = GameObject.FindObjectOfType<EventSystem>();
inputModule = eventSystem.GetComponent<OVRInputModule>();
}
}
I just cranked that out for a prototype. Works great.

spyderbyte
Explorer

idrez said:

I'm having one issue. How do you set the GazePointer to righthandAnchor locator if the variable type is OVRCameraRig

gmbdozlw4je9.png

Hey idrez. Cool script. Glad you got it. I think you may have an older version.  I'm using Unity 2017 and  Oculus sample framework v1.15. I just checked for an update and it seems I have the latest framework version. This is what I have:g4ad8mrzdh33.png

alexvilch
Protege
Is there anything like this ( add Raycast ) to Oculus Avatar Touch for Oculus Rift  example ? If I want to start the ray from my hand ( left or right ) ?
Thank you,
Alex

yaboie88
Honored Guest
YES! your step-4-step instructions have worked for me.. I can now use my oculus touch controller to interact with a world space canvas.

Digitale_Fabrik
Explorer
Hello, How can I activate a new scene by pressing a button by this? 
It shall be like this:
When i press the button i want to play a 360° Video. This Video i want to place as  new scene or on an invisible place on the same scene where i press the button. ANyway i want to see the Video after pressing the button! How does it run?