Beispiel #1
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();
        }
Beispiel #2
0
        private void ProcessNewInstall()
        {
            bool isNewInstall = CheckIsNewInstall();

            Log.i("Check Is New Install:" + isNewInstall);

            if (isNewInstall)
            {
                //对比外部文件
                List <string> outResult = new List <string>();
                FilePath.GetFileInFolder(FilePath.persistentDataPath4Res, ProjectPathConfig.abConfigfileName, outResult);

                AssetDataTable exterTable = new AssetDataTable();
                for (int i = 0; i < outResult.Count; ++i)
                {
                    exterTable.LoadPackageFromFile(outResult[i]);
                }

                //生成差异文件列表:
                List <ABUnit> needDeleteList = ABUnitHelper.CalculateLateList(exterTable, AssetDataTable.S, false);

                for (int i = 0; i < needDeleteList.Count; ++i)
                {
                    ABUnit unit          = needDeleteList[i];
                    string exterFilePath = ProjectPathConfig.AssetBundleName2ExterUrl(unit.abName);
                    if (File.Exists(exterFilePath))
                    {
                        File.Delete(exterFilePath);
                    }
                }

                var packages = AssetDataTable.S.allAssetDataPackages;
                if (packages.Count > 0)
                {
                    var package = packages[0];
                    PlayerPrefs.SetString(INNER_RES_PACKAGE, package.key);
                    PlayerPrefs.SetInt(INNER_RES_BUILDTIME, (int)package.buildTime);
                    PlayerPrefs.Save();
                }
            }
        }