Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging in monogame

How do you print or output text in Monogame?

I googled how to display text in monogame and was led to this: Debug.WriteLine

Which says: "By default, the output is written to an instance of DefaultTraceListener."(and that page just confused me more).

So, if someone could direct me to a method of displaying DefaultTraceListener, or another method of outputting text in monogame, I would appreciate it.

like image 843
James G. Avatar asked Nov 13 '13 01:11

James G.


People also ask

How do you write console in Monogame?

Write(thing in here); or Console. WriteLine(thing in here); to write to the console window.

What is debug WriteLine in C#?

WriteLine(String) Writes a message followed by a line terminator to the trace listeners in the Listeners collection. WriteLine(Object) Writes the value of the object's ToString() method to the trace listeners in the Listeners collection.


2 Answers

I found it!

Using Debug.WriteLine writes to the debugger, which is in the output window in Visual Studio(by default at the bottom). It appears when you close the program(press F5 to start, Esc to close) by default in an OpenGL project.

like image 87
James G. Avatar answered Sep 29 '22 00:09

James G.


If you like, you can use Console.WriteLine like you would in a normal C# console application, assuming you're developing a desktop application. There are a couple of steps.

  1. Open the Properties for your MonoGame project
  2. Select the Application tab
  3. Change the Output Type to Console Application.

Your application should run as normal, only a console window should appear when you start the game.

Alternatively, you can use Debug.WriteLine, which will write to the output window in Visual Studio (it should appear when you start debugging your game).

like image 40
fallaciousreasoning Avatar answered Sep 29 '22 01:09

fallaciousreasoning