Quantcast
Channel: Questions in topic: "webcam"
Viewing all articles
Browse latest Browse all 256

WebGL Webcam light keeps enabled after stoping WebCamTexture

$
0
0
I'm using the following script to enable/disable the webcam on WebGL. It works fine on the Editor but on the browser, the webcam light stays on after disabling the WebcamTexture. It happens on Chrome and Firefox. Any ideas? Thanks. public void Enable() { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Enable"); #endif _enabled = true; } public void Disable() { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Disable"); #endif _enabled = false; } #region MONOBEHAVIOUR void Update() { if(_enabled) { if(_webcamTexture == null) { while(!Application.RequestUserAuthorization(UserAuthorization.WebCam).isDone) { return; } if (Application.HasUserAuthorization(UserAuthorization.WebCam)) { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Webcam authorized"); #endif _webcamTexture = new WebCamTexture (WebCamTexture.devices[0].name); _webcamTexture.Play (); } else { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.Log("Webcam NOT authorized"); #endif } } else if (_webcamTexture.isPlaying) { if(!_ready) { if (_webcamTexture.width < 100) { return; } _ready = true; } if(_webcamTexture.didUpdateThisFrame) { _aspectRatioFitter.aspectRatio = (float)_webcamTexture.width / (float)_webcamTexture.height; _imageRectTransform.localEulerAngles = new Vector3 (0, 0, -_webcamTexture.videoRotationAngle); _image.texture = _webcamTexture; } } } else { if(_webcamTexture != null) { _webcamTexture.Stop (); _webcamTexture = null; _image.texture = null; } } } #endregion

Viewing all articles
Browse latest Browse all 256

Trending Articles