UE4笔记---自定义间隔的定时器


UE4笔记---自定义间隔的定时器

.h 中定义
FTimerHandle TH_VisibilityMessage;




.cpp
#include "Engine.h"


GWorld->GetTimerManager().SetTimer(TH_VisibilityMessage, this, &UUMGTipMessage::OnTimerHandleEvent, 5, false);


// 参数描述
/**
 * Sets a timer to call the given native function at a set interval.  If a timer is already set
 * for this delegate, it will update the current timer to the new parameters and reset its
 * elapsed time to 0.
 *
 * @param InOutHandle Handle to identify this timer. If it is invalid when passed in it will be made into a valid handle.
 * @param InObj Object to call the timer function on.
 * @param InTimerMethod Method to call when timer fires.
 * @param InRate The amount of time between set and firing.  If <= 0.f, clears existing timers.
 * @param InbLoop true to keep firing at Rate intervals, false to fire only once.
 * @param InFirstDelay The time for the first iteration of a looping timer. If < 0.f inRate will be used.

 */


UE4笔记---通过代理方式获取Tick

/** Delegate for callbacks to Tick */

FTickerDelegate TickDelegate;

/** Handle to various registered delegates */
FDelegateHandle TickDelegateHandle;

bool Tick(float DeltaSeconds);


// Register delegate for ticker callback
TickDelegate = FTickerDelegate::CreateUObject(this, &UShooterGameInstance::Tick);
TickDelegateHandle = FTicker::GetCoreTicker().AddTicker(TickDelegate);





你可能感兴趣的:(UE4学习笔记)