menu_bookDocumentation
s&box HUD: UI scale factor
HUD Static Class
HUD is an internal static class that provides a scale factor for UI elements based on screen resolution. It ensures UI elements scale proportionally across different display sizes.
Type Signature
CSHARP
internal static class Hud
{
public static float Scale => Screen.Height / 1080.0f;
}Properties
Scale
Returns a scale factor based on the current screen height relative to 1080p. This allows UI elements to scale proportionally on different resolutions.Usage
CSHARP
// Get the current HUD scale factor
var scale = Hud.Scale;
// Scale a UI element
var elementSize = 100 * Hud.Scale;
// Scale position
var position = new Vector2(100, 100) * Hud.Scale;Notes
- Internal class (not intended for public API)
- Scale is calculated as Screen.Height / 1080.0
- 1080p is the reference resolution
- Scale is read-only (computed property)
- Used for responsive UI scaling
- Ensures consistent UI appearance across resolutions
Was this helpful?