Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Oculus Touch and UI how to guide for Unity.

spyderbytespyderbyte Posts: 3
edited August 2017 in Unity Development
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! :-)


  • spyderbytespyderbyte Posts: 3
    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.

    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.

    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. 

    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.

    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.

    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.  
    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

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

  • idrezidrez Posts: 2
    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 :
    	public void AssignCameraRig()
    		EventSystem eventSystem = GameObject.FindObjectOfType<EventSystem>();
    		inputModule = eventSystem.GetComponent<OVRInputModule>();
    I just cranked that out for a prototype. Works great.

  • spyderbytespyderbyte Posts: 3
    idrez said:
    I'm having one issue. How do you set the GazePointer to righthandAnchor locator if the variable type is OVRCameraRig

    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:
  • alexvilchalexvilch Posts: 38
    Brain Burst
    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,
  • yaboie88yaboie88 Posts: 1
    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_FabrikDigitale_Fabrik Posts: 5
    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? 
Sign In or Register to comment.