示例#1
0
        public void DownloadPackage(Action <ResPackageHandler> callback)
        {
            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            m_DownloadListener = callback;
            string resName = AssetName2ResName(m_Package.packageName);

            m_Loader.Add2Load(resName, OnPackageDownloadFinish);

            HotUpdateRes hotUpdateRes = ResMgr.S.GetRes <HotUpdateRes>(resName);

            string fullPath = FilePath.persistentDownloadCachePath + m_Package.relativeLocalParentFolder + m_Package.zipFileName;

            hotUpdateRes.SetUpdateInfo(fullPath, m_Package.zipUrl, 10000);
            if (m_Loader != null)
            {
                m_Loader.LoadAsync();
            }
        }
示例#2
0
        public void CheckUpdateList(Action <ResPackageHandler> callBack)
        {
            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            ApplyUpdateRecord();

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            m_CheckListener = callBack;
            string resName = AssetName2ResName(m_Package.configFile);

            m_Loader.Add2Load(resName, OnRemoteABConfigDownloadFinish);

            HotUpdateRes hotUpdateRes = ResMgr.S.GetRes <HotUpdateRes>(resName);

            string fullPath = FilePath.persistentDownloadCachePath + m_Package.configFile;

            hotUpdateRes.SetUpdateInfo(fullPath, m_Package.GetAssetUrl(m_Package.configFile), 1000);

            if (m_Loader != null)
            {
                m_Loader.LoadAsync();
            }
        }
示例#3
0
        public static IRes Create(string name, short assetType)
        {
            switch (assetType)
            {
            case eResType.kAssetBundle:
                return(AssetBundleRes.Allocate(name));

            case eResType.kABAsset:
                return(AssetRes.Allocate(name));

            case eResType.kABScene:
                return(SceneRes.Allocate(name));

            case eResType.kInternal:
                return(InternalRes.Allocate(name));

            case eResType.kNetImageRes:
                return(NetImageRes.Allocate(name));

            case eResType.kHotUpdateRes:
                return(HotUpdateRes.Allocate(name));

            default:
                Log.e("Invalid assetType :" + assetType);
                return(null);
            }
        }
示例#4
0
        public static HotUpdateRes Allocate(string name)
        {
            HotUpdateRes res = ObjectPool <HotUpdateRes> .S.Allocate();

            if (res != null)
            {
                res.name = name;
            }
            return(res);
        }
示例#5
0
        protected void AddDownloadFile(string name)
        {
            string resName = ResPackageHandler.AssetName2ResName(name);

            m_ResLoader.Add2Load(resName, OnConfigFileDownloadResult);

            HotUpdateRes res          = ResMgr.S.GetRes <HotUpdateRes>(resName);
            string       relativePath = GetAssetRelativePath(name);
            string       fullPath     = FilePath.persistentDataPath4Res + relativePath;

            res.SetUpdateInfo(fullPath, GetAssetUrl(relativePath), 1000, ConfigFileValidChecker);
        }
示例#6
0
        private void ProcessRemoteABConfig(HotUpdateRes res)
        {
            AssetDataTable remoteDataTable = new AssetDataTable();

            try
            {
                remoteDataTable.LoadPackageFromFile(res.localResPath);
            }
            catch (Exception e)
            {
                Log.e(e);
            }
            m_NeedUpdateFileList = ABUnitHelper.CalculateLateList(AssetDataTable.S, remoteDataTable, true);

            if (m_NeedUpdateFileList != null)
            {
                if (m_Package.updateBlackList != null)
                {
                    var list = m_Package.updateBlackList;

                    for (int i = 0; i < list.Count; ++i)
                    {
                        for (int j = m_NeedUpdateFileList.Count - 1; j >= 0; --j)
                        {
                            if (m_NeedUpdateFileList[j].abName.Equals(list[i]))
                            {
                                m_NeedUpdateFileList.RemoveAt(j);
                                break;
                            }
                        }
                    }
                }

                m_NeedUpdateFileCount = m_NeedUpdateFileList.Count;

                for (int i = 0; i < m_NeedUpdateFileCount; ++i)
                {
                    m_NeedUpdateFileSize += m_NeedUpdateFileList[i].fileSize;
                }
            }

            //Dump();
            ClearLoader();
        }
示例#7
0
        private void InnerStartUpdate(List <ABUnit> updateList)
        {
            if (updateList == null || updateList.Count == 0)
            {
                return;
            }

            if (m_Loader != null)
            {
                Log.w("Package Handler is Working.");
                return;
            }

            m_Loader = ResLoader.Allocate("ResPackageHolder");

            if (m_UpdateUnitMap == null)
            {
                m_UpdateUnitMap = new Dictionary <string, ABUnit>();
            }
            else
            {
                m_UpdateUnitMap.Clear();
            }

            for (int i = 0; i < updateList.Count; ++i)
            {
                string resName = AssetName2ResName(updateList[i].abName);

                m_UpdateUnitMap.Add(resName, updateList[i]);

                m_Loader.Add2Load(resName, OnResUpdateFinish);
                HotUpdateRes res          = ResMgr.S.GetRes <HotUpdateRes>(resName);
                string       relativePath = m_Package.GetABLocalRelativePath(updateList[i].abName);
                string       fullPath     = FilePath.persistentDataPath4Res + relativePath;
                res.SetUpdateInfo(fullPath, m_Package.GetAssetUrl(relativePath), updateList[i].fileSize);
            }

            m_Loader.LoadAsync(OnPackageUpdateFinish);
        }
示例#8
0
        private void OnRemoteABConfigDownloadFinish(bool result, IRes res)
        {
            if (!result)
            {
                Log.e("Download remote abConfig File Failed.");
                ClearLoader();

                if (m_CheckListener != null)
                {
                    m_CheckListener(this);
                    m_CheckListener = null;
                }
                return;
            }

            HotUpdateRes hotUpdateRes = res as HotUpdateRes;

            if (hotUpdateRes == null)
            {
                ClearLoader();

                if (m_CheckListener != null)
                {
                    m_CheckListener(this);
                    m_CheckListener = null;
                }
                return;
            }

            ProcessRemoteABConfig(hotUpdateRes);

            if (m_CheckListener != null)
            {
                m_CheckListener(this);
                m_CheckListener = null;
            }
        }