Select your preferred scripting language. All code snippets will be displayed in this language.
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.
CloseFor 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.
ClosedeviceName | Name of the device from XRSettings.supportedDevices. |
prioritizedDeviceNameList | Prioritized list of device names from XRSettings.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 XRSettings.supportedDevices.
In order to check for success, check XRSettings.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 XRSettings.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 XRSettings.loadedDeviceName as an empty string and set XRSettings.enabled to false.
You can disable XR by loading an empty string deviceName.
After loading a device, you may want to enable it with XRSettings.enabled.
#pragma strict // Run in split-screen mode function Start() { StartCoroutine(LoadDevice("Split")); } function LoadDevice(newDevice: String) { XRSettings.LoadDeviceByName(newDevice); nullXRSettings.enabled = true; }
// Run in split-screen mode
using System.Collections; using UnityEngine; using UnityEngine.XR;
public class ExampleClass : MonoBehaviour { void Start() { StartCoroutine(LoadDevice("Split")); }
IEnumerator LoadDevice(string newDevice) { XRSettings.LoadDeviceByName(newDevice); yield return null; XRSettings.enabled = true; } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information