Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

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

WebCamTexture.deviceName

Suggest a change

Success!

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.

Close

Sumbission failed

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

Close

Cancel

public var deviceName: string;
public string deviceName;
public deviceName as string

Description

Set this to specify the name of the device to use.

This only has an effect when set while the camera is not running.

Note: if you want to use WebCamTexture to get the camera stream from device connected through Unity Remote, then you must initalize it through the constructor. It's not possible to change device using WebCamTexture.deviceName from regular devices to remote devices and vice versa.

	// Sets the device of the WebCamTexture to the first one available and starts playing it
	function Start () {
		var devices : WebCamDevice[] = WebCamTexture.devices;
		var webcamTexture : WebCamTexture = WebCamTexture();
		if(devices.length > 0){
            webcamTexture.deviceName = devices[0].name;
			webcamTexture.Play();
		}
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        WebCamDevice[] devices = WebCamTexture.devices;
        WebCamTexture webcamTexture = new WebCamTexture();
        if (devices.length > 0) {
            webcamTexture.deviceName = devices[0].name;
            webcamTexture.Play();
        }
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Start() as void:
		devices as (WebCamDevice) = WebCamTexture.devices
		webcamTexture as WebCamTexture = WebCamTexture()
		if devices.length > 0:
			webcamTexture.deviceName = devices[0].name
			webcamTexture.Play()