private void OnDestroy()
        {
            Reset();

            isCalledDestroyed = true;

            instance  = null;
            isInited  = false;
            isRunning = false;
        }
        /// <summary>
        /// startImmediatly가 true이면, delay후에 첫 작업이 시작되고
        /// false라면, delay + interval 시점에 작업이 시작됩니다.
        /// checkCondition이 false면 반복을 종료합니다.
        /// </summary>
        /// <param name="task"></param>
        /// <param name="checkCondition"></param>
        /// <param name="endTask"></param>
        /// <param name="delay"></param>
        /// <param name="interval"></param>
        /// <param name="startImmediatly"></param>
        public IntervalTask(Action task, Func <bool> checkCondition, Action endTask, float delay, float interval,
                            bool startImmediatly = true) : base(task, delay)
        {
            Interval       = interval;
            CheckCondition = checkCondition ?? (() => true);
            EndTask        = endTask;

            var entryReserveTime = startImmediatly
                ? GlobalDispatchTimer.NormalizeTime(delay)
                : GlobalDispatchTimer.NormalizeTime(interval);

            ExecutedTicks = entryReserveTime;
        }
        private void Awake()
        {
            // 어찌되었든 Awake는 탄다.

            isCalledDestroyed = false;
            instance          = this;
            isInited          = true;

            timedJobQueue = new PriorityQueue <TimerJob>();
            triggerList   = new LinkedList <DestroyTrigger>();
            triggerMap    = new Dictionary <long, List <WeakReference> >();

            DontDestroyOnLoad(gameObject);

            isRunning = true;
        }
        private static void Init()
        {
            if (!isInited)
            {
                if (!Application.isPlaying)
                {
                    return;
                }

                GlobalDispatchTimer mainDispatcher = null;

                try
                {
                    mainDispatcher = GameObject.FindObjectOfType <GlobalDispatchTimer>();
                }
                catch (Exception e)
                {
                    Debugs.LogError("Failed to create DispatchTimer Instance.");
                }

                // 메인 디스패처가 없으면 만들어 준다.
                if (mainDispatcher == null)
                {
                    new GameObject("GlobalDispatchTimer").AddComponent <GlobalDispatchTimer>();
                }
                else
                {
                    // 있어도 강제로 Awake를 실행 시켜서 초기화 되도록 해준다.
                    instance.Awake();
                }
            }
            else
            {
                Debugs.Log("DispatchTimer가 이미 초기화 되었습니다.");
            }
        }
 private void SetInterval()
 {
     ExecutedTicks = GlobalDispatchTimer.NormalizeTime(Interval);
 }