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

book_4_sparkGenerated
code_blocksInput

Description

The ScreenText method of the DebugOverlaySystem class is used to draw text on the screen at a specified pixel position. This method is useful for displaying debug information or other text overlays directly on the screen.

Usage

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

  • pixelPosition (Vector2): The position on the screen where the text will be drawn, specified in pixel coordinates.
  • text (System.String): The text string to be displayed on the screen.
  • size (System.Single): The size of the text.
  • flags (Sandbox.TextFlag): Flags that determine the text rendering options, such as alignment and wrapping.
  • color (Color): The color of the text.
  • duration (System.Single): The duration for which the text will be displayed on the screen, in seconds.
  • transform (Transform): The transform to apply to the text, allowing for rotation and scaling.

Example

// Example of using ScreenText to display a message on the screen
Vector2 position = new Vector2(100, 200);
string message = "Hello, Sandbox!";
float textSize = 12.0f;
TextFlag textFlags = TextFlag.Center;
Color textColor = Color.White;
float displayDuration = 5.0f;
Transform textTransform = Transform.Identity;

DebugOverlaySystem debugOverlay = new DebugOverlaySystem();
debugOverlay.ScreenText(position, message, textSize, textFlags, textColor, displayDuration, textTransform);