10#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
13 return EasyWebCam.WebCamPreview;
25 WebCamTexture webcamera;
27 bool isUseEasyWebCam =
true;
29 int previewWidth = 640;
30 int previewHeight = 480;
34#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
35 isUseEasyWebCam = isUseEWC;
38 GameObject webCamObject =
new GameObject(
"EasyWebCamLib");
39 webCamObject.AddComponent<EasyWebCam>();
44 if(EasyWebCam.checkPermissions())
46 webcamera =
new WebCamTexture (640, 480);
49 webcamera =
new WebCamTexture (640, 480);
53 webcamera =
new WebCamTexture(640, 480);
59#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
60 isUseEasyWebCam = isUseEWC;
63 GameObject gameObject =
new GameObject(
"EasyWebCamLib");
64 gameObject.AddComponent<EasyWebCam>();
69 if(EasyWebCam.checkPermissions())
72 previewHeight = height;
73 webcamera =
new WebCamTexture (width, height);
77 previewHeight = height;
78 webcamera =
new WebCamTexture (width, height);
82 webcamera =
new WebCamTexture(width, height);
91 if (isRunning)
return;
92#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
104 webcamera =
new WebCamTexture (previewWidth, previewHeight);
110 foreach (var webCamDevice
in WebCamTexture.devices)
112 if (webCamDevice.name ==
"UVC Camera")
continue;
115 webcamera =
new WebCamTexture(webCamDevice.name, 640, 480);
126 if (!success)
throw new Exception(
"No usable webcamera found!");
136 if (!isRunning)
return;
137#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
144 if(webcamera !=
null)
161#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
164 return new Vector2(EasyWebCam.Width(), EasyWebCam.Height());
168 return new Vector2(webcamera.width, webcamera.height);
171 return new Vector2(webcamera.width, webcamera.height);
180#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
183 return EasyWebCam.Width();
187 return webcamera.width;
190 return webcamera.width;
199#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
202 return EasyWebCam.Height();
206 return webcamera.height;
210 return webcamera.height;
220#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
223 return EasyWebCam.isPlaying ();
227 return webcamera.isPlaying;
231 return webcamera.isPlaying;
241#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
244 return EasyWebCam.WebCamPreview.GetPixels();
248 return webcamera.GetPixels();
252 return webcamera.GetPixels();
266#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
269 return EasyWebCam.WebCamPreview.GetPixels(x,y,targetWidth,targetHeight);
273 return webcamera.GetPixels(x,y,targetWidth,targetHeight);
277 return webcamera.GetPixels(x, y, targetWidth, targetHeight);
287#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
290 return EasyWebCam.WebCamPreview.GetPixels32();
294 return webcamera.GetPixels32();
297 return webcamera.GetPixels32();
int Width()
get the width of the camera
Color32[] GetPixels32()
Gets the pixels32 of the camera
DeviceCamera(bool isUseEWC=true)
int Height()
get the height of the camera
bool isPlaying()
get status of the camera
Color[] GetPixels(int x, int y, int targetWidth, int targetHeight)
get the pixels of the camera image by using the target rect range
void Play()
open the camera
void Stop()
Stop this camera.
Vector2 getSize()
Gets the size of the webcam
Color[] GetPixels()
get the Pixels of the camera image
DeviceCamera(int width, int height, bool isUseEWC=true)