Using SDK Cardboard in Unity 5 - No Touch Events?

I have a 2D scene that should show a list of available cardboard scenes (like thumbnails). After the user clicks the thumbnail, I try to send it to the selected card scene. However, I cannot catch touch events in the first (list) of scenes. After the tap nothing happens, just put it down. (EDIT: add that I tested this only on Android)

This is what I did for testing:

  • I am creating a new project (Unity 5.0.2f) - 2D
  • I put the UI button and text box in the scene
  • I add a script that runs after the button is pressed - it just changes the text of the text field to "Clicked" --- →> ALL FINE WORKS, pressing the button on the touch screen works as expected, the text is changed <<--- ---
  • I import Google Carboard SDK --- →> NO EVENTS WORK! The click handler never starts <<--- <---
  • I uninstall the Google Cardboard SDK --- →> WORK TAPS AGAIN <<---

The start click script 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"); } } 

Thus, basically importing a cardboard SDK completely breaks touch events in Unity 5. If I test it directly in unity, mouse events work fine. The text changes even when the Cardboard SDK is imported. Anyone have an idea? Am I doing something wrong or is it a Unity bug?

+7
android unity3d google-cardboard
source share
4 answers

Another way to do this, assuming you want to save the TapIsTrigger / want this 2D scene in VR mode to use:

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

Again, for this you need to click TapIsTrigger.

+1
source share

Disable "Tap Is Trigger" in the settings of Cardboard.SDK. Please note: the new version v0.5 no longer has this problem.

0
source share

In my case, this two-finger problem with a few touches only occurs when switching from a cardboard scene to a non-cardboard scene.

My solution: when you want to load a scene from a cardboard scene into a scene without cardboard, before executing LoadLevel (), turn off VR mode included in the CarboardMain of the game object, in Cardboard .cs script, then you execute LoadLevel ().

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

And my decision

You can overcome this by first turning off the camera and then turning off VR Mode Enabled in the CardboardMain game object, so the scene switching stream will look smooth.

0
source share

Try the following steps:

  • Remove MainCamera
  • Drag CarboardMain into the scene
  • From the Prefabs / UI CardboardReticle field in the main camera
  • Add a physical Raycaster to the main camera component
  • Add GameObject Event System
  • Add GazeInputModule Script to the event system
  • Add touch input module to the event system
0
source share

All Articles