unity virtual reality sdk supported

How to change Virtual Reality SDKs list in Unity Build settings (via script)

Just a quick article to help people that are desperate like I was yesterday. Yesterday I was implementing the develop-once-build-everywhere facility of our ImmotionRoom system: it’s a very nice menu where you can choose the headset you’re developing for and then it sets for you all settings, prefab and stuff so that you can build your program for every headset you want without changing a single line of code or modifiying your scene. Cool, isn’t it?

cross platform full body vr
The amazing multi-build menu now available on ImmotionRoom SDK: this way developing full body games for all platforms have become super easy… you just need to click on a menu entry!

Well, I was getting crazy because I was developing some editor scripts to implement it and then I didn’t manage to find how to change via script that damn Virtual Reality SDKs list that you can see in your Player Settings. Changing the Virtual reality Supported flag is super-easy and documented, but I could not find a way to change the other thing and in PlayerSettings class I couldn’t manage to find a solution.

unity virtual reality sdk supported
List of VR parameters… accessing them via editor is super-easy, but finding them via script is a pain

I was about to quit when I found that Oculus (and even Vive) already do it in their scripts… so I got to know how to do this. The secret is using the new VR native support of Unity. In particular, the class UnityEditorInternal.VR (that I didn’t know it existed until yesterday…)

So, to enable/disable VR support for a particular platform, you can use old method

PlayerSettings.virtualRealitySupported = bool_value

or you can use new implementation and write

UnityEditorInternal.VR.VREditor.SetVREnabledOnTargetGroup(BuildTargetGroup, bool);

To change the VR SDKs list for a particular platform, you have to call

UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup, string[]);

The second parameter is an array of strings, specifying the string IDs of the Virtual Reality SDKs that you want to support. Using a string is not a super smart choice, since you can pass to this method any string, even “ILoveSkarredGhost” (even if in this case, the system will complain about a not-found SDK).

unity vr sdk supported
Look, mom, I’m a virtual reality SDK!

Valid strings are things like “Oculus”, “OpenVR” (for SteamVR) and “None” (for non-VR applications). Remember that the array is ordered on priority… so at first place you have to put the preferred SDK.

Hope to have helped you… happy VR developing!


Disclaimer: this blog contains advertisement and affiliate links to sustain itself. If you click on an affiliate link, I'll be very happy because I'll earn a small commission on your purchase. You can find my boring full disclosure here.

12 thoughts on “How to change Virtual Reality SDKs list in Unity Build settings (via script)

  1. Thanks for article, very helpful. A couple of additional notes based on 2017.3 and looking in Unity Decompiled (https://github.com/MattRix/UnityDecompiled/blob/master/UnityEditor/UnityEditorInternal.VR/VREditor.cs):

    You can get a list of the available Virtual Reality SDKs with:

    string[] availableVRDevices = UnityEditorInternal.VR.VREditor.GetAvailableVirtualRealitySDKs(BuildTargetGroup.Android);

    You can get the current list of devices set:

    string[] currentVRDevices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Android);

    And rather than using SetVREnabledDevicesOnTargetGroup, it probably worth using SetVirtualRealitySDKs because that also sets the dirty flag:

    UnityEditorInternal.VR.VREditor.SetVirtualRealitySDKs(BuildTargetGroup.Android, new string[] { “None”, “cardboard” });

    Jules

  2. Is there any way to set the Depth Format of Daydream via script? I’m on Unity 5.6.1 (Can’t update yet due to project constraints).

Comments are closed.

Releated

apple vision pro 2 cable

The XR Week Peek (2025.04.21): Apple Vision Pro 2 battery cable leaked, NVIDIA launched RTX 5060 graphics cards, and more!

Yesterday it was Easter here in Italy, and I had a good time with my family eating delicious food. You can read my greetings to the community and see some pictures of the cake I’ve eaten on Twitter/X if you want.  Today is also a Holiday in Italy (I guess to leave people the time to […]

pimax crystal super

The XR Week Peek (2025.04.15): Tariffs may be lifted on XR headsets, Vision Pro 2 may be in production, and more!

This week, we had quite a lot of interesting news about all the major players: Apple, Meta, Google, and Valve. There is a lot to unpack, so make sure to read this roundup of news till the end… where there will also be a giveaway of keys for a cool mixed reality game!  (And feel free […]