Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide 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.

    Note

    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

    • Logging
    • Scripts
    • Improve this Doc
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation