DebugText is null. (DebugTextSystem NullReferenceException)

I can’t use DebugText. On game start a unexpected exception appears.

My script is equal as the example from the docs. Except the Texture. https://doc.xenko.com/latest/en/manual/troubleshooting/debug-text.html

namespace MyGame {

  public class MyController : SyncScript {

    public override void Start() {
      Log.ActivateLog(LogMessageType.Debug);
      Log.Debug("MyController Start");
    }

    public override void Update() {
      DebugText.Print("MyController Update", new Int2(x: 50, y: 50));
    }
  }

}

Error:

Unexpected exception. System.NullReferenceException. 
The object reference was not set to an object instance.
 at Xenko.Profiling.DebugTextSystem.Draw(GameTime gameTime)
   at Xenko.Games.GameSystemCollection.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.Draw(GameTime gameTime)
   at Xenko.Games.GameBase.DrawFrame()
   at Xenko.Games.GameBase.TickInternal()

etc.

I added this script as component to the shere object of a new project. Also tried on the UI object.
(The Log works)
DebugText is null.

Platform: Windows (10 Desktop)
Xenko: 3.0.0.3

does this fix work for you?

1 Like

Yes, thanks. It’s a workaround and should be fixed. Ok, there are issues on github. :slight_smile:
… I see DebugText only works in Update methods. In Start method I get no error and nothing is displayed on runtime.