예제 #1
0
        public static bool SetUpdateFileManifest(FileManifest updateList)
        {
            bool canAppend = false;

            if (ManifestManager.fileManifest != null && updateList != null)
            {
                canAppend = ManifestManager.fileManifest.AppendFileManifest(updateList);
                if (canAppend)
                {
                    if (ManifestManager.updateFileManifest != null)  //append persistent file
                    {
                        var persistent = ManifestManager.updateFileManifest.allAbInfo;
                        for (int i = 0; i < persistent.Count; i++)
                        {
                            updateList.Add(persistent[i]);
                        }
                    }
                    ManifestManager.updateFileManifest = updateList;
                    Debug.LogFormat("append updatefilemanifest({0}) to ManifestManager.fileManifest({1})", updateList.appNumVersion, ManifestManager.fileManifest.appNumVersion);
                }
                else
                {
                    Debug.LogFormat("updatefilemanifest({0}) < ManifestManager.fileManifest({1}) don't need append", updateList.appNumVersion, fileManifest.appNumVersion);
                }
            }
            return(canAppend);
        }
예제 #2
0
        public static void LoadUpdateFileManifest(System.Action onComplete)
        {
            var         fileListName = Common.CRC32_FILELIST_NAME;
            var         url          = CUtils.PathCombine(CUtils.GetRealPersistentDataPath(), CUtils.GetRightFileName(fileListName));
            AssetBundle ab           = null;

            if (FileHelper.FileExists(url) && (ab = AssetBundle.LoadFromFile(url)) != null)
            {
                var assets = ab.LoadAllAssets <FileManifest>();
                if (assets.Length > 0)
                {
                    ManifestManager.updateFileManifest = assets[0];
                }
                ab.Unload(false);

                if (ManifestManager.fileManifest != null && ManifestManager.updateFileManifest != null)
                {
                    ManifestManager.fileManifest.AppendFileManifest(ManifestManager.updateFileManifest);
                }
                else
                {
                    Debug.LogError(" updateFile Manifest asset is null url:" + url);
                }

#if HUGULA_LOADER_DEBUG || UNITY_EDITOR
                Debug.LogFormat("LoadUpdateFileManifest 2 {0} is done ! {1}", url, fileListName, ManifestManager.updateFileManifest);
#endif
            }

            if (onComplete != null)
            {
                onComplete();
            }
        }
예제 #3
0
        public List <ABInfo> CompareFileManifest(FileManifest compare)
        {
            List <ABInfo> re = new List <ABInfo>();

            if (compare == null)
            {
                return(re);
            }
            if (appNumVersion > compare.appNumVersion)
            {
                return(re);
            }
            var    compareABInfos = compare.allAbInfo;
            ABInfo abInfo;

            for (int i = 0; i < compareABInfos.Count; i++)
            {
                abInfo = compareABInfos[i];
                if (!CheckABCrc(abInfo))
                {
                    re.Add(abInfo);
                }
            }

            return(re);
        }
예제 #4
0
        /// <summary>
        /// 加载更新内容
        /// </summary>
        public uint AddDiffManifestTask(FileManifest mainifest1, FileManifest mainifest2, System.Action <LoadingEventArg> onProgress, System.Action <bool> onComplete)
        {
            if (mainifest1 == null)
            {
                return(0);
            }
            var spliteExtension = Hugula.HugulaSetting.instance.spliteExtensionFolder; //启动了分离

            var           loadInfos = mainifest1.CompareFileManifest(mainifest2);
            List <ABInfo> re        = new List <ABInfo> ();

            foreach (var abInfo in loadInfos)
            {
                if (!spliteExtension)
                {
                    re.Add(abInfo);
                }
                else if (abInfo.priority <= FileManifestOptions.AutoHotPriority)   //非自动下载级别
                {
                    re.Add(abInfo);
                }
                else if (FileHelper.PersistentFileExists(abInfo.abName))    //存在表示已经下载过但是版本不对
                {
                    re.Add(abInfo);
                }
            }

            re.Sort(abInfoCompare);

            return(AddTask(re, FileManifestOptions.FirstLoadPriority, onProgress, onComplete));
        }
