Description
The Overlay
property of the CameraComponent
class provides access to a HudPainter
object. This object is used to draw elements directly onto the screen, overlaying all other rendered content. It is particularly useful for creating debug overlays or other UI elements that need to be visible on top of everything else in the scene.
Usage
To use the Overlay
property, you can access it from an instance of CameraComponent
. You can then use the HudPainter
methods to draw shapes, text, or other graphics on the screen. This is typically done in the rendering loop or a similar update method where you want to ensure the overlay is drawn every frame.
Example
// Example of using the Overlay property to draw a simple rectangle on the screen
public class MyCameraComponent : CameraComponent
{
public override void Update()
{
base.Update();
// Access the Overlay property
var overlay = this.Overlay;
// Begin drawing
overlay.Begin();
// Draw a rectangle at the top-left corner of the screen
overlay.DrawRect(new Rect(10, 10, 100, 50), Color.Red);
// End drawing
overlay.End();
}
}