- Home /
Question by
vereonis · Nov 27, 2019 at 10:16 AM ·
cameraorthographicorthographic camera
Animate turning orthographic camera view on and off (like in editor)
In the editor when you press the "2D" button (usually top left of scene) this toggles orthographic on an off. In the editor doing this animates the transition, I'd like this transition in game.
I currently simply have a function toggling orthographic on and off which snaps the change.
private void toggleCameraView()
{
if (Input.GetKeyDown(KeyCode.F2))
{
if (Camera.main.orthographic)
{
Camera.main.orthographic = false;
}
else
{
Camera.main.orthographic = true;
}
}
}
I've tried applying solutions previously given for this, however these answers range from 6-10 years ago and all give me deprecation errors and won't run. E.g. This answer from 20013 or This forum post from 2009
Comment