//一次清除所有没有引用的bundle public void DeleteNoRefBundles() { for (int i = 0; i < waitingDelBundles.Count; ++i) { BundleHolder one = waitingDelBundles[i]; one.Unload(); } waitingDelBundles.Clear(); }
//尝试少量的删除 public IEnumerator TryDelete() { yield return(null); float curTime = Time.realtimeSinceStartup; while (waitingDelBundles.Count > ZERO_REF_COUNT) { BundleHolder one = waitingDelBundles[0]; if (one.RefCount == 0 && curTime - one.NoRefTime > DEL_TIME) //它依赖的holder的时间肯定比它早 { one.Unload(); waitingDelBundles.RemoveAt(0); } else { break; //排在前面的时间最久 } } //_Scripts.Main.App.Log(string.Format("bundle count = {0}",bundles.Count)); }