private static IEnumerator ClearResourcePoolsByTimeAsync(float fTime, bool bClearAsset) { var watch = Stopwatch.StartNew(); var curTime = Time.time; var resources = new List <string>(ResourcePoolManager._resourcePoolDict.Keys); for (var i = 0; i < resources.Count; i++) { watch.Stop(); if (watch.ElapsedMilliseconds > 2) { yield return(null); watch.Reset(); } watch.Start(); ResourcePool resourcePool = null; if (ResourcePoolManager._resourcePoolDict.TryGetValue(resources[i], out resourcePool)) { if (resourcePool != null && curTime - resourcePool.LastUseTime > fTime) { resourcePool.Clear(); ResourcePoolManager._resourcePoolDict.Remove(resources[i]); } } } }
public void Dispose() { pool.Clear(); }