WebCamTextureConstructor

Switch to Manual
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);

Parameters

deviceName要使用的视频输入设备的名称。
requestedWidth请求的纹理宽度。
requestedHeight请求的纹理高度。
requestedFPS请求的纹理帧率。

Description

创建 WebCamTexture。

使用 WebCamTexture.devices 可获取可用摄像机设备名称列表。如果没有向构造函数提供或以 null 字符串形式传递名称,将使用找到的第一个设备。

所选摄像机可能不支持这些参数指定的请求宽度、高度和帧率。在这种情况下,将使用最接近的可用值。

创建 WebCamTexture 前请 调用 Application.RequestUserAuthorization

Note: using webcam texture on Android requires a device running Honeycomb (Android 3.0) or later.

Note: If you want to use a WebCamTexture to play the camera stream from a device connected through Unity Remote, then you must initialize it through use of the constructor. It is not possible to change the device later using WebCamTexture.deviceName from a regular device to a remote device and vice versa.

Note: For camera devices of kind WebCamKind.ColorAndDepth (currently these are only dual back and true depth cameras on latest iOS devices), it is possible to create a WebCamTexture instance to receive depth data using WebCamDevice.depthCameraName as the deviceName. This WebCamTexture always contains one channel and is in half-precision floating point format with distance values in meters.

If required, it is also possible to create a second WebCamTexture instance using WebCamDevice.name as deviceName to receive color data. In this case, both color and depth data will be synchronized.

Currently, iOS supports only limited combinations of color/depth data resolutions. requestedWidth and requestedHeight parameters are ignored, when creating WebCamTexture instances for ColorAndDepth devices. For iPhone 7+/8+ dual back cameras, the size of the WebCamTexture for color data is 1440x1080 and for iPhone X dual back and front true depth cameras, it is 1500x1126. The depth data resolution is always a maximum of 320x240 for iPhone 4+/8+/X dual back cameras and 640x480 for iPhone X front true depth cameras.