Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

sensing if device is cardboard or daydream

Discussion in 'Daydream' started by hawken, Nov 1, 2018.

  1. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    488
    it's possible to get the headset name and go from there, but there's no kind of obvious universal app technique - if you list cardboard before daydream, you'll get cardboard and visa versa. Devices change and you'll be playing a cat and mouse game adding new device names.

    What would be nice is if we could get some sort of "I am a daydream device" when unity starts, so we can offer cardboard to 3DOF phones and daydream to 6DOF phones and headsets (like the Mirage Solo) from the same app build.

    Any ideas?
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    272
    If you list daydream before cardboard and daydream isn't supported, it should fall back to cardboard. What happens in the cases you're observing?

    It looks like there is an underlying google api to tell up front if the hardware supports async reprojection feature (daydream). Here's an example of using that api from c#.
     
  3. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    488
    Thanks for this!

    The specific problem I'm having is that my app starts up as a normal non VR app using XR settings none (actually, just toggle the XR supported bool), where the user can tap the screen to do things. When they start VR mode, I use the following code to change the XR settings:

    Code (CSharp):
    1.     IEnumerator LoadDevice(string newDevice)
    2.     {
    3.         XRSettings.LoadDeviceByName(newDevice);
    4.         yield return null;
    5.         XRSettings.enabled = true;
    6.     }
    with:
    Code (CSharp):
    1. StartCoroutine(LoadDevice("daydream"));
    If I do this, any cardboard device won't fallback from daydream to cardboard. Looking for a solution where I can say "OK you are cardboard so load cardboard XR settings" or "OK you are daydream so load daydream settings" using the above technique where the app starts in "none"



    If I remove the "none" the app will start up in VR mode.

    If I build with "virtual reality supported" turned off (akin to XRSettings.enabled = false) , the app won't build with VR capabilities. (error: To use the Google VR SDK on Android, 'Player Settings > Virtual Reality Supported' setting must be checked.)
     
    Last edited: Nov 4, 2018
  4. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    488
    in GvrHeadset there is a way to check with:

    Code (CSharp):
    1. static bool SupportsPositionalTracking
    It's not publicly accessible though

    https://developers.google.com/vr/re...GvrHeadset_1aae8dcbc79ff4b94be4f612a5b92e763e

    So I just made a non-static version of that boolean in GvrHeadset.cs and used the following code:


    Code (CSharp):
    1.         if(vrMode)
    2.         {
    3.             GvrHeadset headset = GameObject.FindObjectOfType<GvrHeadset>();
    4.             if (headset.SupportsPositionalTracking2)
    5.             {
    6.                 StartCoroutine(LoadDevice("daydream"));
    7.             }
    8.             else
    9.             {
    10.                 StartCoroutine(LoadDevice("cardboard"));
    11.             }
    12.         }
    seems to work, however this only works in a scene with the GvrHeadset object
     
    Last edited: Nov 4, 2018
  5. DarkVerse

    DarkVerse

    Joined:
    Jan 9, 2017
    Posts:
    40
    I know this is an old thread but if anyone stumbles on it (like I just did) there is a way to do this. LoadDeviceByName will take a string array and try to load the devices in the order listed, so you can do

    string[] devices = new string[] {"daydream", "cardboard"};
    then change LoadDevice signature to be LoadDevice(string[] devices)
    StartCoroutine(LoadDevice(devices));

    if it is Daydream compatible it will load daydream, if not it will fall thru to cardboard.
    See https://docs.unity3d.com/ScriptReference/XR.XRSettings.LoadDeviceByName.html