Programatically switching supported VR SDKs

I’m working on a VR app that supports Vive and Oculus. With Unity 5.3 we could use the native VR support for Oculus and the OpenVR plugin for Vive and our build scripts turn things on and off as appropriate.

Unity 5.4 added a list of “Virtual Reality SDKs” to the Player Settings. These are serialized in ProjectSettings.asset in a section that looks like this:

  vectorPropertyNames:

  ...

  - Standalone::VR::enabledDevices

  ...

  Standalone::VR::enabledDevices:
  - Oculus
  - OpenVR

Is there a way to change this list through scripting in the editor? There isn’t a named property or field on PlayerSettings and there’s also no mention of vectorPropertyNames, just SetPropertyBool etc.

In a pinch I guess I could just have two copies of ProjectSettings.asset and swap them in when I do a build. Thats going to be a pain to maintain, especially if we add Android support and want to do specific Cardboard, GearVR builds too.

I am also trying to support Android, and Vive at this time, was hoping 5.4 would fix this. Anyone have experience getting an app to run on Android with SteamVR plugin in the project?

Baroque, we are having the same issue with 5.4p2.

Any chance you guys found a solution that did not involve multiple files?

Unfortunately not. We ended up not needing it–we branched and had different mobile and desktop projects in the end.

Actually, digging around some internals, it looks like there’s a UnityEditorInternal.VR.GetVREnabledDevices(BuildTargetGroup targetGroup) and SetVREnabledDevices(BuildTargetGroup targetGroup, string[ ] devices) you could try.

Hope it works for you!