Unity allows rearranging XR loaders in editor: https://docs.unity3d.com/Packages/com.unity.xr.management@4.5/manual/EndUser.html#example-modifying-the-loader-list
Here is an example script that loads both OpenXR and Varjo XR Plugins and orders them so that loading Varjo is tried before OpenXR.
By default the prioritization order is alphabetical. You will need to rerun this script if you enable or disable Plug-in providers is XR Plug-in Management.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.XR.Management;
using UnityEngine;
using UnityEngine.XR.OpenXR;
using UnityEngine.XR.Management;
using Varjo.XR;
public class XRSDKLoader : MonoBehaviour
{
[MenuItem("XR SDK Loader/Set Priority to Varjo")]
public static void SetLoadSequence()
{
var generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);
var settingsManager = generalSettings.Manager;
// Get a readonly reference to the current set of loaders.
var readonlyCurrentLoaders = settingsManager.activeLoaders;
// Modifying the loader list order
var reorderedLoadersList = new List<XRLoader>();
foreach (var loader in readonlyCurrentLoaders)
{
if (loader is VarjoLoader)
{
// Insert 'Varjo Loader' Loaders at head of list
reorderedLoadersList.Insert(0, loader);
}
else if (loader is OpenXRLoader)
{
// Insert 'OpenXR Loader' Loaders at back of list
reorderedLoadersList.Insert(reorderedLoadersList.Count, loader);
}
}
// Would only fail if the new list contains a loader that was
// not in the original list.
if (!settingsManager.TrySetLoaders(reorderedLoadersList))
{
Debug.LogWarning("Failed to set the reordered loader list! Refer to the documentation for additional information!");
}
for(int i = 0; i < reorderedLoadersList.Count; i++)
{
Debug.Log("New loaders list " + i + ": " + reorderedLoadersList[i].name);
}
}
}