Sarah Maher
Sarah Maher

Reputation: 830

Check Daydream compatibility in unity

Let say I'm developing a Hybrid app that will lunch in VR mode if the device is daydream ready , other than that it will lunch normally .

void Start(){
    if(magical condition) {
        EnableVR (); 
    }
}

IEnumerator LoadDevice(string newDevice, bool enable)
{
    VRSettings.LoadDeviceByName(newDevice);
    yield return null;
    VRSettings.enabled = enable;
}

void EnableVR()
{
    StartCoroutine(LoadDevice("daydream", true));
}

void DisableVR()
{
    StartCoroutine(LoadDevice("", false));
}

how can I check if the current device is daydream device or not ?

Upvotes: 0

Views: 121

Answers (1)

Originating from derHugo's comment, as the documentation links have changed due to a refactor on Unity's end from a VR namespace to XR (as it covers all of AR, VR, and MR):

XRSettings.loadedDeviceName.html will tell you the type of device that's currently active.

XRDevice.model will let you know the specific model.

joejo

You need to check VRSettings.loadedDeviceName to see if the currently running device is "cardboard" or "daydream". That should let you know what device you are running on so you can make decisions about how to handle input.

Upvotes: 0

Related Questions