private void Update() { pt.Update(); //定时替换 if (Input.GetKeyDown(KeyCode.R)) { bool succ = pt.ReplaceTimeTask(tempID, (int tid) => { Debug.Log("定时等待删除......"); }, 2, PETimeUnit.Second, 0); if (succ) { Debug.Log("替换成功"); } } //定时删除 if (Input.GetKeyDown(KeyCode.D)) { bool succ = pt.DeleteTimeTask(tempID); if (succ) { Debug.Log("删除成功"); } } }
public void Update() { if (pt == null) { return; } pt.Update(); }
// Update is called once per frame void Update() { if (Timer != null) { if (_passingTime) { if (Timer.Tick >= _targetTick) { Timer.Tick = _targetTick; _passingTime = false; _targetTick = 0; Timer.ElapseSpeed = NormalTimeSpeed; } } Timer.Update(Time.deltaTime); PlayTime.Update(Time.deltaTime); if (Application.isEditor) { if (Input.GetKeyDown(KeyCode.Keypad1)) { Timer.ElapseSpeed = 10000; } if (Input.GetKeyUp(KeyCode.Keypad1)) { Timer.ElapseSpeed = NormalTimeSpeed; } if (Input.GetKey(KeyCode.Keypad1)) { Timer.ElapseSpeed *= 1.01f; if (Timer.ElapseSpeed > 1000000) { Timer.ElapseSpeed = 1000000; } } } #if DEBUG_TIMER if (Application.isEditor) { m_ElapseSpeed = Timer.ElapseSpeed; m_Tick = Timer.Tick.ToString("#,##0"); m_Day = Timer.Day; m_Hour = Timer.Hour; m_Minute = Timer.Minute; m_Second = Timer.Second; m_TimeInDay = Timer.TimeInDay; m_HourInDay = Timer.HourInDay; m_MinuteInDay = Timer.MinuteInDay; m_SecondInDay = Timer.SecondInDay; m_CycleInDay = Timer.CycleInDay; m_TimeString = Timer.FormatString("D hh:mm:ss AP"); } #endif } }
//第一种用法:运行线程检测并处理任务 static void Test1() { //运行线程驱动计时 PETimer pt = new PETimer(); pt.SetLog((string info) => { Console.WriteLine("LogInfo:" + info); }); pt.AddTimeTask((int tid) => { Console.WriteLine("Process线程ID:{0}", Thread.CurrentThread.ManagedThreadId.ToString()); }, 10, PETimeUnit.Millisecond, 0); while (true) { pt.Update(); } }
//在主线程检测并处理 static void Test1() { PETimer pt = new PETimer(); pt.SetLog((string info) => { Console.WriteLine("ConsoleLog:" + info); }); pt.AddTimeTask((int tid) => { Console.WriteLine("Time:" + DateTime.Now); Console.WriteLine("Process线程ID:{0}", Thread.CurrentThread.ManagedThreadId.ToString()); }, 1000, 0, PETimeUnit.Millisecond); while (true) { pt.Update(); } }
// Update is called once per frame void Update() { if (!m_PauseTimer) { if (m_Assembly != null) { m_Assembly.Update(); m_Timer.ElapseSpeed = GameTime.Timer.ElapseSpeed; m_Timer.Update(Time.deltaTime); } else { m_Timer.ElapseSpeed = 0; } } foreach (KeyValuePair <int, CSCommon> kvp in m_CommonEntities) { kvp.Value.Update(); } foreach (CSPersonnel personnel in m_MainNpcs) { personnel.Update(); } foreach (CSPersonnel personnel in m_RandomNpcs) { personnel.Update(); } if (m_Clod != null && Time.frameCount % 8192 == 0 && Assembly != null && Assembly.Farm != null && Assembly.Farm.IsRunning) { if (!IsAdjustingClods) { StartCoroutine(AdjustClodsProc()); } } if (m_Clod != null && Time.frameCount % 8192 == 4096 && Assembly != null && Assembly.Farm != null && !Assembly.isSearchingClod && Assembly.Farm.IsRunning && Assembly.ModelObj != null) { StartCoroutine(CSMain.Instance.SearchVaildClodForAssembly(Assembly)); } }
/// <summary> /// 在主线程检测并处理 /// </summary> private static void Test1() { PETimer pt = new PETimer(); pt.SetLog((string info) => { Console.WriteLine($"ConsoleLog{info}"); }); pt.AddTimeTask((int tid) => { Console.WriteLine($"Time:{DateTime.Now}"); Console.WriteLine($"Process线程ID:{Thread.CurrentThread.ManagedThreadId.ToString()}"); }, 1000, 0); while (true) { pt.Update(); //休眠20毫秒 不然CPU占用率高 Thread.Sleep(20); } }
public void Update() { pt.Update(); }
private void Update() { pt.Update(); }
public void Update() { pt.Update(); // 驱动整个定时任务的检测 }
private void Update() { peTimer.Update(); }
public void Update() { _timer.Update(); }
private void FixedUpdate() { pt.Update(); }