public DeviceCamera(int width, int height, bool isUseEWC = true)
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        isUseEasyWebCam = isUseEWC;
        if (isUseEasyWebCam)
        {
            GameObject gameObject = new GameObject("EasyWebCamLib");
            gameObject.AddComponent <EasyWebCam>();
        }
        else
        {
#if UNITY_ANDROID
            if (EasyWebCam.checkPermissions())
            {
                previewWidth  = width;
                previewHeight = height;
                webcamera     = new WebCamTexture(width, height);
            }
#else
            previewWidth  = width;
            previewHeight = height;
            webcamera     = new WebCamTexture(width, height);
#endif
        }
#else
        webcamera = new WebCamTexture(width, height);
#endif
    }
    /// <summary>
    /// open the camera
    /// </summary>
    public void Play()
    {
        if (isRunning)
        {
            return;
        }
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (isUseEasyWebCam)
        {
            EasyWebCam.Play();
        }
        else
        {
            if (webcamera != null)
            {
                webcamera.Play();
            }
            else
            {
                webcamera = new WebCamTexture(previewWidth, previewHeight);
                webcamera.Play();
            }
        }
#else
        webcamera.Play();
#endif
        isRunning = true;
    }
Exemple #3
0
    public void Stop()
    {
        #if UNITY_ANDROID && !UNITY_EDITOR
        if (EasyWebCam.isActive)
        {
            if (isTorchOn)
            {
                torchImage.sprite = torchOffSprite;
                EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.Off);
                isTorchOn = !isTorchOn;
            }
        }
        #endif
        if (this.e_qrController != null)
        {
            this.e_qrController.StopWork();
        }

        if (this.resetBtn != null)
        {
            this.resetBtn.SetActive(false);
        }
        if (this.scanLineObj != null)
        {
            this.scanLineObj.SetActive(false);
        }
    }
Exemple #4
0
    public void TorchOff()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (EasyWebCam.isActive)
        {
            EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.Off);
        }
#endif
    }
Exemple #5
0
    /// <summary>
    /// start the work.
    /// </summary>
    public void StartWork()
    {
#if UNITY_ANDROID
        if (!EasyWebCam.checkPermissions())
        {
            requestCameraPermissions();
            return;
        }
#endif
        if (this.webcam != null)
        {
            this.webcam.Play();
        }
    }
Exemple #6
0
    /// <summary>
    /// get the width of the camera
    /// </summary>
    public int Width()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
		if(isUseEasyWebCam)
		{
		return EasyWebCam.Width();
		}
		else
		{
		return webcamera.width;
		}
#else
        return webcamera.width;
#endif
    }
Exemple #7
0
 /// <summary>
 /// get status of the camera
 /// </summary>
 /// <returns><c>true</c>, if playing was ised, <c>false</c> otherwise.</returns>
 public bool isPlaying()
 {
             #if UNITY_ANDROID && !UNITY_EDITOR
     if (isUseEasyWebCam)
     {
         return(EasyWebCam.isPlaying());
     }
     else
     {
         return(webcamera.isPlaying);
     }
             #else
     return(webcamera.isPlaying);
             #endif
 }
Exemple #8
0
 /// <summary>
 /// get the width of the camera
 /// </summary>
 public int Width()
 {
             #if UNITY_ANDROID && !UNITY_EDITOR
     if (isUseEasyWebCam)
     {
         return(EasyWebCam.Width());
     }
     else
     {
         return(webcamera.width);
     }
             #else
     return(webcamera.width);
             #endif
 }
Exemple #9
0
 /// <summary>
 /// get the height of the camera
 /// </summary>
 public int Height()
 {
             #if UNITY_ANDROID && !UNITY_EDITOR
     if (isUseEasyWebCam)
     {
         return(EasyWebCam.Height());
     }
     else
     {
         return(webcamera.height);
     }
             #else
     return(webcamera.height);
             #endif
 }
Exemple #10
0
 /// <summary>
 /// Gets the size of the webcam
 /// </summary>
 /// <returns>The size.</returns>
 public Vector2 getSize()
 {
             #if UNITY_ANDROID && !UNITY_EDITOR
     if (isUseEasyWebCam)
     {
         return(new Vector2(EasyWebCam.Width(), EasyWebCam.Height()));
     }
     else
     {
         return(new Vector2(webcamera.width, webcamera.height));
     }
             #else
     return(new Vector2(webcamera.width, webcamera.height));
             #endif
 }
