Legacy Documentation: Version 2017.1 (Go to current version)
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public static function LoadDeviceByName(deviceName: string): void;
public static void LoadDeviceByName(string deviceName);
public static function LoadDeviceByName(prioritizedDeviceNameList: string[]): void;
public static void LoadDeviceByName(string[] prioritizedDeviceNameList);


deviceName Name of the device from VRSettings.supportedDevices.
prioritizedDeviceNameList Prioritized list of device names from VRSettings.supportedDevices.


Loads the requested device at the beginning of the next frame.

A list of supported devices which can be passed into this function can be obtained from VRSettings.supportedDevices.

In order to check for success, check VRSettings.loadedDeviceName on the next frame.

This function will try to initialize only the device(s) passed in, it will not fall back to other devices in the VRSettings.supportedDevices list. You can pass a list of values to fall back to other devices on failure. If no device could be initialized, it will fall back to VRSettings.loadedDeviceName as an empty string and set VRSettings.enabled to false.

You can disable VR by loading an empty string deviceName.

After loading a device, you may want to enable it with VRSettings.enabled.

#pragma strict
// Run in split-screen mode
function Start() {
function LoadDevice(newDevice: String) {
	nullVRSettings.enabled = true;
// Run in split-screen mode

using System.Collections; using UnityEngine; using UnityEngine.VR;

public class ExampleClass : MonoBehaviour { void Start() { StartCoroutine(LoadDevice("Split")); }

IEnumerator LoadDevice(string newDevice) { VRSettings.LoadDeviceByName(newDevice); yield return null; VRSettings.enabled = true; } }

Did you find this page useful? Please give it a rating:

Copyright © 2020 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。