39 lines
673 B
C#
39 lines
673 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
public class FrameTimer1 : SingletonMono<FrameTimer1>
|
|
{
|
|
private Dictionary<int, Action> _frameTimers = new();
|
|
private int _timerCount = 0;
|
|
|
|
private void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
|
|
public int StartTimer(Action callback)
|
|
{
|
|
_timerCount++;
|
|
_frameTimers[_timerCount] = callback;
|
|
return _timerCount;
|
|
}
|
|
|
|
public void StopTimer(int timerId)
|
|
{
|
|
_frameTimers.Remove(timerId);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
foreach (var kv in _frameTimers)
|
|
{
|
|
kv.Value.Invoke();
|
|
}
|
|
}
|
|
}
|