void ScreenText( Vector2 pixelPosition, string text, float size, TextFlag flags, Color color, float duration )
void ScreenText( Vector2 pixelPosition, Sandbox.TextRendering/Scope textBlock, TextFlag flags, float duration )

robot_2Generated
code_blocksInput

Description

The ScreenText method of the DebugOverlaySystem class is used to draw text directly onto the screen at a specified pixel position. This method is useful for displaying debug information or other text overlays in a 2D context, such as HUD elements or notifications.

Usage

To use the ScreenText method, you need to provide the following parameters:

  • pixelPosition: A Vector2 representing the position on the screen where the text should be drawn. The coordinates are in pixels.
  • text: A string containing the text to be displayed.
  • size: A float specifying the size of the text.
  • flags: A TextFlag enumeration value that determines the text alignment and other display options.
  • color: A Color object that defines the color of the text.
  • duration: A float indicating how long the text should remain on the screen, in seconds.

Example

// Example of using ScreenText to display a message on the screen

// Define the position on the screen (in pixels)
Vector2 position = new Vector2(100, 50);

// Define the text to display
string message = "Hello, Sandbox!";

// Set the text size
float textSize = 24.0f;

// Choose text flags (e.g., center alignment)
TextFlag textFlags = TextFlag.Center;

// Define the text color
Color textColor = Color.White;

// Set the duration for the text to be displayed
float displayDuration = 5.0f;

// Draw the text on the screen
DebugOverlaySystem.ScreenText(position, message, textSize, textFlags, textColor, displayDuration);