public void StartDialog(Dialog dialog, bool freezeGame, bool zoom, float zoomValue = 0f) { //animator.SetBool("IsOpen", true); zoomCamera = zoom; if (zoomCamera) { // just a reminder, zoom should always be postive ppc.targetCameraHalfHeight = zoomValue <= float.Epsilon ? 2.5f : zoomValue; ppc.adjustCameraFOV(); } stopTime = freezeGame; nameText.text = dialog.name; sentences.Clear(); //Debug.Log("Open dialog"); OpenDialog(); foreach (string sentence in dialog.sentences) { sentences.Enqueue(sentence); } DisplayNextSentence(); }
public override void Execute(GameObject GameActor) { //Grab the cameras I need to adjust, this assumes that the gameobject passed in has both cameras attatched PixelPerfectCamera PixelCam = GameActor.GetComponent <PixelPerfectCamera>(); Camera ActualCam = GameActor.GetComponent <Camera>(); //Check if a new zoom level has been requested if (z != 0) { //The pixel camera will only allow orthographic sizes that don't distort pixels. So by adjusting z, a desired size is being requested not set. PixelCam.targetCameraHalfHeight -= Mathf.Clamp(z, -1, 1); PixelCam.targetCameraHalfHeight = Mathf.Clamp(PixelCam.targetCameraHalfHeight, 2, 10); } //This returns a valid orthographic size to be lerped to. (I can probably figure out a way to not call this every frame) float newZoom = PixelCam.adjustCameraFOV(true); //Now we lerp to the closest valid size. this can be smoothed out better, but good enough for now. ActualCam.orthographicSize = Mathf.Lerp(ActualCam.orthographicSize, newZoom, Time.smoothDeltaTime * sens); }