/// <summary> /// 检查更新 /// </summary> private void CheckVersionChange() { GameEntry.Log(LogCategory.Resource, "CheckVersionChange"); if (LocalAssetsManager.GetVersionFileExists()) { //判断只读区资源版本号和CDN资源版本号是否一致 if (!string.IsNullOrEmpty(m_LocalAssetsVersion) && m_LocalAssetsVersion.Equals(m_CDNVersion)) { GameEntry.Log(LogCategory.Resource, "可写区资源版本号和CDN资源版本号一致"); //一致 进入预加载流程 GameEntry.Procedure.ChangeState(ProcedureState.Preload); } else { GameEntry.Log(LogCategory.Resource, "可写区资源版本号和CDN资源版本号不一致"); BeginCheckVersionChange(); } } else { GameEntry.Log(LogCategory.Resource, "下载初始资源"); //下载初始资源 DownloadInitResources(); } }
public ResourceManager() { StreamingAssetsManager = new StreamingAssetsManager(); LocalAssetsManager = new LocalAssetsManager(); m_NeedDownloadList = new LinkedList <string>(); }
/// <summary> /// 将只读区版本文件初始化到可写区 /// </summary> private void InitVersionFileFormStreamingAssetsToLocal() { GameEntry.Log(LogCategory.Resource, "InitVersionFileFormStreamingAssetsToLocal"); m_LocalAssetsVersionDic = new Dictionary <string, AssetBundleInfoEntity>(); var enumerator = m_StreamingAssetsVersionDic.GetEnumerator(); while (enumerator.MoveNext()) { AssetBundleInfoEntity entity = enumerator.Current.Value; m_LocalAssetsVersionDic[enumerator.Current.Key] = new AssetBundleInfoEntity() { AssetBundleName = entity.AssetBundleName, MD5 = entity.MD5, Size = entity.Size, IsFirstData = entity.IsFirstData, IsEncrypt = entity.IsEncrypt }; } //保存版本文件 LocalAssetsManager.SaveVersionFile(m_LocalAssetsVersionDic); //保存版本号 m_LocalAssetsVersion = m_StreamingAssetsVersion; LocalAssetsManager.SetResourceVersion(m_LocalAssetsVersion); }
/// <summary> ///初始化可写区资源包信息 /// </summary> private void InitLocalAssetsBundleInfo() { GameEntry.Log(LogCategory.Resource, "InitLocalAssetsBundleInfo"); m_LocalAssetsVersionDic = LocalAssetsManager.GetAssetBundleVersionList(ref m_LocalAssetsVersion); //CheckVersionChange(); }
/// <summary> /// 保存版本信息 /// </summary> /// <param name="entity"></param> public void SaveVersion(AssetBundleInfoEntity entity) { if (m_LocalAssetsVersionDic == null) { m_LocalAssetsVersionDic = new Dictionary <string, AssetBundleInfoEntity>(); } m_LocalAssetsVersionDic[entity.AssetBundleName] = entity; //保存版本文件 LocalAssetsManager.SaveVersionFile(m_LocalAssetsVersionDic); }
/// <summary> /// 检查可写区版本文件是否存在 /// </summary> private void CheckVersionFileExistsInLocal() { GameEntry.Log(LogCategory.Resource, "CheckVersionFileExistsInLocal"); if (LocalAssetsManager.GetVersionFileExists()) { //可写区版本文件存在 //加载可写区资源包信息 InitLocalAssetsBundleInfo(); } else { //可写区版本文件不存在 //判断只读区版本文件是否存在 if (m_IsExistsStreamingAssetsBundleInfo) { //只读区版本文件存在 //将只读区版本文件初始化到可写区 InitVersionFileFormStreamingAssetsToLocal(); } } CheckVersionChange(); }
/// <summary> /// 保存资源版本号(用于检查版本更新完毕后 保存) /// </summary> public void SetResourceVersion() { m_LocalAssetsVersion = m_CDNVersion; LocalAssetsManager.SetResourceVersion(m_LocalAssetsVersion); }