Add letterboxing or pillarboxing to your cameras in Unity3d.
Letterboxer makes it easy to automatically add letterboxing, pillarboxing, or pixel perfect view scaling to your camera's view. It also updates while in edit mode to give you real-time previews of letterboxing in the game view.
Copy the Letterboxer
folder into your Assets
folder.
- Add the
Letterboxer
component to yourCamera
GameObject. If aCamera
component doesn't exist on the GameObject, one will be added. - Change the
Target Width
andTarget Height
options to suit your needs. These will be used to determine the aspect ratio for theMaintain Aspect Ratio
mode, or the base size for theBest Pixel Perfect Fit
mode. - Set the
Type
option, both of which will be described in more detail below.
- Target Width: The ideal width of your game view.
- Target Height: The idea height of your game view.
- Type: The type of view scaling behaviour to use. There are two options currently.
- Maintain Aspect Ratio: Scales the view to fill the screen as much as possible while maintaining aspect ratio. If the resolution doesn't match the target width or height, letterboxing or pillarboxing will be added.
- Best Pixel Perfect Fit: Scales your view by pixel perfect increments like 1x, 2x, 3x, etc. This ensures equal pixel sizes. For example for a base size of 200x200, view size will be fixed to sizes like 200x200, 400x400, etc depending on screen size.
This project contains a demo in the LetterboxDemo
folder. This includes an example of a camera with the Letterboxer
component attached. To see how Letterboxer
behaves, simply change the values on the component attached to the camera.