标签:ret ati idt div user amt width devices blog
public class UITest : MonoBehaviour { public string deviceName; public WebCamTexture webCam; // 图片组件 public RawImage rawImage; void Start() { StartCoroutine(Call()); } public IEnumerator Call() { // 请求权限 yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { // 获取相机设备 WebCamDevice[] devices = WebCamTexture.devices; // 取第一个相机名称 deviceName = devices[0].name; // 创建相机贴图 webCam = new WebCamTexture(deviceName, Screen.width, Screen.height, 60); // rawImage.texture = webCam; // 相机开启 webCam.Play(); } } }
最后把UI中的 RawImage 组件拖放到 rawImage 面板中。
标签:ret ati idt div user amt width devices blog
原文地址:http://www.cnblogs.com/jiuxuan/p/7532030.html