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, where each component of the vector corresponds to a portion of the screen space. This property allows you to define the portion of the screen that the camera will render to, which can be useful for creating split-screen effects or rendering multiple views simultaneously.
Usage
To use the Viewport
property, you can set it to a Vector4
value where each component is a float between 0 and 1. The components represent the left, top, width, and height of the viewport, respectively, in normalized screen coordinates.
For example, setting the Viewport
to new Vector4(0, 0, 0.5f, 0.5f)
would render the camera's 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 top-right quarter of the screen
camera.Viewport = new Vector4(0.5f, 0, 0.5f, 0.5f);
// This will render the camera's view in the top-right quarter of the screen.