Skip to content

shiena/OpenXRRuntimeSelector

Repository files navigation

OpenXRRuntimeSelector

openupm

Runtime Json Selector for Unity OpenXR

System Requirements

Unity

  • 2020.2+

Platforms

  • Windows

API Compatibility Level

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 Registries in dropdown top left
  • Select OpenXR Runtime Selector and click Install
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