47 lines
758 B
C#
Raw Normal View History

2025-05-18 01:04:31 +08:00
using UnityEngine;
namespace G
{
public class Timer
{
public delegate bool TimerCallFunc(object[] param = null);
public static int s_handleTotal;
public int m_handle;
public float m_curTime;
public float m_delay;
public TimerCallFunc m_func;
public object[] m_param;
public bool m_loop;
public Timer(float delay, TimerCallFunc func, bool _loop, object[] param = null)
{
m_delay = delay;
m_func = func;
m_curTime = 0f;
m_loop = _loop;
m_param = param;
s_handleTotal++;
m_handle = s_handleTotal;
}
public bool Update()
{
m_curTime += Time.deltaTime;
if (m_curTime >= m_delay)
{
if (m_loop)
{
m_curTime -= m_delay;
}
return m_func(m_param);
}
return true;
}
}
}