using UnityEngine;
using System.Collections;
public class HDCamera : MonoBehaviour {
public static string deviceName = "HD Pro WebcamC920";//摄像头硬件名称
WebCamTexture tex;
IEnumerator Start()
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
//print(devices.Length);
//deviceName = devices[1].name;
if (deviceName != devices[0].name)
{
deviceName =devices[0].name;
}
tex = new WebCamTexture(deviceName, 1920, 1080, 30);
renderer.material.mainTexture= tex;
tex.Play();
}
else
{
}
}
// Update is called once per frame
void Update () {
}
}