HudPainter - Use cases?

Started by fishy · one year ago · 3 replies · 79 views

#1
fishy
Member
JoinedFeb 2023 Posts82 Score1,548
Had a discussion on Discord about HudPainter and it's use cases - the documentation kind of just leaves me with more questions than answers.

https://sbox.game/dev/doc/systems/ui/painting-a-hud/

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 Razor panels, but it is not interactive. 

What exactly is the use case for this?

When it says more efficient, is that in terms of performance? Or more efficient in the time/effort it takes to do, whatever HudPainter is designed to do? 

Why would/should HudPainter be used instead of a screen panel + Razor component combo? What can we do with this that we couldn't or shouldn't do in Razor?
#2
matt
Facepunch
JoinedApr 2021 Posts267 Score2,045
If you are making a crosshair it's simpler and quicker in terms of code and performance to draw 4 lines instead of clumsily laying out 4 panels in UI

You wouldn't make a game on the web out of divs and css
#3
fishy
Member
JoinedFeb 2023 Posts82 Score1,548
Okay thanks, by the sounds of it, it's a pretty limited/unique use case for things like crosshairs then. 
#4
garry
Facepunch
JoinedApr 2021 Posts436 Score2,270
Under the good the HudPainter is a CommandList, so it's a real clean, easy way to draw to the HUD. It's simple stuff at the minute but our intention is to expand it over time, so it's really powerful and simple.
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.