반응형

◼︎UE4 로그 포맷

출처: https://wergia.tistory.com/122

- 일반 메시지

UE_LOG(LogTemp, Log, TEXT("Log Message"));


- FString

UE_LOG(LogTemp, Log, TEXT("Character Name :: %s"), *MyCharacter->GetName());


- bool

UE_LOG(LogTemp, Log, TEXT("Character is Die :: %s"), MyCharacter->IsDie ? TEXT("true") : TEXT("false"));


- int

UE_LOG(LogTemp, Log, TEXT("Character HP :: &d"), MyCharacter->Hp);

 

 
- float

UE_LOG(LogTemp, Log, TEXT("Character Stamina :: %f"), MyCharacter->Stamina);


- FVector

UE_LOG(LogTemp, Log, TEXT("Character Location :: %s"), MyCharacter->GetActorLocation().ToString());


- FName

UE_LOG(LogTemp, Log, TEXT("Character FName :: &d"), MyCharacter->GetFName().ToString());


위 방식으로 컴파일시 에러 발생하는 경우. 
(출처: 
https://answers.unrealengine.com/questions/370716/ue-log-unable-to-print-an-fname-from-uactivemontag.html)

UE_LOG(LogTemp, Log, TEXT("[hackcatml] USpringArmComponent::SocketName: %s"), *USpringArmComponent::SocketName.ToString());


- 여러 자료형 한번에 로그로 출력하기

UE_LOG(LogTemp, Log, TEXT("CharacterName :: &s / HP :: &d / Stamina :: %f"), *MyCharacter->GetName(), MyCharacter->Hp, MyCharacter->Stamina);

 


◼︎UE4 Log On Screen
출처: https://hombody.tistory.com/190 

GEngine->AddOnScreenDebugMessage(Key, TimeToDisplay, DisplayColor, DebugMessage, bNewerOnTop);
파라미터:
- key: 로그 축적(-1), 로그 갱신(-1 아닌값)
- TimeToDisplay: 보여지는 시간
- DisplayColor: 색상
- DebugMessage: 출력할 문자열
- bNewerOnTop: True일 경우 위에서 아래로, False는 반대

// 일반 메시지 출력
GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Yellow, TEXT("Move Left was Pressed"));

// 로그 포맷 적용하여 출력.
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, FString::Printf(TEXT("Input Value : String : %s, Int : %d, Float : %f"), TEXT("Name"), 99, 3.14f));




 

반응형

+ Recent posts