Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

sensing if device is cardboard or daydream

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

  1. hawken


    Aug 22, 2013
    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


    Unity Technologies

    Aug 9, 2013
    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


    Aug 22, 2013
    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.     }
    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


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

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

    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


    Jan 9, 2017
    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)

    if it is Daydream compatible it will load daydream, if not it will fall thru to cardboard.