HudPainter
Each camera has a HudPainter that can be used to draw onto the HUD. You do this every frame, in any Update function.
Each camera has a HudPainter that can be used to draw onto the HUD. You do this every frame, in any Update function.
This is more efficient than using actual UI panels because there's no layout, stylesheets or interactivity.. you're doing all that stuff yourself.
If your UI is relatively simple, you can do it this way to keep things easy.
protected override void OnUpdate()
{
if ( Scene.Camera is null )
return;
var hud = Scene.Camera.Hud;
hud.DrawRect( new Rect( 300, 300, 10, 10 ), Color.White );
hud.DrawLine( new Vector2( 100, 100 ), new Vector2( 200, 200 ), 10, Color.White );
hud.DrawText( new TextRendering.Scope( "Hello!", Color.Red, 32 ), Screen.Width * 0.5f );
}
Referenced API
Canonical API pages mentioned in this guide.
A 2-dimensional vector. Typically represents a position, size, or direction in 2D space.
Represents a rectangle.
Access screen dimension etc.
No summary available.
No summary available.
The width of the game screen. Equal to Screen.x
No summary available.
When enabled, called every frame