コード例 #1
0
ファイル: Stopwatch.cs プロジェクト: TenYearsADream/Frame
        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);
        }
コード例 #2
0
ファイル: Stopwatch.cs プロジェクト: TenYearsADream/Frame
        // 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();
                }
            }
        }