功能介绍
可以设置定时或延时执行某个操作。
设置定时器
FTimerHandle timerHandle;
FTimerDelegate Delegate = FTimerDelegate::CreateUObject(&ATestTime::OnCountDown);
GetWorld()->GetTimerManager().SetTimer(timerHandle, Delegate, 1.0f, true);
void ATestTime::OnCountDown()
{
//DoSomething
}
清除定时器
GetWorld()->GetTimerManager().ClearTimer(timerHandle);
其它常用API
GetWorld()->GetTimerManager().PauseTimer(mTimer); //暂停
GetWorld()->GetTimerManager().UnPauseTimer(mTimer); //唤醒
float elapsed = GetWorld()->GetTimerManager().GetTimerElapsed(mTimer); //已逝时间
float elapsed = GetWorld()->GetTimerManager().GetTimerRemaining(mTimer); //剩余时间
bool isActive = GetWorld()->GetTimerManager().IsTimerActive(mTimer); //激活
bool isPaused = GetWorld()->GetTimerManager().IsTimerPaused(mTimer); //暂停
bool isExist = GetWorld()->GetTimerManager().TimerExists(mTimer); //存在