/// <summary> /// 获取一个资源的下载路径 /// </summary> /// <param name="_versionItem"></param> /// <returns></returns> private string GetDownloadPath(AssetBundleVersionItem _versionItem) { if (null == _versionItem) { return(null); } string downloadFullPath = string.Format("{0}/{1}/{2}${3}.dat", AssetBundleDefine.SERVER_RES_PATH, AssetBundleDefine.RuntimePlatformName(), _versionItem.ItemName, _versionItem.MD5); return(downloadFullPath); }
/// <summary> /// 获取本地存储路径 /// </summary> /// <param name="_versionItem"></param> /// <returns></returns> public static string GetFileLocalPath(AssetBundleVersionItem _versionItem) { if (null == _versionItem) { return(null); } string fileFullPath = string.Format("{0}/{1}/{2}${3}.dat", AssetBundleDefine.AssetBundlesDir, AssetBundleDefine.RuntimePlatformName(), _versionItem.ItemName, _versionItem.MD5); return(fileFullPath); }
/// <summary> /// 单个资源下载完成 /// 将文件写入本地 /// 如果有压缩或者加密,可以在这里进行解析 /// </summary> /// <param name="s"></param> /// <param name="o"></param> /// <param name="arg3"></param> private void SingleAssetComplete(string s, object o, object arg3) { byte[] bytes = (byte[])o; AssetBundleVersionItem downloadItem = (AssetBundleVersionItem)arg3; string localItemPath = GetFileLocalPath(downloadItem); // 写入到本地 App.Make <IFileDiskSystem>().CreateFile(localItemPath, bytes); if (downloadItem.AssetPathType == AssetPathType.gameLoad) { // 广播,通知临时资源使用中心来替换临时资源(一般为模型,音效,UI等) AppEvent.BroadCastEvent(string.Format("{0}_{1}", AssetBundleDefine.ABDownloadSuccess, localItemPath)); } }