Exemplo n.º 1
0
        private void SetupMirrorMode(WebcamMirrorModes mirrorMode)
        {
            if (mirrorMode == WebcamMirrorModes.None)
            {
                if (_mirrorCamera != null)
                {
                    Destroy(_mirrorCamera.gameObject);
                }
                return;
            }

            if (_mirrorCamera == null)
            {
                GameObject child = new GameObject("Webcam Display");
                child.transform.SetParent(transform, false);
                _mirrorCamera                     = child.AddComponent <Camera>();
                _mirrorCamera.cullingMask         = _compositeCamera.cullingMask;
                _mirrorCamera.clearFlags          = _compositeCamera.clearFlags;
                _mirrorCamera.backgroundColor     = _compositeCamera.backgroundColor;
                _mirrorCamera.projectionMatrix    = _compositeCamera.projectionMatrix;
                _mirrorCamera.fieldOfView         = _compositeCamera.fieldOfView;
                _mirrorCamera.nearClipPlane       = _compositeCamera.nearClipPlane;
                _mirrorCamera.farClipPlane        = _compositeCamera.farClipPlane;
                _mirrorCamera.useOcclusionCulling = _compositeCamera.useOcclusionCulling;
                _mirrorCamera.allowHDR            = _compositeCamera.allowHDR;
                _mirrorCamera.depth               = 100;

                _drawMirrorMode.name = "Mirror Mode Quad";
                _mirrorCamera.AddCommandBuffer(CameraEvent.AfterEverything, _drawMirrorMode);
                _drawMirrorMode.Blit(_compositeCamera.targetTexture, BuiltinRenderTextureType.CameraTarget);
            }

            _mirrorCamera.targetDisplay = (int)mirrorMode;
        }
Exemplo n.º 2
0
 private void OnWebcamStateChanged(WebcamMirrorModes modeChangedTo)
 {
     foreach (var listener in _listeners)
     {
         listener.OnStateChanged(modeChangedTo);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// When the Mirror Mode is changed the window will be minimized
 /// </summary>
 /// <param name="changedToMode"></param>
 public void OnStateChanged(WebcamMirrorModes changedToMode)
 {
     Screen.SetResolution(1280, 720, false);
     if (changedToMode == WebcamMirrorModes.None && !Application.isEditor)
     {
         IntPtr unityWindowHandle = UnityWindowHandleUtility.GetUnityWindowHandle();
         if (unityWindowHandle != IntPtr.Zero)
         {
             User32interop.ShowWindowAsync(unityWindowHandle, MinimizeWindow);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Handles assignment/removal of the canvas shown in place of the Webcam.
 /// </summary>
 /// <param name="changedToMode"></param>
 public void OnStateChanged(WebcamMirrorModes changedToMode)
 {
     if (changedToMode == WebcamMirrorModes.None)
     {
         if (!_webcamUi)
         {
             GameObject UiResourceRef = (GameObject)Resources.Load("Prefabs/MetaLogoCanvas");
             _webcamUi           = GameObject.Instantiate(UiResourceRef);
             _webcamUi.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
             foreach (Transform t in _webcamUi.transform)
             {
                 t.gameObject.hideFlags = HideFlags.HideInHierarchy | HideFlags.HideInInspector;
             }
         }
     }
     else if (_webcamUi != null)
     {
         GameObject.Destroy(_webcamUi);
         _webcamUi = null;
     }
 }
Exemplo n.º 5
0
 public void OnStateChanged(WebcamMirrorModes changedToMode)
 {
     SetupMirrorMode(changedToMode);
     _targetDisplay = changedToMode;
 }