예제 #5
0
        /// <summary>
        /// 加载first pack 包和更新内容
        /// </summary>
        public uint AddFirstManifestTask(FileManifest mainifest1, FileManifest mainifest2, System.Action <LoadingEventArg> onProgress, System.Action <bool> onComplete)
        {
            if (mainifest1 == null)
            {
                return(0);
            }

            List <ABInfo>             re    = new List <ABInfo> ();
            Dictionary <string, bool> added = new Dictionary <string, bool> ();
            var    localABInfos             = mainifest1.allAbInfo;
            var    diffABInfos = mainifest1.CompareFileManifest(mainifest2); //mainifest2.appNumVersion - mainifest1.appNumVersion >= 0;
            ABInfo abInfo;

            for (int i = 0; i < diffABInfos.Count; i++)
            {
                abInfo = diffABInfos[i];
                re.Add(abInfo);
                added[abInfo.abName] = true;
            }

            for (int i = 0; i < localABInfos.Count; i++)
            {
                abInfo = localABInfos[i];
                if (abInfo.priority >= FileManifestOptions.FirstLoadPriority &&
                    abInfo.priority < FileManifestOptions.AutoHotPriority && !added.ContainsKey(abInfo.abName))  //首包下载内容
                {
                    re.Add(abInfo);
                }
            }
            added.Clear();

            re.Sort(abInfoCompare);

            return(AddTask(re, FileManifestOptions.FirstLoadPriority, onProgress, onComplete));
        }
예제 #6
0
        public static void LoadFileManifest(System.Action onComplete)
        {
            var fileListName = Common.CRC32_FILELIST_NAME;
            var url          = CUtils.PathCombine(CUtils.GetRealStreamingAssetsPath(), CUtils.GetRightFileName(fileListName));

            url = CUtils.GetAndroidABLoadPath(url);
            AssetBundle ab = AssetBundle.LoadFromFile(url);

            if (ab != null)
            {
                var assets = ab.LoadAllAssets <FileManifest>();
                if (assets.Length > 0)
                {
                    ManifestManager.fileManifest = assets[0];
                }
                else
                {
                    Debug.LogWarning("there is no fileManifest in StreamingAssetsPath use (Hugula/BUild For Bublish) build ");
                }

#if HUGULA_LOADER_DEBUG || UNITY_EDITOR
                Debug.LogFormat("LoadFileManifest 1 {0} is done !\r\n ManifestManager.fileManifest.count = {1}", url, ManifestManager.fileManifest.Count);
#endif
                ab.Unload(false);
            }

            if (onComplete != null)
            {
                onComplete();
            }
        }
예제 #7
0
        public bool AppendFileManifest(FileManifest newFileManifest)
        {
            bool canAppend = appNumVersion <= newFileManifest.appNumVersion;

            newAppNumVersion = newFileManifest.appNumVersion;
            Debug.LogFormat("appNumVersion local={0},new={1}", appNumVersion, newFileManifest.appNumVersion);
            if (canAppend)
            {
                Debug.LogFormat("version old={0},new={1}", version, newFileManifest.version);
                var newVersion = newFileManifest.version;
                if (!string.IsNullOrEmpty(newVersion))
                {
                    version = newVersion;
                }
                else
                {
                    Debug.LogWarningFormat("newFileManifest({0}) version is null", newFileManifest.appNumVersion);
                }

                var variants = newFileManifest.allAssetBundlesWithVariant;
                for (int i = 0; i < variants.Length; i++)
                {
                    AddVariant(variants[i]);
                }

                var           list = newFileManifest.allAbInfo;
                ABInfo        abinfo;
                ABInfo        abinfo1;
                List <ABInfo> removes = new List <ABInfo>();
                for (int i = 0; i < list.Count; i++)
                {
                    abinfo = list[i];
                    if (abInfoDict.TryGetValue(abinfo.abName, out abinfo1) && abinfo.crc32 == abinfo1.crc32) //the same abinfo should remove
                    {
                        removes.Add(abinfo);
                    }
                    Add(abinfo);
                }

                for (int i = 0; i < removes.Count; i++)
                {
                    newFileManifest.Remove(removes[i]);
                }
            }

            return(canAppend);
        }
