/// <summary> /// ��ʱ����δʹ����Դ /// </summary> /// <returns></returns> IEnumerator ReleaseUnusedAssetBundle() { while (true) { yield return(new WaitForSeconds(releaseTime)); abReleaseList.Clear(); foreach (AssetBundleData abData in abLoadDict.Values) { float curTime = Time.realtimeSinceStartup - abData.mLastUsedTime; if (curTime > maxStayTime) { abReleaseList.Add(abData); } } if (abReleaseList.Count > 0) { for (int i = 0; i < abReleaseList.Count; i++) { AssetBundleData abData = abReleaseList[i]; abData.Release(); abLoadDict.Remove(abData.mPath); } Resources.UnloadUnusedAssets(); } } }
/// <summary> /// �ͷ�AssetBundle /// </summary> /// <param name="bundleName"></param> public void ReleaseAssetBundle(string bundleName) { if (abLoadDict.ContainsKey(bundleName)) { AssetBundleData abData = abLoadDict[bundleName]; abData.Release(); abLoadDict.Remove(bundleName); } }