private IEnumerator CheckForLeaks() { var waitForSeconds = new WaitForSeconds(cnf.CheckForLeaksPeriodSec); var swapUnitGOPrefabInfo = new Dictionary <GameObject, PrefabInfo>(); while (!ApplicationIsQuitting) { bool leak = st.UnitGOPrefabInfo.Keys.Any(go => go == null); if (leak) { foreach (var kvp in st.UnitGOPrefabInfo) { if (kvp.Key == null) { Debug.LogErrorFormat("Leak for prefab {0}", kvp.Value.PrefabGO.name); continue; } swapUnitGOPrefabInfo.Add(kvp.Key, kvp.Value); } PObjectUtil.Swap(ref st.UnitGOPrefabInfo, ref swapUnitGOPrefabInfo); swapUnitGOPrefabInfo.Clear(); } yield return(waitForSeconds); } }
private IEnumerator DisposeCATs() { var waitForSeconds = new WaitForSeconds(cnf.DisposeCATsPeriodSec); var swapDisposingCATs = new HashSet <PBaseAsyncTask>(); while (!ApplicationIsQuitting) { foreach (var cat in st.DisposingTasks) { if (!TryDispose(cat)) { swapDisposingCATs.Add(cat); } } PObjectUtil.Swap(ref st.DisposingTasks, ref swapDisposingCATs); swapDisposingCATs.Clear(); yield return(waitForSeconds); } }