public string deviceName ;

描述

设置此属性可指定要使用的设备的名称。

只有在摄像机不运行时,设置此属性才有效。

注意:如果要使用 WebCamTexture 从通过 Unity Remote 连接的设备获取摄像机流,必须通过构造函数将其初始化。不能使用 WebCamTexture.deviceName 将设备从常规设备更改为远程设备,反之亦然。

// Sets the device of the WebCamTexture to the first one available and starts playing it
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(); } } }