📄 블루프린트에서 로그 출력하기
✏️ 블루프린트
✏️ 출력 결과
📄 C++에서 로그 출력하기
✏️ C++ 코드
UE_LOG(LogTemp, Warning, TEXT("Hello World"));
int32 myInt = 100;
UE_LOG(LogTemp, Warning, TEXT("MyInt is : %d"), myInt);
float myFloat = 3.14159f;
UE_LOG(LogTemp, Warning, TEXT("myFloat is : %f"), myFloat);
UE_LOG(LogTemp, Warning, TEXT("myFloat is : %.2f"), myFloat);
double myDouble = 0.000756;
UE_LOG(LogTemp, Warning, TEXT("myDouble is : %lf"), myDouble);
char myChar = 'C';
UE_LOG(LogTemp, Warning, TEXT("myChar is : %c"), myChar);
wchar_t wideChar = L'W';
UE_LOG(LogTemp, Warning, TEXT("myChar is : %lc"), wideChar);
bool myBool = true;
UE_LOG(LogTemp, Warning, TEXT("myBool is : %d"), myBool);
UE_LOG(LogTemp, Warning, TEXT("%s"), myBool ? TEXT("true") : TEXT("false"));
FString myString = TEXT("This is myString");
UE_LOG(LogTemp, Warning, TEXT("%s"), *myString);
UE_LOG(LogTemp, Warning, TEXT("%s"), *GetName());
✏️ 출력 결과
📄 매크로 활용
- Build.cs 파일에 매크로로 등록시켜놓고 사용하면 정말 편하다.
PublicDefinitions.Add("WG_LOG(x)=UE_LOG(LogTemp, Warning, TEXT(x));");
PublicDefinitions.Add("WG_TEXT(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Magenta, TEXT(x));}");
PublicDefinitions.Add("WG_STRING(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Magenta, x);}");
PublicDefinitions.Add("WG_BOOL(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, (x ? FString(\"true\") : FString(\"false\")));}");
PublicDefinitions.Add("WG_INT(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Turquoise, FString::FromInt(x));}");
PublicDefinitions.Add("WG_FLOAT(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Green, FString::SanitizeFloat(x));}");
PublicDefinitions.Add("WG_VECTOR(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, x.ToString());}");
PublicDefinitions.Add("WG_ROTATOR(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Purple, x.ToString());}");
PublicDefinitions.Add("WG_ENUM(x)=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Emerald, UEnum::GetDisplayValueAsText(x).ToString());}");
PublicDefinitions.Add("WG_FUNC()=if(GEngine){GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::White, (FString(__FUNCTION__) + TEXT(\"(\") + FString::FromInt(__LINE__) + TEXT(\")\")));}");