Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

WebCamTexture.WebCamTexture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function WebCamTexture()
public WebCamTexture();
public def WebCamTexture()
public function WebCamTexture(requestedWidth: int, requestedHeight: int, requestedFPS: int)
public WebCamTexture(int requestedWidth, int requestedHeight, int requestedFPS);
public def WebCamTexture(requestedWidth as int, requestedHeight as int, requestedFPS as int)
public function WebCamTexture(requestedWidth: int, requestedHeight: int)
public WebCamTexture(int requestedWidth, int requestedHeight);
public def WebCamTexture(requestedWidth as int, requestedHeight as int)
public function WebCamTexture(deviceName: string)
public WebCamTexture(string deviceName);
public def WebCamTexture(deviceName as string)
public function WebCamTexture(deviceName: string, requestedWidth: int, requestedHeight: int)
public WebCamTexture(string deviceName, int requestedWidth, int requestedHeight);
public def WebCamTexture(deviceName as string, requestedWidth as int, requestedHeight as int)
public function WebCamTexture(deviceName: string, requestedWidth: int, requestedHeight: int, requestedFPS: int)
public WebCamTexture(string deviceName, int requestedWidth, int requestedHeight, int requestedFPS);
public def WebCamTexture(deviceName as string, requestedWidth as int, requestedHeight as int, requestedFPS as int)

Parameters

deviceName The name of the video input device to be used.
requestedWidth The requested width of the texture.
requestedHeight The requested height of the texture.
requestedFPS The requested frame rate of the texture.

Description

Create a WebCamTexture.

Use WebCamTexture.devices to get a list of the names of available camera devices. If no device name is supplied to the constructor or is passed as a null string, the first device found will be used.

The requested width, height and framerate specified by the parameters may not be supported by the chosen camera. In such cases, the closest available values will be used.

Note: if you want to use WebCamTextures in the web player, you need to get the user's permission to do so. Call Application.RequestUserAuthorization before creating a WebCamTexture.

Note: if you want to use WebCamTexture to play the camera stream from device connected through Unity Remote, then you must initalize it through the constructor. Later it's not possible to change device using WebCamTexture.deviceName from regular devices to remote devices and vice versa.