OpenXRRuntimeSelector
                                
                                 OpenXRRuntimeSelector copied to clipboard
                                
                                    OpenXRRuntimeSelector copied to clipboard
                            
                            
                            
                        Runtime Json Selector for Unity OpenXR
OpenXRRuntimeSelector
Runtime Json Selector for Unity OpenXR
System Requirements
Unity
- 2020.2+
Platforms
- Windows
API Compatibility Level
- .NET 4.x
- .NET Standard 2.0 with Microsoft.Win32.Registry
Support Runtime
- Environment Variable (XR_RUNTIME_JSON)
- System Default
- Oculus
- WindowsMR
- SteamVR
- ViveVR
- Varjo
Installation
Add from OpenUPM | via scoped registry, recommended
To add OpenUPM to your project:
- open Edit/Project Settings/Package Manager
- add a new Scoped Registry:
Name: OpenUPM
URL:  https://package.openupm.com/
Scope(s): com.shiena
- click Save
- open Package Manager
- Select My Registriesin dropdown top left
- Select OpenXR Runtime Selectorand clickInstall
Add from GitHub | not recommended, no updates through PackMan
You can also add it directly from GitHub on Unity 2019.4+. Note that you won't be able to receive updates through Package Manager this way, you'll have to update manually.
- open Package Manager
- click +
- select Add from Git URL
- paste https://github.com/shiena/OpenXRRuntimeSelector.git
- click Add
Sample Code
If you start XR environment after setting a specific runtime JSON, that runtime will be used.
using OpenXRRuntimeJsons;
void SetOculusRuntimeFromAvailableRuntimes()
{
    // Get the available OpenXR runtime json
    IReadOnlyDictionary<OpenXRRuntimeType,string> openXRRuntimes = OpenXRRuntimeJson.GetRuntimeJsonPaths();
    if (openXRRuntimes.ContainsKey(OpenXRRuntimeType.Oculus))
    {
        // Use the Oculus OpenXR runtime
        OpenXRRuntimeJson.SetRuntimeJsonPath(OpenXRRuntimeType.Oculus);
    }
}
void SetCustomRuntimeJson(string jsonPath)
{
    if (!OpenXRRuntimeJson.SetRuntimeJsonPath(jsonPath))
    {
        Debug.Log($"{jsonPath} is not available");
    }
}
Sample Project
References
- https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/specification/loader/runtime.adoc