Class UnityLoopTicker<TState>
Uses a Unity Coroutine(TimeSpan) with the SDG.Framework.Utilities.TimeUtility singleton.
public class UnityLoopTicker<TState> : ILoopTicker<TState>, ILoopTicker, IDisposable
Type Parameters
TState
- Inheritance
-
UnityLoopTicker<TState>
- Implements
-
ILoopTicker<TState>
- Inherited Members
Constructors
UnityLoopTicker(MonoBehaviour, ILogger, TimeSpan, bool, TState?, TickerCallback<ILoopTicker<TState>>?)
Create a new timer.
public UnityLoopTicker(MonoBehaviour component, ILogger logger, TimeSpan periodicDelay, bool invokeImmediately, TState? state, TickerCallback<ILoopTicker<TState>>? onTick = null)
Parameters
componentMonoBehaviourloggerILoggerperiodicDelayTimeSpanHow often to invoke the timer.
invokeImmediatelyboolIf the timer should be invoked now or wait a period.
stateTStateonTickTickerCallback<ILoopTicker<TState>>Callback since the timer being invoked now would mean you couldn't subscribe to the event first.
UnityLoopTicker(MonoBehaviour, ILogger, TimeSpan, TimeSpan, TState?, TickerCallback<ILoopTicker<TState>>?)
Create a new timer.
public UnityLoopTicker(MonoBehaviour component, ILogger logger, TimeSpan initialDelay, TimeSpan periodicDelay, TState? state, TickerCallback<ILoopTicker<TState>>? onTick = null)
Parameters
componentMonoBehaviourloggerILoggerinitialDelayTimeSpanHow long to wait to initially invoke the timer.
periodicDelayTimeSpanHow often to invoke the timer.
stateTStateonTickTickerCallback<ILoopTicker<TState>>Callback since the timer being invoked now would mean you couldn't subscribe to the event first.
Properties
InitialDelay
Delay before the first invocation.
public TimeSpan InitialDelay { get; }
Property Value
PeriodicDelay
Delay between each subsequent invocation.
public TimeSpan PeriodicDelay { get; }
Property Value
State
Generic state that can be used to store information.
public TState? State { get; }
Property Value
- TState
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
~UnityLoopTicker()
protected ~UnityLoopTicker()
Events
OnTick
Invoked every Delay seconds.
public event TickerCallback<ILoopTicker<TState>>? OnTick
Event Type
- TickerCallback<ILoopTicker<TState>>