Exemple #1
0
        public static StopwatchTimeData Add(float callBackRate = -1, CallBack <StopwatchTimeData> callBack = null, bool isRealTime = false, string name = "")
        {
            Init();
            if (string.IsNullOrEmpty(name))
            {
                name = Guid.NewGuid().ToString();
            }
            if (timerDic.ContainsKey(name))
            {
                Debug.LogError("Stopwatch Name contain " + name);
                return(null);
            }
            StopwatchTimeData d = new StopwatchTimeData(name, callBackRate, isRealTime, callBack);

            timerDic.Add(name, d);
            d.Play();
            return(d);
        }
Exemple #2
0
        // Update is called once per frame
        void Update()
        {
            if (timerDic.Values.Count == 0)
            {
                return;
            }
            tempList.Clear();
            tempList.AddRange(timerDic.Values);

            for (int i = 0; i < tempList.Count; i++)
            {
                StopwatchTimeData st = tempList[i];
                if (st.State == TimerPlayState.Stop)
                {
                    timerDic.Remove(st.Name);
                    continue;
                }

                if (st.State == TimerPlayState.Playing)
                {
                    st.RunUpdate();
                }
            }
        }