S&box Wiki

Log in to edit

Overview of DebugOverlay

<cat>Code.Editor</cat> <title>Overview of DebugOverlay</title> # Overview of the DebugOverlay System The debug overlay system in s&box is very easy to use and fairly useful for debugging purposes, below is a example of how you can draw debug screen text and a sphere using `DebugOverlay.ScreenText()` you can find all other DebugOverlay methods [here](https://sbox.game/dev/api/Sandbox.DebugOverlaySystem) In this example we'll simply be using the `OnUpdate()` method to call our DebugOverlay ScreenText and OnStart for the Sphere. ```cs protected override void OnStart() { // Sphere will disappear after 5 seconds DebugOverlay.Sphere(new Sphere(Vector3.Zero, 10f), Color.Green, 5f); } protected override void OnUpdate() { const string name = "Cool Game!"; DebugOverlay.ScreenText(new Vector2(400, 500), $"This is my {name}"); } ``` Below is the result of the code snippet in the scene. <upload src="a9972/8dd42ebc3a75257.png" size="311293" name="image.png" />