/// <summary> /// 卸载所有资源; /// </summary> public void ReleaseAllAsset() { List <string> delAsset = new List <string>(); foreach (KeyValuePair <string, AssetPack> kvp in m_AllAssets) { if (!kvp.Value.m_IsResident) //fufeng ni lao na yang? { delAsset.Add(kvp.Key); } } foreach (string assetName in delAsset) { ReleaseDownLoadCoroutine(assetName); //立即停止Coroutine; WWWDownLoader.StopLoad(assetName + m_strAssetExtension); WWWDownLoader.RemoveDownLoad(assetName + m_strAssetExtension, null); //AssetLoader内部的 www调用逻辑上来说没有回调.函数内部有非空判断; AssetPack assetPack = m_AllAssets[assetName]; m_AllAssets.Remove(assetName); assetPack.m_AssetRefer--; assetPack.AssetRelease = true; if (assetPack.m_AssetRefer > 0) { Debug.LogError("release asset still used: " + assetPack.m_AssetName); } assetPack = null; } delAsset.Clear(); }
public void Release() { m_RefNum -= 1; if (m_RefNum == 0) { m_mapRoleBodyLoader.Remove(ResuceName); WWWDownLoader.StopLoad(ResuceName); WWWDownLoader.RemoveDownLoad(ResuceName, null); _Release(); } }
public static void ReleaseAllModel() { foreach (ModelLoader loader in cacheLoaders.Values) { WWWDownLoader.StopLoad(loader.mResName); WWWDownLoader.RemoveDownLoad(loader.mResName, null); loader.modelPrefab = null; loader.request = null; if (loader.bundle != null) { loader.bundle.Unload(true); loader.bundle = null; } } cacheLoaders.Clear(); }
/// <summary> /// 卸载资源; /// </summary> public void ReleaseAsset(string assetName, Callback <string> callBack, bool isKeepLoading) { if (m_AllAssets.ContainsKey(assetName)) { AssetPack assetPack = m_AllAssets[assetName]; if (assetPack != null) { if (assetPack.m_CallBack != null) { assetPack.m_CallBack -= callBack; } if (!assetPack.m_IsResident) { assetPack.m_AssetRefer--; if (isKeepLoading) { if (assetPack.State != AssetState.DownLoading && assetPack.State != AssetState.LocalLoading) //KeepLoading的任务, 只有在加载完成后,才能进行卸载; { assetPack.m_nKeepLoadingRefer--; } } if (assetPack.m_AssetRefer <= 0 && assetPack.m_nKeepLoadingRefer <= 0) //非常驻资源,没有外部使用,并且下载完成的情况下; { assetPack.m_CallBack = null; WWWDownLoader.StopLoad(assetName + m_strAssetExtension); WWWDownLoader.RemoveDownLoad(assetName + m_strAssetExtension, null); //AssetLoader内部的 www调用逻辑上来说没有回调.函数内部有非空判断; ReleaseDownLoadCoroutine(assetName); //立即停止Coroutine; assetPack.AssetRelease = true; m_AllAssets.Remove(assetName); } } } else { Debug.LogError("AssetLoader ReleaseAsset,AssetPack can not be null. " + assetName); } } }
public void Release() { m_RefNum -= 1; if (m_RefNum == 0) { cacheLoaders.Remove(mResName); WWWDownLoader.StopLoad(mResName); WWWDownLoader.RemoveDownLoad(mResName, null); modelPrefab = null; request = null; if (bundle != null) { bundle.Unload(true); bundle = null; } m_www = null; } }