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 () {
}
}
本博客详细介绍了如何在Unity中通过请求用户授权、获取摄像头设备信息、选择并播放指定摄像头画面的过程,适用于游戏开发和虚拟现实场景。
1万+

被折叠的 条评论
为什么被折叠?



