C++ Tips & Tricks for Debugging [Unreal Engine 4]

preview_player
Показать описание
In this C++ tutorial for Unreal Engine 4 I'll explain a few ways to log information to the output log and the game viewport.

- AddOnScreenDebugMessage (Also known as Print String in Blueprint)
- UE_LOG macro to log messages in categories with different severities like log, warning, error, verbose.
- DrawDebugString, drawing string at 3D location in the world.

Рекомендации по теме
Комментарии
Автор

You know, I have suggested your tutorials to almost everyone who asked for the past half a decade, and I've only just subbed to your youtube page. I apologise :D

tehfn
Автор

I had no idea you could make debug text appear on hit like that! Thank you!

TartsFlying
Автор

Had no idea that draw debug string existed! Thanks!

Krustachu
Автор

Very nice tutorial, I didn't know about the DrawDebugString. By the way there is another way to debug not mentioned in the video, which is the one used by blueprints. o, FString* m); //With this one we can print a string on screen without override the last printed value and also log automatically on the Output Log.

LuizFernando-tmwl
Автор

Awesome video. Since you're using Visual Assist, you can actually keybind the add-include feature and when you have methods from GEngine, you can click within the method name, hit your keybind, and get your includes automatically. It's really helpful because you don't have to reference the API if you don't know the include path.

matt_
Автор

Hey Tom, loved your tutorial! What theme are you using for Visual Studio?

roekko
Автор

you can also bind that to std::cout this way:

#include <sstream>
#include <ostream>
#include <iostream>

using std::cout;

class UE_stringbuf : public std::stringbuf
{
protected:
int sync() {
auto sentence = (str()).c_str() ;
UE_LOG(LogTemp, Log, TEXT("%s"), *FString(sentence));
if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::Yellow, sentence);}
return std::stringbuf::sync();
}
};

//in classes you are going to use that with:
AMyClass::AMyClass()
{
cout.rdbuf(&Stream);
}

artymclabin
Автор

Tom. How do you compile your code so fast? I am having such a painful waiting time compiling mine (about 3 ~ 7 minutes). Even if I only change a variable name on the source

LuizFernando-tmwl
Автор

Is there a way to color certain categories in UE_LOG or color a certain line in the Output Log? Because I know there is a Verbose Level called SetColor but I could not figure out how it works. And I know that SET_WARN_COLOR(COLOR_CYAN) does not work in the Engine.

SirPytan