I want to say “hello world” in the console and also how open the console in the game
Hi,
You can access the console from inside the UE4 editor, Window > Developer Tools > Output Log. It appears as a separate tab next to the Content Browser.
To print a message from C++ code you need this:
UE_LOG(LogTemp, Warning, TEXT("Hello World!"));
For some reason, using a semi-colon (the ; symbol) after a macro in UE4, like with UE_LOG, makes the project not compile. IntelliSense also says that it’s wrong for some reason. Yet, when I do tutorials and whatnot I always see people using the semi-colon at the end and I don’t understand why it works for them but not for me.
That’s strange! I’ve never encountered such issue!
In general, UE_LOG
does not require a semicolon at the end but the reason everyone uses it is to be consistent with c++ which requires a semicolon at the end of each statement.
Not sure if it helps but try including "UObject/ObjectMacros.h"
. Maybe it fixes your intellisense issues and hence the compiling errors.
I new in the UE4 developing, can you give me the exact steps? one by one
You generally have to enclose UE_LOG in brackets even if it’s a single line. It’s a macro that expands to some weird stuff.
{
UE_LOG(…)
}
This is an old thread, but it didn’t seem like what OP was looking for had been answered.
Assuming OP wanted to know how to print to the game’s viewport console and not the editor’s “Output Log” console you need to get the UConsole
object from UGameViewportClient::ViewportConsole
GetWorld()->GetGameViewport()->ViewportConsole->OutputText(TEXT("Hello From the Viewport Console!"));