예제 #8
0
        public static bool SetUpdateFileManifest(FileManifest updateList)
        {
            bool canAppend = false;

            if (ManifestManager.fileManifest != null && updateList != null)
            {
                canAppend = ManifestManager.fileManifest.AppendFileManifest(updateList);
                if (canAppend)
                {
                    ManifestManager.updateFileManifest = updateList;
                    Debug.LogFormat("append updatefilemanifest({0}) to ManifestManager.fileManifest({1})", updateList.appNumVersion, ManifestManager.fileManifest.appNumVersion);
                }
                else
                {
                    Debug.LogFormat("updatefilemanifest({0}) < ManifestManager.fileManifest({1}) don't need append", updateList.appNumVersion, fileManifest.appNumVersion);
                }
            }
            return(canAppend);
        }
예제 #9
0
        public static bool LoadUpdateFileManifest(System.Action <bool> onComplete)
        {
            bool        needClearCache = false;
            var         fileListName   = Common.CRC32_FILELIST_NAME;
            var         url            = CUtils.PathCombine(CUtils.GetRealPersistentDataPath(), CUtils.GetRightFileName(fileListName));
            AssetBundle ab             = null;

            if (FileHelper.FileExists(url) && (ab = AssetBundle.LoadFromFile(url)) != null)
            {
                var          assets     = ab.LoadAllAssets <FileManifest> ();
                FileManifest updateList = null;
                if (assets.Length > 0)
                {
                    updateList = assets[0];
                }
                ab.Unload(false);

                if (updateList != null)
                {
                    bool canAppend = SetUpdateFileManifest(updateList);
                    needClearCache = !canAppend;
                }
                else if (ManifestManager.fileManifest != null)   // the update file manifest is out of version
                {
                    ManifestManager.fileManifest.newAppNumVersion = 0;
                    File.Delete(url);
                    needClearCache = true;
                    Debug.LogError(" updateFile Manifest asset is null url:" + url);
                }

#if HUGULA_LOADER_DEBUG || UNITY_EDITOR
                Debug.LogFormat("LoadUpdateFileManifest 2 {0} is done ! {1}", url, fileListName, ManifestManager.updateFileManifest);
#endif
            }

            if (onComplete != null)
            {
                onComplete(needClearCache);
            }

            return(needClearCache);
        }
예제 #10
0
        /// <summary>
        /// 加载手动下载内容
        /// </summary>
        public uint AddManualManifestTask(FileManifest mainifest1, string folder, System.Action <LoadingEventArg> onProgress, System.Action <bool> onComplete)
        {
            if (mainifest1 == null)
            {
                return(0);
            }

            var           allAbInfos = mainifest1.allAbInfo;
            List <ABInfo> loadInfos  = new List <ABInfo> ();
            ABInfo        abInfo;

            for (int i = 0; i < allAbInfos.Count; i++)
            {
                abInfo = allAbInfos[i];
                if (abInfo.abName.Contains(folder) && !FileHelper.PersistentFileExists(abInfo.abName))   // && abInfo.priority > FileManifestOptions.AutoHotPriority)
                {
                    loadInfos.Add(abInfo);
                }
            }

            loadInfos.Sort(abInfoCompare);

            return(AddTask(loadInfos, FileManifestOptions.ManualPriority, onProgress, onComplete)); //手动下载优先级最高
        }
예제 #11
0
        /// <summary>
        /// 加载后置下载内容
        /// </summary>
        public uint AddBackgroundManifestTask(FileManifest mainifest1, System.Action <LoadingEventArg> onProgress, System.Action <bool> onComplete)
        {
            if (mainifest1 == null)
            {
                return(0);
            }

            var           allAbInfos = mainifest1.allAbInfo;
            List <ABInfo> loadInfos  = new List <ABInfo> ();
            ABInfo        abInfo;

            for (int i = 0; i < allAbInfos.Count; i++)
            {
                abInfo = allAbInfos[i];
                if (abInfo.priority < FileManifestOptions.ManualPriority &&
                    abInfo.priority >= FileManifestOptions.AutoHotPriority &&
                    !FileHelper.PersistentFileExists(abInfo.abName))
                {
                    loadInfos.Add(abInfo);
                }
            }
            loadInfos.Sort(abInfoCompare);
            return(AddTask(loadInfos, FileManifestOptions.StreamingAssetsPriority, onProgress, onComplete));
        }