Exemple #11
0
    /// <summary>
    /// get the height of the camera
    /// </summary>
    public int Height()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
		if(isUseEasyWebCam)
		{
			return  EasyWebCam.Height();
		}
		else
		{
			return webcamera.height;
		}

#else
        return webcamera.height;
#endif
    }
Exemple #12
0
    /// <summary>
    /// get status of the camera
    /// </summary>
    /// <returns><c>true</c>, if playing was ised, <c>false</c> otherwise.</returns>
    public bool isPlaying()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
		if(isUseEasyWebCam)
		{
		return EasyWebCam.isPlaying ();
		}
		else
		{
		return webcamera.isPlaying;
		}

#else
        return webcamera.isPlaying;
#endif
    }
Exemple #13
0
 /// <summary>
 /// Toggles the torch by click the ui button
 /// note: support the feature by using the EasyWebCam Component
 /// </summary>
 public void toggleTorch()
 {
             #if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
     if (EasyWebCam.isActive)
     {
         if (isTorchOn)
         {
             torchImage.sprite = torchOffSprite;
             EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.Off);
         }
         else
         {
             torchImage.sprite = torchOnSprite;
             EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.On);
         }
         isTorchOn = !isTorchOn;
     }
             #endif
 }
Exemple #14
0
    /// <summary>
    /// open the camera
    /// </summary>
    public void Play()
    {
        if (isRunning)
        {
            return;
        }
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
		if(isUseEasyWebCam)
		{
			EasyWebCam.Play();
		}
		else{
			webcamera.Play ();
		}
#else
        webcamera.Play();
#endif
        isRunning = true;
    }
Exemple #15
0
    /// <summary>
    /// Toggles the torch by click the ui button
    /// note: support the feature by using the EasyWebCam Component
    /// </summary>
    public void ToggleTorch()
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (EasyWebCam.isActive)
        {
            if (isTorchOn)
            {
                torchOff.SetActive(true);
                torchOn.SetActive(false);
                EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.Off);
            }
            else
            {
                torchOff.SetActive(false);
                torchOn.SetActive(true);
                EasyWebCam.setTorchMode(TBEasyWebCam.Setting.TorchMode.On);
            }
            isTorchOn = !isTorchOn;
        }
#endif
    }
Exemple #16
0
    /// <summary>
    /// Stop this camera.
    /// </summary>
    public void Stop()
    {
        if (!isRunning)
        {
            return;
        }

                #if UNITY_ANDROID && !UNITY_EDITOR
        if (isUseEasyWebCam)
        {
            EasyWebCam.Stop();
        }
        else
        {
            webcamera.Stop();
        }
                #else
        webcamera.Stop();
                #endif
        isRunning = false;
    }
    /// <summary>
    /// Stop this camera.
    /// </summary>
    public void Stop()
    {
        if (!isRunning)
        {
            return;
        }
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        if (isUseEasyWebCam)
        {
            EasyWebCam.Stop();
        }
        else
        {
            if (webcamera != null)
            {
                webcamera.Stop();
            }
        }
#else
        webcamera.Stop();
#endif
        isRunning = false;
    }
Exemple #18
0
    /// <summary>
    /// open the camera
    /// </summary>
    public void Play()
    {
        if (isRunning)
        {
            return;
        }
#if UNITY_ANDROID && !UNITY_EDITOR
        if (isUseEasyWebCam)
        {
            EasyWebCam.Play();
        }
        else
        {
            webcamera.Play();
        }
#else
        if (UnityEngine.WebCamTexture.devices.Length > 0)
        {
            webcamera.Play();
        }
#endif
        isRunning = true;
    }
    public DeviceCamera(bool isUseEWC = true)
    {
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        isUseEasyWebCam = isUseEWC;
        if (isUseEasyWebCam)
        {
            GameObject webCamObject = new GameObject("EasyWebCamLib");
            webCamObject.AddComponent <EasyWebCam>();
        }
        else
        {
#if UNITY_ANDROID
            if (EasyWebCam.checkPermissions())
            {
                webcamera = new WebCamTexture(640, 480);
            }
#else
            webcamera = new WebCamTexture(640, 480);
#endif
        }
#else
        webcamera = new WebCamTexture(640, 480);
#endif
    }