Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Oculus OVR

Discussion in 'AR/VR (XR) Discussion' started by shananas, Sep 26, 2019.

  1. shananas

    shananas

    Joined:
    Sep 5, 2016
    Posts:
    1
    I have a project i'm working with a group on that is networked between an Oculus and Mobile app with Photon networking. To prevent errors the mobile version needs the oculus package and the VR player. With the Oculus folder/package in the project when i try to build the mobile app it forces it to build to VR. I have checked the XR setting and VR support is set to inactive but it still build it in VR.
    Was wondering if anyone knew if the Oculus package forces a VR build somewhere even with VR supported unchecked on both android and the pc XR settings
     
  2. FdenUijl

    FdenUijl

    Joined:
    Sep 5, 2019
    Posts:
    12
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    400
    Depends how your scene and code is setup. If you don't check 'initialize XR on startup' or disable the oculus package it doesn't go into VR.
    Then maybe use 2 different scenes for input and load them next to the main game?
     
  4. FdenUijl

    FdenUijl

    Joined:
    Sep 5, 2019
    Posts:
    12
    We are using the following to switch between VR and AR. You can also just remove/add the VR plugin before building. (IPreprocessBuildWithReport)

    Code (CSharp):
    1.        private void SetXRPlugins(string[] addPlugins, string[] removePlugins, UnityEditor.BuildTargetGroup buildTarget)
    2.         {
    3.             var xrSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(buildTarget);
    4.  
    5.             if(xrSettings == null)
    6.             {
    7.                 XRGeneralSettingsPerBuildTarget buildTargetSettings = null;
    8.                 EditorBuildSettings.TryGetConfigObject(XRGeneralSettings.k_SettingsKey, out buildTargetSettings);
    9.                 xrSettings = buildTargetSettings.SettingsForBuildTarget(BuildTargetGroup.Android);
    10.             }
    11.  
    12.             xrSettings.InitManagerOnStart = true;
    13.  
    14.             foreach(var addPlugin in addPlugins)
    15.             {
    16.                 if(!XRPackageMetadataStore.AssignLoader(xrSettings.Manager, addPlugin, buildTarget))
    17.                 {
    18.                     Debug.LogWarning("PLUGIN NOT ASSIGNED!: " + addPlugin);
    19.                 }
    20.             }
    21.  
    22.             foreach(var removePlugin in removePlugins)
    23.             {
    24.                 if(!XRPackageMetadataStore.RemoveLoader(xrSettings.Manager, removePlugin, buildTarget))
    25.                 {
    26.                     Debug.LogWarning("PLUGIN NOT REMOVED!: " + removePlugin);
    27.                 }
    28.             }
    29.  
    30.             EditorUtility.SetDirty(xrSettings);
    31.         }
    32.  
    33. //Switch to Oculus:
    34. addPlugins = new string[] { typeof(global::Unity.XR.Oculus.OculusLoader).FullName };
    35. removePlugins = new string[] { typeof(UnityEngine.XR.ARCore.ARCoreLoader).FullName };
    36.  
    37. //Switch to AR:
    38. removePlugins = new string[] { typeof(global::Unity.XR.Oculus.OculusLoader).FullName };
    39. addPlugins = new string[] { typeof(UnityEngine.XR.ARCore.ARCoreLoader).FullName };
    40.  
    But we still have to remove the Oculus folder by hand (and restart Unity) before building, else the build will fail at start-up.


    EDIT: Can confirm that running a Pre-build shell script on Unity Cloud Build fixed my problem. For other people who have the same issue:

    UnityCloudBuildScript.sh
    Code (CSharp):
    1. #!/bin/bash
    2.  
    3. rm -r Assets/Oculus
    Should do the trick
     
    Last edited: Nov 18, 2021
    DevDunk likes this.
unityunity