using UnityEngine;
using System.Collections; public class C : MonoBehaviour
{
private WebCamTexture cameraTexture;
private string cameraName = "";
private bool isPlay = true;
// Use this for initialization
void Start()
{
cameraTexture = new WebCamTexture();
StartCoroutine(Test());
} // Update is called once per frame
void Update()
{ } IEnumerator Test()
{
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;
cameraName = devices[].name;
cameraTexture = new WebCamTexture(cameraName, , , );
cameraTexture.Play();
isPlay = true;
}
} void OnGUI()
{
if (isPlay)
{
GUI.DrawTexture(new Rect(, , , ), cameraTexture, ScaleMode.ScaleToFit);
}
}
}

unity3d 读取usb摄像头-LMLPHP

04-13 16:46