unity WebCam 手机自适应 摄像头
来源:互联网 发布:复杂网络前景 编辑:程序博客网 时间:2024/05/20 03:36
using UntyEngine;using System.Collections;using UnityEngine.UI;public class MobileCam : MonoBehaviour{ private bool camAvailable; private WebCamTexture cameraTexture; private Texture defaultBackground; public RawImage background; public AspectRatioFitter fit; public bool frontFacing; // Use this for initialization void Start() { defaultBackground = background.texture; WebCamDevice[] devices = WebCamTexture.devices; if (devices.Length == 0) return; for (int i = 0; i < devices.Length; i++) { var curr = devices[i]; if (curr.isFrontFacing == frontFacing) { cameraTexture = new WebCamTexture(curr.name, Screen.width, Screen.height); break; } } if (cameraTexture == null) return; cameraTexture.Play(); // Start the camera background.texture = cameraTexture; // Set the texture camAvailable = true; // Set the camAvailable for future purposes. } // Update is called once per frame void Update() { if (!camAvailable) return; float ratio = (float)cameraTexture.width / (float)cameraTexture.height; fit.aspectRatio = ratio; // Set the aspect ratio float scaleY = cameraTexture.videoVerticallyMirrored ? -1f : 1f; // Find if the camera is mirrored or not background.rectTransform.localScale = new Vector3(1f, scaleY, 1f); // Swap the mirrored camera int orient = -cameraTexture.videoRotationAngle; background.rectTransform.localEulerAngles = new Vector3(0, 0, orient); }}
阅读全文
0 0
- unity WebCam 手机自适应 摄像头
- ---WebCam网络摄像头6 编译WebCam
- 【AR】DroidCam笔记本调用手机摄像头(smartphone's camera as pc webcam)
- 【AR】DroidCam笔记本调用手机摄像头(smartphone's camera as pc webcam)
- 使用USB摄像头(Webcam)拍照
- 使用USB摄像头(Webcam)拍照
- ---WebCam网络摄像头10 socket
- webcam摄像头采集遇到问题
- jquery.webcam进行摄像头拍照
- unity 5.0.1:nugi自适应手机分辨率
- [Mo]windows下kinect用作webcam摄像头
- ---WebCam网络摄像头5 usb 使用
- ---WebCam网络摄像头9 usb dirver
- ---WebCam网络摄像头11 http协议
- WebCam网络摄像头5 usb 使用
- Testing your USB Webcam开摄像头
- Unity使用WebCamTexture 实现手机前后摄像头调用
- unity 摄像头
- 介绍一下Hibernate的二级缓存
- Kubernetes Master High Availability 高级实践
- vim配置代码自动补全
- 机器学习极好的入门学习视频推荐
- 自定义圆形jin'du't
- unity WebCam 手机自适应 摄像头
- 用clearfix:after消除(DIV块因内部浮动而高度收缩的问题)
- <基于Java数据结构>线性表
- ListView中按钮监听器 设置 及 优化
- CentOS 6.8 安装git 及配置
- Codeforces 894C:Marco and GCD Sequence(构造)
- centos7—quota配额
- XR,下一代搜索
- 迷茫