private void Update() { for (int i = 0; i < scheduleList.Count; ++i) { ScheduleObj obj = scheduleList[i]; obj.Update(); if (obj.IsDone) { scheduleList.RemoveAt(i--); } } for (int i = 0; i < threadedScheduleList.Count; ++i) { ThreadedSchedule info = threadedScheduleList[i]; lock (info) { if (!info.IsCompleted) { continue; } } try { info.OnComplete?.Invoke(); threadedScheduleList.RemoveAt(i--); }catch (Exception e) { Debug.LogError(e); } } }