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:
- I create a new project (Unity 5.0.2f) - 2D
- I put a UI button and a textfield to the scene
- 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 <<<---
- I import Google's Carboard SDK --->>> NO TOUCH EVENT WORKS! Click handler never triggered <<<---
- 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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With