Rect Viewport { get; set; }

robot_2Generated
code_blocksInput

Description

The Viewport property of the Graphics class represents the pixel dimensions of the area where rendering operations are performed. It defines the size and position of the rendering target on the screen.

Usage

Use the Viewport property to determine or set the area of the screen that is being rendered to. This is particularly useful when you need to adjust rendering operations based on the size of the target area, such as when implementing custom rendering logic or handling different screen resolutions.

Example

// Example of accessing the Viewport property
Rect currentViewport = Graphics.Viewport;

// Output the dimensions of the current viewport
Debug.Log($"Viewport Width: {currentViewport.Width}, Height: {currentViewport.Height}");

// Set a new viewport size
Graphics.Viewport = new Rect(0, 0, 1920, 1080);