A Unity script to adjust camera size according to different aspect ratios.
- Automatically adjust the camera's size so that the center area always keeps its original aspect ratio.
- Use pillarboxing if the target screen is wider than original.
- Use letterboxing if the target screen is taller than original.
- Support both orthographic and perspective cameras.
- Preview of original aspect ratio viewport.
- Import the unitypackage into your Unity project.
- Make sure that the CameraSizeAdjusterEditor.cs is under an Editor folder.
- Attach CameraSizeAdjuster.cs onto your camera object.
- Set the Base Aspect Ratio field to your desired original aspect ratio.
- When your camera is under orthograpic projection, set the Base Camera Size field to your desired original camera size.
- Notice that the size of your camera changes properly responding to different screen sizes.
- When your camera is under perspective projection, set the Base Camera FOV field to your desired original camera FOV.
- Notice that the field of view of your camera changes properly responding to different screen sizes.
- You can toggle on the Show Base Aspect Area field to show a preview of your original aspect ratio viewport.