Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (AllTimerIds.Count > 0)
        {
            float deltaTime = Time.deltaTime;
            float realDalta = Time.unscaledDeltaTime;
            for (int i = AllTimerIds.Count - 1; i >= 0; i--)
            {
                uint id = AllTimerIds[i];
                if (AllTimerInfos.ContainsKey(id))
                {
                    TimerInfo ti = AllTimerInfos[id];
                    if (ti.IgnoreTimeScale)
                    {
                        ti.resetCountDownTime = ti.resetCountDownTime - realDalta;
                    }
                    else
                    {
                        //ti.resetCountDownTime = ti.resetCountDownTime = -realDalta;
                    }

                    if (ti.resetCountDownTime <= 0)
                    {
                        if (ti.callBack != null)
                        {
                            ti.callBack();
                        }
                        if (ti.repeat)
                        {
                            ti.resetCountDownTime = ti.interval;
                        }
                        else
                        {
                            AllTimerIds.Remove(id);
                            AllTimerInfos.Remove(id);
                        }
                    }
                }
            }
        }
    }