Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Enable\Disable plug-in provider before build

Discussion in 'AR/VR (XR) Discussion' started by YuriyVotintsev, Jul 24, 2020.

  1. YuriyVotintsev

    YuriyVotintsev

    Joined:
    Jun 11, 2013
    Posts:
    91
    I need to enable\disable Oculus plug-in provider for different types of build. How can i do it in code to automate process? Can't find anywhere information about it.
     

    Attached Files:

    LeoHerrera likes this.
  2. orzech123

    orzech123

    Joined:
    Mar 12, 2018
    Posts:
    17
    That's exactly what I also would like to do. Did you found the solution?

    Regards!
     
  3. korinVR

    korinVR

    Joined:
    Jul 7, 2012
    Posts:
    30
  4. TheNullReference

    TheNullReference

    Joined:
    Nov 30, 2018
    Posts:
    222
    Code (CSharp):
    1.  
    2. public class SetLoadersClass(){
    3.  
    4.    // Assign this, it should be in your settings folder.
    5.    private UnityEngine.XR.Management.XRGeneralSettings androidSettings = null;
    6.  
    7.     public void LoadOculusPlugin()
    8.     {
    9.              
    10.        PlayerSettings.Android.minSdkVersion = AndroidSdkVersions.AndroidApiLevel24;
    11.  
    12.        androidSettings.InitManagerOnStart = true;
    13.  
    14.        var loaderString = typeof(Unity.XR.Oculus.OculusLoader).FullName
    15.  
    16.         UnityEditor.XR.Management.Metadata.XRPackageMetadataStore.AssignLoader(androidSettings.AssignedSettings, loaderString, BuildTargetGroup.Android);
    17.            
    18.       EditorUtility.SetDirty(androidSettings);
    19.  
    20.     }
    21. }
    22.  
    This worked for me. I think UnityEditor.XR.Management.Metadata.XRPackageMetadataStore.ClearLoaders is a thing if you want to reverse it as well