using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpenCamera : MonoBehaviour {
WebCamTexture _webCamera;
string DeviceName;
public GameObject Plane;//作为显示摄像头的面板 在界面上拖动赋值
// Use this for initialization
void Start()
{
WebCamDevice[] devices = WebCamTexture.devices;
for (int i = 0; i < devices.Length; i++)
{
//print(devices[i].name);
if (devices[i].name == "Creative GestureCam")
DeviceName = devices[i].name;
}
_webCamera = new WebCamTexture(DeviceName, 640, 480, 30);
Plane.GetComponent<Renderer>().material.mainTexture = _webCamera;
_webCamera.Play();
}
}
Unity打开网络摄像头