Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Cardboard SDK in Unity 5 - no touch events?

I have a 2D scene that is supposed to show a list of available cardboard scenes (like thumbnails). After the user taps a thumbnail, I am trying to send him to the selected cardboard scene. However, I am unable to catch the touch events in the first (list) scene. After a tap, nothing happens, simply put. (EDIT: I will add that I tested this only on Android)

This is what I did to test:

  1. I create a new project (Unity 5.0.2f) - 2D
  2. I put a UI button and a textfield to the scene
  3. I add a script that is triggered after clicking the button - it just changes the text of the textfield to "Clicked" --->>> ALL WORKS FINE, tapping the button on the touch screen works as expected, text changed <<<---
  4. I import Google's Carboard SDK --->>> NO TOUCH EVENT WORKS! Click handler never triggered <<<---
  5. I delete Google's Cardboard SDK --->>> TAPS WORK AGAIN <<<---

The script of the click that is triggered is simple:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class TestScript : MonoBehaviour {

    public Text text;

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }

    public void ButtonClicked() {
        text.text = "Clicked!";
//      Application.LoadLevel ("DemoScene");
    }
}

So basically importing the Cardboard SDK complete breaks the touch events in Unity 5. If I test it directly in unity, mouse events work alright. The text is changed even when Cardboard SDK is imported. Anybody has some idea? Am I doing something wrong or is this a Unity bug?

like image 839
Fygo Avatar asked May 22 '15 03:05

Fygo


1 Answers

Another way to do it, assuming you want to keep the TapIsTrigger / want to have this 2D scene in VR Mode is to use:

if(Cardboard.SDK.CardboardTriggered){
    //what you want to happen when the user touches the screen
}

Again, you need to have TapIsTrigger ticked for this to work.

like image 90
pierre Avatar answered Oct 24 '22 07:10

pierre