Printing & Logging in Unreal Engine C++
if(GEngine)
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, TEXT("Some message!"));
UE_LOG(LogTemp, Warning, TEXT("Some message!"));
int MyInt = 3;
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("int: %d"), MyInt));
UE_LOG(LogTemp, Warning, TEXT("int: %d"), MyInt);
float MyFloat = 10.5f;
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("float: %f"), MyFloat));
UE_LOG(LogTemp, Warning, TEXT("float: %f"), MyFloat);
bool bMyBool = true;
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("bool: %s"), bMyBool ? TEXT("true") : TEXT("false")));
UE_LOG(LogTemp, Warning, TEXT("bool: %s"), bMyBool ? TEXT("true") : TEXT("false"));
FString MyString = TEXT("Hello World");
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("FString: %s"), *MyString));
UE_LOG(LogTemp, Warning, TEXT("FString: %s"), *MyString);
FName MyName = TEXT("Hello World");
GEngine->AddOnScreenDebugMessage(-1, 10.0f, FColor::Red, FString::Printf(TEXT("FName: %s"), *MyName.ToString()));
UE_LOG(LogTemp, Warning, TEXT("FName: %s"), *MyName.ToString());