Description
The CustomSize
property of the CameraComponent
class allows you to specify a custom aspect ratio for the camera. By default, the camera size is determined by the screen size or the render target size. This property is useful when you need to override the default behavior and set a specific aspect ratio for rendering purposes.
Usage
To use the CustomSize
property, assign a Vector2
value representing the desired width and height ratio. If you do not set this property, the camera will use the default screen or render target size.
Note that this property is marked with the JsonIgnore
and Hide
attributes, indicating that it is not serialized to JSON and is hidden in certain contexts, such as the editor.
Example
// Example of setting a custom aspect ratio for a camera
CameraComponent camera = new CameraComponent();
// Set a custom aspect ratio of 16:9
camera.CustomSize = new Vector2(16, 9);
// Reset to default behavior by setting it to null
camera.CustomSize = null;