Runtime Json Selector for Unity OpenXR
Unity
- 2020.2+
Platforms
- Windows
API Compatibility Level
- .NET 4.x
- .NET Standard 2.0 with Microsoft.Win32.Registry
- Environment Variable (
XR_RUNTIME_JSON
) - System Default
- Oculus
- WindowsMR
- SteamVR
- ViveVR
- Varjo
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 Registries
in dropdown top left - Select
OpenXR Runtime Selector
and 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
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");
}
}