Skip to content

unitycoder/UnityWebcamTool

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UnityWebcamTool

WebTool.cs is a simple script to control webcam in Unity. There is a Test_WebcamTool sample scene showing how to use the script.

How to Use

  • Attach WebTool.cs to a GameObject.
  • In the inpector, set your webcam device name and requested resolution.
  • (optional) Assign a material to apply the WebCamTexture.
  • In another script, reference to the WebTool component and call Init() function in Start(). Enter play mode and your webcam will be opened. If targetMaterial is assigned in the previous step, its mainTexture will be automatically replaced with WebCamTexture.

Scripting Reference

  • Init() opens webcam and starts rendering to WebCamTexture. If targetMaterial has been assigned, its mainTexture will be automatically replaced with WebCamTexture.
  • Texture GetWebcamTex() returns the WebCamTexture.
  • SetToMaterial(Material _material) applys WebCamTexture to the material's mainTexture.
  • PauseWebcam() pauses the webcam input.
  • PlayWebcam() starts the webcam input.

Note

This project use Git submodule gm_WebcamTool. You need to call

git clone --recurse-submodules <URL>

when you clone this reposiory.

About

Simple scripts to control webcam in Unity.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%