Search Unity

Android - Know which VR SDK is being targeted?

Discussion in 'AR/VR (XR) Discussion' started by hungrybelome, Apr 27, 2017.

  1. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Hi,

    I'm trying to support both Daydream/GearVR, and so I want a build pre-process step that reads from the PlayerSettings/OtherSettings which VR SDK is being targeted, and then destroys/enables certain game objects with the platform-specific scripts.

    The PlayerSettings class has a static .virtualRealitySupported property, but I don't see anything that lists the actual targeted SDKs.

    Anyone know how to find out via script which VR SDK is being targeted?

    Thanks!
     
    Last edited: Apr 27, 2017
  2. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    hungrybelome likes this.
  3. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Awesome, thanks!

    Also, when I target two VR sdks (Oculus and Daydream) and then build for Android, my Google Pixel automatically prompts for the Daydream headset when launching the app. If I were to run the app on a Samsung phone, would it prompt for the gear VR instead? I don't have a Samsung phone yet, but I'll be buying an s8 soon, so trying to prepare for multiplatform support now.

    I wasn't sure whether adding Daydream to the target list results in always prompting for the Daydream on Android, or only if the device supports Daydream. Hence my attempt at a build preprocess step, and maintaining two separate Android builds for Daydream and GearVR. Hoping you could shed some light on this!

    Thanks for your help!
     
  4. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    The order in which you have the SDKs in the player settingslist are the order in which the engine attempts to initialize them. So if you put Daydream first and then Oculus, we'll first try to use Daydream. If the device doesn't support it then we'll continue to the next SDK on the list, in this case using Oculus. So yes, it should work as you're guessing. :)
     
  5. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    I have a product that will be on the store soon that will do this automatically as well as adding the appropriate OVRmanager or GVRcontroller and GVRarmmodel respectively via a menu dropdown for "build daydream" or "build gear vr".

    In general though your best bet is to write an editor script to actually add the one you are building for and removing the one you aren't currently building for from the list. It's not like there aren't other things that need to be different, I haven't seen an apk yet that can just be uploaded to both stores without modifications (controller api is different, camera rigs are different,etc.). That way at runtime you can do a nice check at points at which one is being used. Also, its best to make sure the manifests are correct if you are publishing since the two platforms have different requirements. In the end this definitely can be done.