# LoadDeviceByName

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

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.XR](/engine/6000.3/script-reference/unityengine/xr.md)
* **Assembly:** UnityEngine.VRModule

## LoadDeviceByName(string)

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

> **Warning:**
>
> **Deprecated.** XRSettings.LoadDeviceByName is deprecated and should no longer be used. Instead, use the SubsystemManager to load XR devices by querying subsystem descriptors to create and start the subsystems of your choice.

```csharp
public static void LoadDeviceByName(string deviceName)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Name of the device from [XRSettings.supportedDevices](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md).

### Remarks

A list of supported devices which can be passed into this method can be obtained from [XRSettings.supportedDevices](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md).

In order to check for success, check [XRSettings.loadedDeviceName](/engine/6000.3/script-reference/unityengine/xr/xrsettings/loadeddevicename.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/loadeddevicename.md) as an empty string and set [XRSettings.enabled](/engine/6000.3/script-reference/unityengine/xr/xrsettings/enabled.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/enabled.md).

**Note:** Some VR Devices do not support reloading when already active. You should make sure to check the currently loaded device and only load the new device if it is different.

### Examples

```csharp
// Run in split-screen mode
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.XR;

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

    IEnumerator LoadDevice(string newDevice)
    {
        if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
        {
            XRSettings.LoadDeviceByName(newDevice);
            yield return null;
            XRSettings.enabled = true;
        }
    }
}
```

## LoadDeviceByName(string\[])

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

> **Warning:**
>
> **Deprecated.** XRSettings.LoadDeviceByName is deprecated and should no longer be used. Instead, use the SubsystemManager to load XR devices by querying subsystem descriptors to create and start the subsystems of your choice.

```csharp
public static void LoadDeviceByName(string[] prioritizedDeviceNameList)
```

### Parameters

**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): Prioritized list of device names from [XRSettings.supportedDevices](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md).

### Remarks

A list of supported devices which can be passed into this method can be obtained from [XRSettings.supportedDevices](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md).

In order to check for success, check [XRSettings.loadedDeviceName](/engine/6000.3/script-reference/unityengine/xr/xrsettings/loadeddevicename.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/supporteddevices.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/loadeddevicename.md) as an empty string and set [XRSettings.enabled](/engine/6000.3/script-reference/unityengine/xr/xrsettings/enabled.md) 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](/engine/6000.3/script-reference/unityengine/xr/xrsettings/enabled.md).

**Note:** Some VR Devices do not support reloading when already active. You should make sure to check the currently loaded device and only load the new device if it is different.

### Examples

```csharp
// Run in split-screen mode
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.XR;

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

    IEnumerator LoadDevice(string newDevice)
    {
        if (String.Compare(XRSettings.loadedDeviceName, newDevice, true) != 0)
        {
            XRSettings.LoadDeviceByName(newDevice);
            yield return null;
            XRSettings.enabled = true;
        }
    }
}
```
