Search Unity

When a project implemented Oculus Utility, how can I build for Cardboard without Gear feature?

Discussion in 'AR/VR (XR) Discussion' started by cdytoby, Sep 7, 2017.

  1. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    I already written my own "platform switch" script, that when build for cardboard, use these configuration, and when use GearVR, I use other configuration. I did this for each platform we support, like ios Cardboard, non vr mode pc, and so on. And it works for a long time, until I imported Oculus Utility.

    Because I need to implement "on headset mounted and unmounted event" for Oculus, I imported oculus utility in Unity. Then problem comes: I have multiple issues when build only for cardboard.

    When I plugin Samsung Smartphone for GearVR, and build for cardboard, it opens GearVR dialog shows that I have to plug it into Gear Glass. And when I enabled developer mode for Gear, and open the app, it looks just like Cardboard, but with "GearVR flicker effect". And I'm sure Oculus is not in the Virtual Reality SDKs list.

    And When I build on Nexus 6 with Cardboard setting, first time it crashes. and I opened my editor again, and did no changes and build run the project again on the same device, it doesn't crash, but its rotation is not tracked to camera.

    What's going on? How can I support multiple vr devices?
     
  2. RiccardoAxed

    RiccardoAxed

    Joined:
    Aug 29, 2017
    Posts:
    119
    Having same problem here.

    I've a Gear VR based project with Oculus Utilities imported and it works well. Now I was asked to port the project on Cardboard, so I simply switched the XR Settings/VR SDK from "Oculus" to "Cardboard", but when I launch the app it still shows the Gear VR dialog (insert device in Gear VR).

    How can I solve this problem?

    Thanks
     
  3. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    You may want to check the manifest xml. Also you should exclude the Oculus folder from build.
     
  4. RiccardoAxed

    RiccardoAxed

    Joined:
    Aug 29, 2017
    Posts:
    119
    Thank you for the answer.

    I checked the manifest first, removing the references to Samsung, then I even removed the whole manifest and also put the '~' prefix before the OVR folder name to ensure Unity excluded it from the build, but always without success. When I make the Carboard build and launch the app it still shows me the Gear VR dialog.

    Any other suggestions?
     
  5. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    @RiccardoAxed you can open your APK to check the AndroidManifest (using WinRAR for instance). To exclude a folder, i use a point before and after the folder name, didn't new about '~'.
     
  6. RiccardoAxed

    RiccardoAxed

    Joined:
    Aug 29, 2017
    Posts:
    119
    Yes, you can find here the info about '~' on paragraph "Hidden Assets"

    https://docs.unity3d.com/Manual/SpecialFolders.html

    Anyway I did many other tests, checking the manifest and excluding folders but I still can't obtain a Cardboard version from the same project. I'm afraid the only way is to fork the project having two distinct GearVR & Cardboard versions.
     
  7. joschi27

    joschi27

    Joined:
    Jul 31, 2016
    Posts:
    9
    Copied from https://forum.unity.com/threads/app...-to-be-placed-in-gear-vr-on-a-samsung.493028/ just FYI.

    For anyone still needing a fix; I've been on this problem for quite some time now. The fix with excluding oculus .aar files did not work for me, so i came up with a solution myself;

    The problem is this line in your android manifest:
    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
    It starts the gear vr prompt on supported samsung devices. Even if you are building for cardboard, this line is in the manifest.

    How to fix:

    Build the app > Get output from manifest-main.xml in Temp/StagingArea > add this line inside the <application> Tags:

    <meta-data android:name="com.samsung.android.vr.application.mode" android:value="dual" tools:replace="android:value" />
    OR
    <meta-data android:name="com.samsung.android.vr.application.mode" tools:remove="android:value" />

    ... Or export the whole project to android studio and go to the merged manifest, remove the value by hand.

    And you're done.

    If somebody could tell oculus about this problem, that'd be nice. I've tried, they dont seem to care much about bugs.
     
  8. arjenveenhuizen

    arjenveenhuizen

    Joined:
    Jan 12, 2017
    Posts:
    5
    This did not work for me, gradle was throwing errors when merging AndroidManifest.xml. I had to do the following instead for my non-GearVR builds (on Unity 2018.3.0f2):

    <meta-data android:name="com.samsung.android.vr.application.mode" tools:node="remove">
     
    Last edited: May 13, 2019