Using Cardboard SDK in Unity 5 - no touch events?
Asked Answered
R

4

7

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?

Reduce answered 22/5, 2015 at 3:5 Comment(0)
S
1

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.

Sherellsherer answered 29/7, 2015 at 22:15 Comment(0)
J
0

Turn off "Tap Is Trigger" in the Cardboard.SDK settings. Note, the new v0.5 release doesn't have this problem anymore.

Jetta answered 29/5, 2015 at 5:37 Comment(0)
E
0

In my case, this 2-fingers-multi-touch-detected issue only happen when you switch from cardboard scene to non-cardboard scene.

My Solution is: When you want to load scene from Cardboard scene to non-Cardboard scene, before you execute LoadLevel(), disable the VR Mode Enabled in CarboardMain game object, under Cardboard.cs script, then you execute LoadLevel().

ps: When you turn off VR Mode Enabled before loadLevel(), you will experience Cardboard cameras change from VR mode to non-VR in a second (visible but instantly), before you completely jump to the LoadLevel() new scene. This is ugly.

AND my solution is,

You can overcome this by disable the camera first, then only you turn off the VR Mode Enabled in CardboardMain game object, so the scenes-switching flow will be appeared smooth.

Expectant answered 12/6, 2015 at 6:13 Comment(0)
O
0

Try following these steps:

  1. Delete MainCamera
  2. Drag CarboardMain into Scene
  3. From Prefabs/UI place CardboardReticle under Main Camera
  4. Add Physics Raycaster to Main Camera Component
  5. Add Event System GameObject
  6. Add GazeInputModule Script to Event System
  7. Add Touch Input Module to Event System
Ohare answered 22/4, 2016 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.