WebcamSource
Manages the webcam functionality.
Last updated
Manages the webcam functionality.
Last updated
Inherits class.
WebcamSource()
Creates a new WebcamSource object.
WebcamIndex
int
Read-Only. The webcam device index.
WebcamTexture
Read-Only. The WebcamTexture onto which the live video input is rendered.
Timestamp
DateTime
Read-Only. Overriden. The frame timestamp.
IsOpen
bool
Read-Only. If the camera is currently playing and its Width and Height are greater than 16 pixels each.
IsPlaying
bool
Read-Only. If the camera is currently playing.
Width
int
Read-Only. Overriden. The width of the WebcamTexture in pixels.
Height
int
Read-Only. Overriden. The height of the WebcamTexture in pixels.
Rotation
int
Read-Only. Overriden. The rotation of the camera.
Pixels
Read-Only. Overriden. The pixel color data for a mipmap level as Color32 structs.
Pointer
IntPtr
Read-Only. Overriden. A native pointer to the WebcamTexture resource.
Open
void
Starts the camera if the app is granted access.
Close
void
Closes the camera.
Pause
void
Pauses the camera.
SwitchCamera(int)
void
Closes the open camera and opens the camera with the specified device index.
The example shows how to manage webcam functionality with the WebcamSource
class.
To create a Webcam
Source, add a field for Unity to serialize.
Open the webcam to get the live feed.
To get the camera feed, first add an ImageView
field for Unity to serialize. Then, if the webcam is open and has a new frame, draw the texture.
Close the webcam to stop the live feed.
[]