示例#1
0
 public CameraMat(CanvasOrderUpdater canvasOrderUpdater, bool isNecessaryForBlurryBack)
 {
     this.CanvasOrderUpdater       = canvasOrderUpdater;
     this.IsNecessaryForBlurryBack = isNecessaryForBlurryBack;
 }
        void SetCameraToCanvases()
        {
            var dictinoaryPool = DictionaryPool <CanvasOrderUpdater, CameraMat> .Pool;
            var cameraMats     = dictinoaryPool.Get();

            foreach (CameraMat cameraMat in cameraMatRepository.EnumerateCameraMats())
            {
                cameraMats.Add(cameraMat.CanvasOrderUpdater, cameraMat);
            }

            // camera数の調整
            int cameraCount = cameraMats.Count + 1;

            AdjustCameraCount(cameraCount, ref cameraList);

            IEnumerable <CanvasInStratum> sortedCanvases = canvasRepository.EnumerateCanvases();
            // CanvasRepositoryの内部実装によりorder in layerの降順で列挙されるので
            // 以下のOrderByDescendingは省略することができる
            //.OrderByDescending((CanvasInStratum canvas) => canvas.CanvasOrderUpdater.CanvasOrder);

            int            cameraIndex          = cameraCount - 1;
            CameraInStudio cameraInStudio       = cameraList[cameraIndex];
            Camera         camera               = (cameraInStudio.CameraOperator as ICameraHolder).Camera;
            float          maxBlurryCameraDepth = -1f;

            foreach (CanvasInStratum canvas in sortedCanvases)
            {
                CanvasOrderUpdater canvasOrderUpdater = canvas.CanvasOrderUpdater;
                CameraMat          cameraMat;
                if (cameraMats.TryGetValue(canvasOrderUpdater, out cameraMat))
                {
                    canvasOrderUpdater.SetCamera(camera);

                    cameraIndex--;
                    if (cameraIndex < 0)
                    {
                        Debug.LogError("Unexpected camera index: " + cameraIndex);
                        cameraIndex = 0;
                    }
                    cameraInStudio = cameraList[cameraIndex];
                    camera         = (cameraInStudio.CameraOperator as ICameraHolder).Camera;

                    // Blurをかける最大Depthを取得しておく
                    if (cameraMat.IsNecessaryForBlurryBack &&
                        maxBlurryCameraDepth < camera.depth)
                    {
                        maxBlurryCameraDepth = camera.depth;
                    }
                }
                else
                {
                    canvasOrderUpdater.SetCamera(camera);
                }
            }

            // CameraListを取得しBlurをかける/外す
            foreach (CameraInStudio c in cameraBank.EnumerateCameras())
            {
                c.CameraOperator.SetBlur(c.CameraOperator.CameraDepth <= maxBlurryCameraDepth);
            }

            dictinoaryPool.Put(cameraMats);
        }
 public CanvasInStratum(int stratumId, int orderInStratum, CanvasOrderUpdater canvasOrderUpdater)
 {
     this.StratumId          = stratumId;
     this.OrderInStratum     = orderInStratum;
     this.CanvasOrderUpdater = canvasOrderUpdater;
 }