Table of Contents

Debug text

Beginner Programmer

You can print debug text at runtime with DebugText. For example, you can use this to display a message when a problem occurs.


Debug text is automatically disabled when you build the game in release mode.

In the Update method of your script, add:

DebugText.Print("My debug text",new Int2(x: 50, y: 50));

Where x and y are the pixel coordinates to display the text at.

The debug message is displayed when you run the game.

Debug text

To hide debug text, use:

DebugText.Visible = false;

Example script

The following script checks that the texture MyTexture is loaded. If it isn't loaded, the game displays the debug text "MyTexture not loaded".

using Stride.Core.Mathematics;
using Stride.Engine;
using Stride.Graphics;

namespace MyGame
    public class Script : SyncScript
		public Texture myTexture;

        public override void Start()
            // Initialization of the script.
            myTexture = Content.Load<Texture>("MyTexture");

        public override void Update()
			if (myTexture == null)
                DebugText.Print("MyTexture not loaded", new Int2(x: 50, y: 50));

See also