KoreanFoodie's Study
[언리얼] 타임 스탬프 찍기(TimeStamp, 시간 로그) 본문
[언리얼] 어떤 개념 : 어떻게 하기
핵심 :
1. UObject 라면, UWorld::GetRealTimeSeconds() 함수를 사용할 수 있다.
2. C++ 클래스라면, FDateTime::Now() 를 쓸 수도 있다.
3. milisecond 를 원한다면 FDateTime::UtcNow() 를 쓰자.
1. UObject 일 경우
UWorld* World = GetWorld();
float PrevSeconds;
float ElapsedSeconds;
if (World)
{
ElapsedSeconds = MyWorld->GetRealTimeSeconds() - PrevSeconds;
PrevSeconds = MyWorld->GetRealTimeSeconds();
UE_LOG(LogTemp, Warning, TEXT("ElapsedTime : %f"), ElapsedSeconds);
}
2. C++ 클래스에서
// Get the current timestamp
FDateTime CurrentTime = FDateTime::Now();
// Convert the timestamp to a string
FString TimestampString = CurrentTime.ToString();
// Print the timestamp
UE_LOG(LogTemp, Warning, TEXT("Current Timestamp: %s"), *TimestampString);
3. Milisecond 가 필요할 때
// Get the current timestamp in milliseconds
FDateTime CurrentTime = FDateTime::UtcNow();
int64 Milliseconds = CurrentTime.ToUnixTimestamp() * 1000 + CurrentTime.GetMillisecond();
// Convert the timestamp to a string with milliseconds
FString TimestampString = FString::Printf(TEXT("%lld milliseconds"), Milliseconds);
// Print the timestamp with milliseconds
UE_LOG(LogTemp, Warning, TEXT("Current Timestamp: %s"), *TimestampString);
'Game Dev > Unreal C++ : Dev Log' 카테고리의 다른 글
[언리얼] 언리얼 UI 최적화 정리 (언리얼 공식 문서를 중심으로) (1) | 2024.02.06 |
---|---|
[언리얼] 다음 틱에 특정 동작 수행시키기 (0) | 2023.11.14 |
인자 없는 기본 생성자로 MakeShared 를 통해 TSharedRef 타입 선언하기 (0) | 2023.09.25 |
C++ 과 언리얼에서 스마트 포인터로 오브젝트 풀 관리하는 방법 (0) | 2023.09.15 |
[언리얼] UI 에서 애니메이션의 이벤트가 끝났음을 알려주는 방법 (0) | 2023.09.08 |
Comments