Search Unity

Daydream Preview lacks native Daydream Controller support and crashes with GVR SDK included

Discussion in 'Daydream' started by b4th, Oct 4, 2016.

  1. b4th

    b4th

    Joined:
    Jul 4, 2016
    Posts:
    65
    I'm trying to develop a Google Daydream app with Daydream Controller support using the Unity Daydream Technical Preview build (UDTP). Unfortunately, UDTP does not appear to have native support for the Daydream Controller, so I have no choice but to include the Google VR SDK to establish a connection.

    The problem is whenever I attempt to build & run a Daydream app on the Nexus 6P with Unity's 'Virtual Reality Support' enabled AND the Google VR SDK included, the app crashes at runtime. I presume that the plugins provided by the Google VR SDK are conflicting with UDTP's native VR support. I see that the app and the controller emulator establish a connection to each-other for a split-second, and then the app crashes.

    I thought my best option might be to rebuild the Google VR SDK's plugin (libgvrunity) from source, removing all references to VR rendering and only keeping references to the controller, but the source for this plugin doesn't appear to be publicly available.

    I'm going to try building a new plugin using the Google VR Android SDK, but if anybody else has faced this issue and can provide any support or direction, it would be greatly appreciated.
     
    Last edited: Oct 4, 2016
  2. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Do you have the GVRViewer prefab enabled in the scene? In my test the script used in that prefab doesn't work at runtime cause it cannot find some method. They probably forgot to cleanup some files when they migrated to the native support.
     
  3. b4th

    b4th

    Joined:
    Jul 4, 2016
    Posts:
    65
    I do have a GVRControllerMain in the scene, and I know that's enough to establish a connection because the controller emulator turns green in the split second before the Unity host app crashes.

    (Also, I don't believe the Google VR SDK is actually using native support! Despite listing Unity Daydream Technical Preview as a prerequisite, the Getting Started instructions never mention Unity's 'Virtual Reality Supported' feature in the Player settings.)
     
  4. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    It was mentioned by Unity guys that Google VR 1.0 is a superset of Unity native support.
    Anyway I am no expert of Google VR, but check the logcat and see where it's crashing.
     
  5. b4th

    b4th

    Joined:
    Jul 4, 2016
    Posts:
    65
    Afraid logcat gave me nothing useful. No error, no stacktrace, nada.

    From what I could see in the Google VR Unity SDK source, the package is basically a fork of the original Google Cardboard Unity SDK with additional support for the controller (https://github.com/googlevr/gvr-unity-sdk). It uses a two-camera setup with distortion correction shaders, as opposed to Unity Technical Preview's native one-camera setup, therefore the native approach is FAR more efficient.

    Anyway, I think I've now found a solution to the issue. The GVR Android SDK (https://github.com/googlevr/gvr-android-sdk) contains an AAR file to link to the controller (libraries/controller/controller.aar). I was able to decompile this module in Android studio. The AAR module doesn't cover all of the controller's functionality (for instance, Accelerometer support), but they cover more than enough for our needs for this application. I wrote one little missing class in java (a listener), built this into an additional AAR module in Android Studio, and then loaded the two AAR files (controller.aar and controllerlistener.aar) into the Unity project. This gave me all I needed to create a few bridge classes in C# to allow Unity to talk to the java module classes to talk to the controller. Modify the GVR Unity SDK so that the ControllerProviderFactory creates the new AndroidJavaControllerProvider instead of the old AndroidNativeControlerProvider, et Voilá, the GvrControllerMain prefab works!

    All the code I've written can be found at the following Gist:

    https://gist.github.com/anonymous/ac8c76641f7b9b2608de50aae262644e#

    And if you can really be bothered to jump through all these hoops, kudos!
     
    Last edited: Oct 4, 2016