WebCamTextureConstructor

切换到手册
public WebCamTexture ();
public WebCamTexture (int requestedWidth, int requestedHeight, int requestedFPS);
public WebCamTexture (int requestedWidth, int requestedHeight);
public WebCamTexture (string deviceName);
public WebCamTexture (string deviceName, int requestedWidth, int requestedHeight);
public WebCamTexture (string deviceName, int requestedWidth, int requestedHeight, int requestedFPS);

参数

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 实例时,将忽略 requestedWidthrequestedHeight 参数。对于 iPhone 7+/8+ 的后置双摄像头,用于颜色数据的 WebCamTexture 的尺寸为 1440x1080,而对于 iPhone X 的后置双摄像头和前置 TrueDepth 摄像头,尺寸为 1500x1126。对于 iPhone 4+/8+/X 的后置双摄像头,深度数据分辨率的最大值始终为 320x240,而对于 iPhone X 的前置 TrueDepth 摄像头,最大分辨率为 640x480。