Пример #1
0
        public void LateUpdate()
        {
            UpdateDofMode();

            Vector3 player_pos;
            Vector3 skate_pos;

            if (XLGraphics.Instance.IsReplayActive())
            {
                if (replay_skater == null)
                {
                    GetReplaySkater();
                }
                player_pos = replay_skater.position;
                skate_pos  = replay_skateboard.position;
            }
            else
            {
                player_pos = PlayerController.Instance.skaterController.skaterTransform.position;
                skate_pos  = PlayerController.Instance.boardController.boardTransform.position;
            }

            if (dof == null)
            {
                dof = PresetManager.Instance.overriderVolume.profile.Add <DepthOfField>();
                dof.SetAllOverridesTo(true);
            }

            // activate DoF override only when using custom focus
            dof.active = useCustomFocus;
            if (useCustomFocus)
            {
                var camera = CustomCameraController.Instance.mainCamera;
                //camera. = 100;
                if (customFocusMode == FocusMode.Player)
                {
                    dof.focusMode.value     = UnityEngine.Rendering.HighDefinition.DepthOfFieldMode.UsePhysicalCamera;
                    dof.focusDistance.value = Vector3.Distance(player_pos, camera.transform.position);
                }
                else if (customFocusMode == FocusMode.Skate)
                {
                    dof.focusMode.value     = UnityEngine.Rendering.HighDefinition.DepthOfFieldMode.UsePhysicalCamera;
                    dof.focusDistance.value = Vector3.Distance(player_pos, camera.transform.position);
                }
            }
        }
Пример #2
0
        ///Enable the Director Camera, while disabling the main camera if any
        public static void Enable()
        {
            //init gamecamera if any
            if (gameCamera == null)
            {
                var main = Camera.main;
                if (main != null && main != renderCamera)
                {
                    gameCamera = main.GetAddComponent <GameCamera>();
                }
            }

            //use gamecamera and disable it
            if (gameCamera != null)
            {
                gameCamera.gameObject.SetActive(false);
                if (matchMainWhenActive)
                {
                    var tempFOV = current.fieldOfView;
                    renderCamera.CopyFrom(gameCamera.cam);
                    if (ignoreFOVChanges)
                    {
                        renderCamera.fieldOfView = tempFOV;
                    }
                }

                //set the root pos/rot
                current.transform.position = gameCamera.position;
                current.transform.rotation = gameCamera.rotation;
            }

            //reset render camera local pos/rot
            renderCamera.transform.localPosition = Vector3.zero;
            renderCamera.transform.localRotation = Quaternion.identity;

            //set render camera to MainCamera if option enabled
            if (setMainWhenActive)
            {
                renderCamera.gameObject.tag = "MainCamera";
            }

            ///enable
            if (autoHandleActiveState)
            {
                renderCamera.gameObject.SetActive(true);
            }

#if SLATE_USE_POSTSTACK
            quickPostDOF = ScriptableObject.CreateInstance <DepthOfField>();
            quickPostDOF.enabled.Override(true);
            quickPostDOF.SetAllOverridesTo(true);
            quickPostVolume = PostProcessManager.instance.QuickVolume(postVolumeLayer, 100, quickPostDOF);
            quickPostVolume.gameObject.hideFlags = HideFlags.None;
#endif

            isEnabled      = true;
            lastTargetShot = null;

            if (onActivate != null)
            {
                onActivate();
            }
        }