Exemplo n.º 1
0
        void OnCaptured(CaptureCamera captureCamera)
        {
            RawImage.enabled = true;
            RawImage.texture = captureCamera.CaptureImage;
            LetterBoxCamera letterBoxCamera = captureCamera.GetComponent <LetterBoxCamera>();

            if (letterBoxCamera != null)
            {
                RawImage.rectTransform.SetSize(letterBoxCamera.CurrentSize);
                //ズームが1ではなく、このイメージを描画するカメラのキャプチャ画像かどうか
                if (letterBoxCamera.Zoom2D != 1)
                {
                    int layerMask = 1 << this.gameObject.layer;
                    if ((letterBoxCamera.CachedCamera.cullingMask & layerMask) != 0)
                    {
                        Vector2 pivot = letterBoxCamera.Zoom2DCenter;
                        pivot.x /= letterBoxCamera.CurrentSize.x;
                        pivot.y /= letterBoxCamera.CurrentSize.y;
                        pivot    = -pivot + Vector2.one * 0.5f;
                        RawImage.rectTransform.pivot      = pivot;
                        RawImage.rectTransform.localScale = Vector3.one / letterBoxCamera.Zoom2D;
                    }
                }
            }
            else
            {
                RawImage.rectTransform.SetSize(Screen.width, Screen.height);
            }

            //カメラのキャプチャコンポーネントを無効にする
            captureCamera.OnCaptured.RemoveListener(OnCaptured);
            captureCamera.enabled = false;
        }
Exemplo n.º 2
0
        void OnCaptured(CaptureCamera captureCamera)
        {
            RawImage.enabled = true;
            RawImage.texture = captureCamera.CaptureImage;
            LetterBoxCamera letterBoxCamera = captureCamera.GetComponent <LetterBoxCamera>();

            if (letterBoxCamera != null)
            {
                RawImage.rectTransform.SetSize(letterBoxCamera.CurrentSize);
            }
            else
            {
                RawImage.rectTransform.SetSize(Screen.width, Screen.height);
            }

            //カメラのキャプチャコンポーネントを無効にする
            captureCamera.OnCaptured.RemoveListener(OnCaptured);
            captureCamera.enabled = false;
        }