When performing an action periodically and indefinitely: To "reset" the delay before execution, the active timer must be explicitly unregistered and re-registered. The period on an active timer cannot be changed once registered. Upon reaching the target destination, return EActiveTimerReturnType::Stop to unregister. Until the destination is reached, return EActiveTimerReturnType::Continue. When inertial scrolling begins, register an active timer with period 0 to update the scroll each frame. When performing some sort of animation or interpolation that is not controlled by an FCurveSequence: Register an active timer w/ period 0 that always returns EActiveTimerReturnType::Stop. To save memory, only use this method if the active timer ever needs to be explicitly unregistered.įor the following common use cases, here are some suggested active timer setups: Search for TWeakPtr ActiveTimerHandle in the UE4 codebase for examples. Store a weak pointer to the FActiveTimerHandle returned by RegisterActiveTimer() and only register when it's invalid. Search for bIsActiveTimerRegistered in the UE4 codebase for examples. Keep a flag in the widget to track whether the active timer is registered. To prevent them, track registration status in one of the This can be extremely useful, but also introduces the possibility of duplicate registrations. Furthermore, there is no limit to the number of active timersĪ widget can have registered concurrently. Pass the FActiveTimerHandle that was returned by SWidget::RegisterActiveTimer() to SWidget::UnRegisterActiveTick().ĭestroy the widget that the active timer is registered under.Ĭurrently active timers are an all-or-nothing situation, so if a single active timer needs to execute, all of Slate will be ticked. Return EActiveTimerReturnType::Stop from the delegate. There are three methods that can be used to unregister an active timer. Pass the delegate and the time period between timer executions (0 to call every frame) to SWidget::RegisterActiveTimer(). While Tick() is deprecated to more clearly reflect this.ĭefine a function with the following signature:ĮActiveTimerReturnType Foo(double InCurrentTime, float InDeltaTime)īind it to an FWidgetActiveTimerDelegate. At some point in the future, it may be renamed to PassiveTick() It will be called by Slate as before, but only when Slate is awake. The original Tick() function is still present as a "passive" tick. This diagram shows how the editor's processor time changes once Slate sleeping is implemented.Īn active timer is a delegate function explicitly registered by a widget that causes a Slate tick/paint pass upon execution, even in the absence of user action (thus the "active" nature of the timer).Īctive timers will continue to execute indefinitely at the frequency determined by their execution period until unregistered.
0 Comments
Leave a Reply. |