mirror of https://github.com/tuyoogame/YooAsset
Update document
parent
fbef706388
commit
fca99fe689
|
@ -0,0 +1,2 @@
|
|||
# 进阶教程
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
# 资源更新
|
||||
|
||||
**更新补丁清单**
|
||||
|
||||
对于联机运行模式,在初始化资源系统之后,需要立刻更新资源清单。
|
||||
|
||||
**注意**:在初始化资源系统的时候,可以选择是否忽略资源版本号,这会影响到我们的更新步骤。
|
||||
|
||||
- 没有忽略资源版本号:在更新之前先获取更新的资源版本号,一般通过HTTP访问游戏服务器来获取。
|
||||
- 忽略资源版本号:在更新的时候,资源版本号可以设置为0。
|
||||
|
||||
````c#
|
||||
private IEnumerator UpdatePatchManifest()
|
||||
{
|
||||
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(updateResourceVersion);
|
||||
yield return operation;
|
||||
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//更新成功
|
||||
}
|
||||
else
|
||||
{
|
||||
//更新失败
|
||||
Debug.LogError(operation.Error);
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
**补丁包下载**
|
||||
|
||||
在补丁清单更新完毕后,就可以更新资源文件了。
|
||||
|
||||
根据产品需求,可以选择更新全部资源,或者只更新部分资源。
|
||||
|
||||
补丁包下载接口:
|
||||
|
||||
- YooAssets.CreatePatchDownloader(string[] tags) 根据资源标签列表下载相关资源包文件
|
||||
- YooAssets.CreateBundleDownloader(string[] locations) 根据资源对象列表下载相关资源包文件
|
||||
|
||||
````c#
|
||||
IEnumerator Download()
|
||||
{
|
||||
string[] tags = { "buildin", "config" };
|
||||
int downloadingMaxNum = 10;
|
||||
int failedTryAgain = 3;
|
||||
DownloaderOperation downloader = YooAssets.CreatePatchDownloader(tags, downloadingMaxNum, failedTryAgain);
|
||||
|
||||
//没有需要下载的资源
|
||||
if (downloader.TotalDownloadCount == 0)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
//需要下载的文件总数和总大小
|
||||
int totalDownloadCount = downloader.TotalDownloadCount;
|
||||
long totalDownloadBytes = downloader.TotalDownloadBytes;
|
||||
|
||||
//注册回调方法
|
||||
downloader.OnDownloadFileFailedCallback = OneDownloadFileFailed;
|
||||
downloader.OnDownloadProgressCallback = OnDownloadProgressUpdate;
|
||||
downloader.OnDownloadOverCallback = OnDownloadOver;
|
||||
|
||||
//开启下载
|
||||
downloader.BeginDownload();
|
||||
yield return downloader;
|
||||
|
||||
//检测下载结果
|
||||
if (downloader.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//下载成功
|
||||
}
|
||||
else
|
||||
{
|
||||
//下载失败
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
|
||||
|
|
@ -118,3 +118,29 @@ void Handle_Completed(AssetOperationHandle handle)
|
|||
}
|
||||
````
|
||||
|
||||
**原生文件加载范例**
|
||||
|
||||
例如:wwise的初始化文件
|
||||
|
||||
````c#
|
||||
void Start()
|
||||
{
|
||||
//获取资源包信息
|
||||
string location = "wwise/init.bnk";
|
||||
BundleInfo bundleInfo = YooAssets.GetBundleInfo(location);
|
||||
|
||||
//文件路径
|
||||
string fileSourcePath = bundleInfo.LocalPath;
|
||||
string fileDestPath = $"{Application.persistentDataPath}/Audio/init.bnk";
|
||||
|
||||
//拷贝文件
|
||||
File.Copy(fileSourcePath, fileDestPath, true);
|
||||
|
||||
//注意:在安卓平台下,可以通过如下方法判断文件是否在APK内部。
|
||||
if(bundleInfo.IsBuildinJarFile())
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
````
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
# 资源更新
|
||||
|
||||
**更新补丁清单**
|
||||
|
||||
对于联机运行模式,在初始化资源系统之后,需要立刻更新资源清单。
|
||||
|
||||
在此之前,需要获取更新的资源版本号,一般通过HTTP访问游戏服务器来获取。
|
||||
|
||||
注意:如果资源系统在初始化的时候,选择忽略资源版本号,那么更新的资源版本号可以设置为0。
|
||||
|
||||
````c#
|
||||
private IEnumerator UpdatePatchManifest()
|
||||
{
|
||||
int updateResourceVersion = 123;
|
||||
int timeout = 30;
|
||||
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(updateResourceVersion, timeout);
|
||||
yield return operation;
|
||||
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//更新成功
|
||||
}
|
||||
else
|
||||
{
|
||||
//更新失败
|
||||
Debug.LogError(operation.Error);
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
**补丁包下载**
|
||||
|
||||
在补丁清单更新完毕后,就可以更新资源文件了。
|
||||
|
||||
根据产品需求,可以选择更新全部资源,或者只更新部分资源。
|
||||
|
||||
````c#
|
||||
private DownloaderOperation _downloader;
|
||||
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
private void CreateDownloader()
|
||||
{
|
||||
string[] tags = { "buildin", "config" };
|
||||
int downloadingMaxNum = 10;
|
||||
int failedTryAgain = 3;
|
||||
_downloader = YooAssets.CreatePatchDownloader(tags, downloadingMaxNum, failedTryAgain);
|
||||
if (_downloader.TotalDownloadCount == 0)
|
||||
{
|
||||
//没有需要下载的资源
|
||||
}
|
||||
else
|
||||
{
|
||||
//需要下载的文件总数和总大小
|
||||
int totalDownloadCount = _downloader.TotalDownloadCount;
|
||||
long totalDownloadBytes = _downloader.TotalDownloadBytes;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启下载
|
||||
/// </summary>
|
||||
private IEnumerator Download()
|
||||
{
|
||||
//注册回调方法
|
||||
_downloader.OnDownloadFileFailedCallback = OneDownloadFileFailed;
|
||||
_downloader.OnDownloadProgressCallback = OnDownloadProgressUpdate;
|
||||
_downloader.OnDownloadOverCallback = OnDownloadOver;
|
||||
|
||||
//开启下载
|
||||
_downloader.BeginDownload();
|
||||
yield return _downloader;
|
||||
|
||||
//检测下载结果
|
||||
if (_downloader.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//下载成功
|
||||
}
|
||||
else
|
||||
{
|
||||
//下载失败
|
||||
}
|
||||
}
|
||||
````
|
||||
|
12
README.md
12
README.md
|
@ -12,7 +12,7 @@ YooAsset是一个基于Unity3D引擎的资源管理插件。
|
|||
|
||||
- **灵活高效的加密方案**
|
||||
|
||||
提供多种加密策略,可以自定义加密规则,基于Unity官方的高效解密方案。
|
||||
基于Unity官方的高效解密方案,可以自定义加密规则。
|
||||
|
||||
- **基于引用计数方案**
|
||||
|
||||
|
@ -48,7 +48,11 @@ YooAsset是一个基于Unity3D引擎的资源管理插件。
|
|||
5. [资源部署](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AssetDeploy.md)
|
||||
|
||||
## 代码教程
|
||||
1. [初始化](https://github.com/tuyoogame/YooAsset/blob/master/Docs/YooAssetInit.md)
|
||||
2. [资源更新](https://github.com/tuyoogame/YooAsset/blob/master/Docs/YooAssetUpdater.md)
|
||||
3. [资源加载](https://github.com/tuyoogame/YooAsset/blob/master/Docs/YooAssetLoader.md)
|
||||
1. [初始化](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial1.md)
|
||||
2. [资源更新](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial2.md)
|
||||
3. [资源加载](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial3.md)
|
||||
|
||||
## 进阶教程
|
||||
|
||||
1. [资源版本管理](https://github.com/tuyoogame/YooAsset/blob/master/Docs/AdvancedTutorial1.md)
|
||||
|
||||
|
|
Loading…
Reference in New Issue