deviceName | 要使用的视频输入设备的名称。 |
requestedWidth | 请求的纹理宽度。 |
requestedHeight | 请求的纹理高度。 |
requestedFPS | 请求的纹理帧率。 |
创建 WebCamTexture。
使用 WebCamTexture.devices 可获取可用摄像机设备名称列表。如果没有向构造函数提供或以 null 字符串形式传递名称,将使用找到的第一个设备。
所选摄像机可能不支持这些参数指定的请求宽度、高度和帧率。在这种情况下,将使用最接近的可用值。
创建 WebCamTexture 前请
调用 Application.RequestUserAuthorization。
**注意:**在 Android 上使用网络摄像头纹理要求设备运行 Honeycomb (Android 3.0) 或更高版本。
**注意:**如果要使用 WebCamTexture 从通过 Unity Remote 连接的设备播放摄像机流,必须通过构造函数将其初始化。随后不能使用 WebCamTexture.deviceName 将设备从常规设备更改为远程设备,反之亦然。
**注意:**对于 WebCamKind.ColorAndDepth 类型的摄像机设备(目前仅限于最新款 iOS 设备上的后置 TrueDepth 双摄像头),无法使用 WebCamDevice.depthCameraName 作为 deviceName 来创建用于接收深度数据的 WebCamTexture 实例。此 WebCamTexture 始终包含一个通道,采用半精度浮点格式,距离值以米为单位。
如果需要,还可以使用 WebCamDevice.name 作为 deviceName 创建第二个 WebCamTexture 实例以接收颜色数据。在这种情况下,颜色和深度数据都将同步。
目前,iOS 仅支持颜色/深度数据分辨率的有限组合方式。在为 ColorAndDepth 设备创建 WebCamTexture 实例时,将忽略 **requestedWidth** 和 **requestedHeight** 参数。对于 iPhone 7+/8+ 的后置双摄像头,用于颜色数据的 WebCamTexture 的尺寸为 1440x1080,而对于 iPhone X 的后置双摄像头和前置 TrueDepth 摄像头,尺寸为 1500x1126。对于 iPhone 4+/8+/X 的后置双摄像头,深度数据分辨率的最大值始终为 320x240,而对于 iPhone X 的前置 TrueDepth 摄像头,最大分辨率为 640x480。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.