Description
The Viewport
property of the CameraComponent
class represents the size of the camera's view on the screen. It is a Vector4
value that is normalized between 0 and 1, indicating the portion of the screen that the camera's view will occupy. This property is useful for setting up split-screen views or rendering multiple camera views within a single screen.
Usage
To use the Viewport
property, you can set it to a Vector4
value where each component is between 0 and 1. The components represent the x and y position of the viewport's bottom-left corner, and the width and height of the viewport, respectively.
For example, setting the Viewport
to new Vector4(0, 0, 0.5f, 0.5f)
will make the camera render its view in the bottom-left quarter of the screen.
Example
// Example of setting the Viewport property
CameraComponent camera = new CameraComponent();
// Set the viewport to the bottom-left quarter of the screen
camera.Viewport = new Vector4(0, 0, 0.5f, 0.5f);
// Set the viewport to the full screen
camera.Viewport = new Vector4(0, 0, 1, 1);