如图所示 后面的ui是摄像机的rawimage代码是:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(RawImage))] //脚本挂在RawImage
public class CameraDevice : MonoBehaviour
{
private List<WebCamTexture> webCamTextures = new List<WebCamTexture>();
private RawImage image;
#region Unity Method
// Called once before Start
void Awake()
{
image = GetComponent<RawImage>();
}
// Use this for initialization
IEnumerator Start()
{
//获取授权
yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
if (Application.HasUserAuthorization(UserAuthorization.WebCam))
{
WebCamDevice[] devices = WebCamTexture.devices;