Unity Daydream Technical Preview lacks controller support and crashes using Google VR SDK

I’m trying to develop a Google Daydream app with 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 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 eachother for a split-second, and then the app crashes.

I believe 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 does not 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.

I think I’ve now found a solution to the issue.

The GVR Android SDK (GitHub - googlevr/gvr-android-sdk: Google VR SDK for Android) 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:

And if you can really be bothered to jump through all these hoops, kudos!