Debugging the output in UE4
All of the code in this chapter (as well as in the later chapters) will require you to work in a UE4 project. For the purpose of testing TArray
, I created a basic code project called TArrays
. In the ATArraysGameMode::ATArraysGameMode
constructor, I am using the debug output feature to print text to the console.
Here's how the code will look:
ATArraysGameMode::ATArraysGameMode(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP) { if( GEngine ) { GEngine->AddOnScreenDebugMessage( 0, 30.f, FColor::Red, "Hello!" ); } }
If you compile and run this project, you will see the debug text in the top-left corner of your game window when you start the game. You can use a debug output to see the internals of your program at any time. Just make sure that the GEngine
object exists at the time of debugging the output. The output of the preceding code is shown in the following screenshot: