Vector2 Size { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Screen.Size property provides the total size of the game screen as a Vector2 value. This property is static and can be accessed without instantiating the Screen class. It represents the width and height of the screen in a single vector, where the x-component is the width and the y-component is the height.

Usage

Use the Screen.Size property to retrieve the current dimensions of the game screen. This can be useful for layout calculations, UI scaling, or any functionality that depends on the screen size.

Example

// Example of accessing the screen size
Vector2 screenSize = Screen.Size;
float screenWidth = screenSize.x;
float screenHeight = screenSize.y;

// Use the screen size for layout calculations
float centerX = screenWidth / 2;
float centerY = screenHeight / 2;

// Output the screen size
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use in-game UI or logging systems
Log.Info($"Screen Size: {screenWidth}x{screenHeight}");