Exemplo n.º 1
0
        // 下载完成后的回调
        void OnSingleABDownloadFinished(bool succeed, ToDownloadBundle b)
        {
            int i = m_downloadingSingleBundles.FindIndex(t => t == b);

            if (i >= 0)
            {
                m_downloadingSingleBundles.RemoveAt(i);
            }

            if (succeed)
            {
                // 将资源的状态改为已下载(NoChange)
                b.BundleObj.State = BundleState.NoChange;
                m_bundleDownloaded.Add(b.BundleObj);

                string error;
                if (m_bundle2Download.Count > CountToWriteAllList)
                {
                    WriteAllListFile(out error);        // 保存所有的 list 文件,此时会删除已下载资源缓存文件,和清空已下载资源列表
                }
                else
                {
                    WriteListFile4DownloadedB(out error);           // 写入缓存文件
                }
            }
        }
Exemplo n.º 2
0
        // 是否正在下载中,或是否需要下载
        public bool SingleABNeedDownload(string path)
        {
            // 下载中
            ToDownloadBundle obj = m_toDownloadSingleBundles.Find(t => t.Path == path);

            if (obj != null)
            {
                return(true);
            }

            // 属于加载时再下载的资源
            BundleItem bundleObj = GetBundleObj(path);

            return(bundleObj != null && bundleObj.State == BundleState.DownloadWhenUse);
        }
Exemplo n.º 3
0
        // 当加载失败后下载
        public void DownloadSingleAB(string path, Action <bool, string> callback)
        {
            Debug.Log(string.Format("Start download: {0}", path));
            ToDownloadBundle b = m_toDownloadSingleBundles.Find(t => t.Path == path);

            if (b != null)
            {
                b.AddFinishHandler(callback);
            }
            else
            {
                b = new ToDownloadBundle(path, callback);
                m_toDownloadSingleBundles.Add(b);
            }
        }