mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-16 21:00:14 +00:00
Update document
This commit is contained in:
@@ -16,8 +16,8 @@ private IEnumerator UpdateStaticVersion()
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//更新成功
|
||||
string PackageVersion = operation.PackageVersion;
|
||||
Debug.Log($"Updated package Version : {PackageVersion}");
|
||||
string packageVersion = operation.PackageVersion;
|
||||
Debug.Log($"Updated package Version : {packageVersion}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -66,7 +66,7 @@ private IEnumerator UpdatePatchManifest()
|
||||
|
||||
用于下载更新资源标签指定的资源包文件。
|
||||
|
||||
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
- YooAssets.CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
|
||||
用于下载更新指定的资源列表依赖的资源包文件。
|
||||
|
||||
@@ -131,25 +131,37 @@ private IEnumerator Start()
|
||||
// 如果获取远端资源版本失败,说明当前网络无连接。
|
||||
// 在正常开始游戏之前,需要验证本地清单内容的完整性。
|
||||
string packageVersion = package.GetPackageVersion();
|
||||
var operation = package.CheckPackageContentsAsync(packageVersion);
|
||||
var operation = package.PreDownloadPackageAsync(packageVersion);
|
||||
yield return operation;
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
if (operation.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
StartGame();
|
||||
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
|
||||
int downloadingMaxNum = 10;
|
||||
int failedTryAgain = 3;
|
||||
int timeout = 60;
|
||||
var downloader = operation.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout);
|
||||
if (downloader.TotalDownloadCount > 0)
|
||||
{
|
||||
// 资源内容本地并不完整,需要提示玩家联网更新。
|
||||
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 开始游戏
|
||||
StartGame();
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
### 源代码解析
|
||||
|
||||
Package.UpdatePackageManifestAsync()方法解析。
|
||||
|
||||
- 联机运行模式
|
||||
|
||||
UpdatePackageManifestAsync()为资源清单更新方法。该方法的内部实现原理如下:
|
||||
通过传入的清单版本,优先比对当前激活清单的版本,如果相同就直接返回成功。如果有差异就从缓存里去查找匹配的清单,如果缓存里不存在,就去远端下载并保存到沙盒里。最后加载沙盒内匹配的清单文件。
|
||||
|
||||

|
||||
|
||||
|
||||
Reference in New Issue
Block a user