Last Updated on 2021-10-31 by Clay
When we using Unity to make a 2D game, if you want to keep the aspect ratio of the camera shooting unchanged, but you want to dynamically adjust the shooting range, then we can adjust the orthographicSize
parameter.
This parameter will directly affect the size
in the camera properties.
Adjust Camera Size with Program
The fastest way is to use:
Camera.main.orthographicSize = SIZE;
SIZE
is the size of the camera range you want.
References
- https://docs.unity3d.com/ScriptReference/Camera-orthographicSize.html
- https://answers.unity.com/questions/174002/what-is-the-relationship-between-camera-size-units.html