s&box
RustCounter-Strike 2s&boxDeadlock
Wiki
Get s&box on Steam
Browse
OverviewGetting StartedCreating GamesEngine & ToolsDocumentationCommunity GamesResources
s&boxDocumentationUiHudpainter
SOURCE 2 · C#
Build and play games with s&box.

Facepunch's game engine and creation platform — make games in C#, or jump straight into community games.

Get s&box on Steam

s&box Wiki

  • Overview
  • Getting Started
  • Creating Games
  • Engine & Tools
  • Documentation
  • Community Games
  • Resources

Tools & Community

  • Getting Started
  • Creating Games
  • Engine & Tools
  • Resources

Platforms

  • RustBattle
  • CSBattle
  • Rust Game Wiki
  • CS2 Skins Wiki
  • Deadlock Wiki

About

  • Official Site
  • Developer Wiki
  • GitHub
  • Get on Steam
NOT AFFILIATED WITH FACEPUNCH STUDIOS · © 2026 s&box Wiki (community)
Docs/UI
UI

HudPainter

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 ), new Vector2( Screen.Width * 0.5f, 100 ) );
	}

Source: Facepunch/sbox-docs (CC-BY-4.0) · updated 2025-06-28. Read it rendered on the official docs.

More in UI

Localization
Razor Components
Razor Panels
Style Properties
Styling Panels
UI
UI Interactions
VirtualGrid
← All documentation

Community wiki — not affiliated with Facepunch Studios. For the latest and most authoritative information, see the official developer wiki.