Leonardo Marques
Leonardo Marques

Reputation: 3951

Embedding Cardboard profile in Unity3D

I want to avoid users having to scan the QRCode with the Cardboard Viewer profile on it so that they can just place their device into the viewer and be ready. The viewer configuration is constant and I have a profile URL for it. Is it possible to load this profile at the application start up in Unity3D and if so how should I do it?

I tried setting it up by loading the following line of code at the Start of a Script attached to a camera but without any luck:

Cardboard.SDK.DefaultDeviceProfile = new Uri(SpecificVRViewerProfileUrl);

I'm using Unity 5.3.1f1, Cardboard 0.6, and Vuforia.

Upvotes: 0

Views: 395

Answers (1)

drwoof
drwoof

Reputation: 132

I haven't used the Unity SDK for cardboard, only java, but looking through the sample (https://github.com/googlesamples/cardboard-unity/blob/master/Cardboard/Scripts/Cardboard.cs) you might want to try getting a device reference using BaseVRDevice. It's a class also in the samples (https://github.com/googlesamples/cardboard-unity/blob/master/Cardboard/Scripts/VRDevices/BaseVRDevice.cs)

// The VR device that will be providing input data.
private static BaseVRDevice device;

device = BaseVRDevice.GetDevice();
device.Init();

and then setting the device profile with this instead of Cardboard.SDK.SetDefaultDeviceProfile

public Uri DefaultDeviceProfile = new Uri("your URL here");
if (DefaultDeviceProfile != null) {
  device.SetDefaultDeviceProfile(DefaultDeviceProfile);
}

Upvotes: 2

Related Questions