Question by
KnightRiderGuy · Mar 23, 2016 at 02:36 PM ·
c#texture2dwebcamvideotexturetv
If No Web Camera Detected Then Display a TV Test Patern
I have a video camera script that will eventually use multiple web cameras to display video depending on which camera is selected. But what I would like to do is. Say that there is no camera connected then display a TV Test pattern. Not quite sure if that makes sense but here is the script so far.
public RawImage rawimage;
WebCamTexture webCamTexture;
private string absolutePath = "./Surveillance/CamCapture/";
string fileName = "filename";
private int m_ImageID;
private string m_FileLocation;
void Start () {
if (!System.IO.Directory.Exists (absolutePath))
System.IO.Directory.CreateDirectory (absolutePath);
if (Application.isEditor)
absolutePath = "Assets/WebcamSnaps/";
WebCamDevice[] cam_devices = WebCamTexture.devices;
m_FileLocation = absolutePath;
webCamTexture = new WebCamTexture(cam_devices[0].name, 480, 640, 30);
rawimage.texture = webCamTexture;
if(webCamTexture != null){
//webCamTexture.Play();
Debug.Log(webCamTexture.deviceName);
}
}
Comment