Example #1
0
        static public void RemoveDownLoad(string strName, Callback <object> callBack, bool isKeepDownLoading)
        {
            if (m_AssetPackMap.ContainsKey(strName))
            {
                DownLoadPack pack = m_AssetPackMap[strName];
                if (pack != null)
                {
                    pack.m_AssetRefer--;
                    pack.AssetInfo.m_callBack -= callBack;

                    if (pack.m_AssetRefer <= 0)                    //可能会出现小于0的情况,下载到一半停止,资源没有被引用,计数为0可以被删.
                    {
                        pack.AssetInfo.m_callBack = null;          //卸载完成callback一定会为null.之前的 CallBack -= 并不一定能确保CallBack被清空了.

                        if (!isKeepDownLoading)
                        {
                            //不保持下载,正常卸载流程;
                            if (pack.State != AssetState.Finish)                            //为下载完,被卸载,本地没有保存,已下载size不需要增加;
                            {
                                m_nDownLoadSize -= pack.AssetInfo.m_nSize;
                            }

                            DownLoadCoroutine freeCoroutine = pack.ReleaseDownLoadCoroutine();
                            RecycleDownLoadCoroutine(freeCoroutine);
                            m_AssetPackMap.Remove(strName);

                            if (m_AssetPackNameList.Contains(strName))
                            {
                                m_AssetPackNameList.Remove(strName);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// 停止某个链接下载;
 /// </summary>
 static public void StopLoad(string strName)
 {
     if (m_AssetPackMap.ContainsKey(strName))
     {
         DownLoadPack pack = m_AssetPackMap[strName];
         if (pack != null)
         {
             DownLoadCoroutine freeCoroutine = pack.ReleaseDownLoadCoroutine();
             RecycleDownLoadCoroutine(freeCoroutine);
             pack.Stop();
         }
     }
 }