Update document

pull/51/head
hevinci 2022-10-18 19:27:47 +08:00
parent 0afe5ada2c
commit 5199430766
8 changed files with 65 additions and 29 deletions

View File

@ -52,6 +52,20 @@
(4) BundleName_HashName_Extension资源包名+哈希值+后缀名
- **Copy Buildin File Option**
首包资源文件的拷贝方式
(1) None不拷贝任何文件
(2) ClearAndCopyAll先清空已有文件然后拷贝所有文件
(3) ClearAndCopyByTags先清空已有文件然后按照资源标签拷贝文件
(4) OnlyCopyAll不清空已有文件直接拷贝所有文件
(5) OnlyCopyByTags不清空已有文件直接按照资源标签拷贝文件
- **构建**
点击构建按钮会开始构建流程,构建流程分为多个节点顺序执行,如果某个节点发生错误,会导致构建失败。错误信息可以在控制台查看。
@ -126,6 +140,7 @@ private static void BuildInternal(BuildTarget buildTarget)
buildParameters.EncryptionServices = new GameEncryption();
buildParameters.CompressOption = ECompressOption.LZ4;
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
// 执行构建
AssetBundleBuilder builder = new AssetBundleBuilder();

View File

@ -10,6 +10,10 @@
#### 公共设置
- Show Packages
是否展示资源包列表视图。
- Enable Addressable
启用可寻址资源定位系统。

View File

@ -3,7 +3,14 @@
初始化资源系统
```c#
// 初始化资源系统
YooAssets.Initialize();
// 创建默认的资源包
var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage");
// 设置该资源包为默认的资源包可以使用YooAssets相关加载接口加载该资源包内容。
YooAssets.SetDefaultAssetsPackage(defaultPackage);
```
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
@ -17,10 +24,10 @@ YooAssets.Initialize();
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.EditorSimulateModeParameters();
var initParameters = new EditorSimulateModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", false);
yield return YooAssets.InitializeAsync(initParameters);
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
yield return defaultPackage.InitializeAsync(initParameters);
}
````
@ -33,9 +40,9 @@ private IEnumerator InitializeYooAsset()
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.OfflinePlayModeParameters();
var initParameters = new OfflinePlayModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
yield return YooAssets.InitializeAsync(initParameters);
yield return defaultPackage.InitializeAsync(initParameters);
}
````
@ -55,22 +62,22 @@ private IEnumerator InitializeYooAsset()
- DecryptionServices : 如果资源包在构建的时候有加密需要提供实现IDecryptionServices接口的实例类。
- QueryServices内置资源查询服务接口。
- DefaultHostServer : 默认的资源服务器IP地址。
- FallbackHostServer : 备用的资源服务器IP地址。
- VerifyLevel : 下载文件校验等级
````c#
private IEnumerator InitializeYooAsset()
{
var initParameters = new YooAssets.HostPlayModeParameters();
var initParameters = new HostPlayModeParameters();
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
initParameters.DecryptionServices = new BundleDecryptionServices();
initParameters.QueryServices = new QueryStreamingAssetsServices();
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0";
yield return YooAssets.InitializeAsync(initParameters);
yield return defaultPackage.InitializeAsync(initParameters);
}
// 文件解密服务类
@ -88,7 +95,8 @@ private class QueryStreamingAssetsServices : IQueryServices
public bool QueryStreamingAssets(string fileName)
{
// 注意使用了BetterStreamingAssets插件
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
}
}
````

View File

@ -9,7 +9,8 @@
````c#
private IEnumerator UpdateStaticVersion()
{
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync();
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync();
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
@ -33,7 +34,8 @@ private IEnumerator UpdateStaticVersion()
````c#
private IEnumerator UpdatePatchManifest()
{
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(packageCRC);
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateManifestOperation operation = package.UpdateManifestAsync(packageCRC);
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
@ -56,15 +58,15 @@ private IEnumerator UpdatePatchManifest()
补丁包下载接口:
- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新当前资源版本所有的资源包文件。
- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新资源标签指定的资源包文件。
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
- YooAssets.CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout)
用于下载更新指定的资源列表依赖的资源包文件。
@ -73,7 +75,8 @@ IEnumerator Download()
{
int downloadingMaxNum = 10;
int failedTryAgain = 3;
DownloaderOperation downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
int timeout = 60;
var downloader = YooAssets.CreatePatchDownloader(downloadingMaxNum, failedTryAgain, timeout);
//没有需要下载的资源
if (downloader.TotalDownloadCount == 0)
@ -114,7 +117,8 @@ IEnumerator Download()
````c#
private IEnumerator UpdateStaticVersion()
{
UpdateStaticVersionOperation operation = YooAssets.UpdateStaticVersionAsync(10);
var package = YooAssets.GetAssetsPackage("DefaultPackage");
UpdateStaticVersionOperation operation = package.UpdateStaticVersionAsync(10);
yield return operation;
if (operation.Status == EOperationStatus.Succeed)
{
@ -135,7 +139,7 @@ private IEnumerator UpdateStaticVersion()
}
// 在弱联网情况下更新补丁清单
UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(packageCRC);
UpdateManifestOperation operation2 = package.WeaklyUpdateManifestAsync(packageCRC);
yield return operation2;
if (operation2.Status == EOperationStatus.Succeed)
{

View File

@ -18,9 +18,9 @@
```c#
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
// 设定资源路径的根目录为:"Assets/GameRes",后续加载的资源定位地址填写相对路径:"Audio/bgMusic"
var createParameters = new YooAssets.EditorSimulateModeParameters();
var createParameters = new EditorSimulateModeParameters();
createParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
yield return YooAssets.InitializeAsync(createParameters);
yield return defaultPackage.InitializeAsync(createParameters);
......
YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
```
@ -31,9 +31,9 @@ YooAssets.LoadAssetAsync<AudioClip>("Audio/bgMusic");
// 以工程内的音频文件为例:"Assets/GameRes/Audio/bgMusic.mp3"
// 需要在资源配置界面启用可寻址功能Enable Addressable
// 配置界面的可寻址规则为AddressByFileName那么资源定位地址填写文件名称"bgMusic"
var createParameters = new YooAssets.EditorSimulateModeParameters();
var createParameters = new EditorSimulateModeParameters();
createParameters.LocationServices = new AddressLocationServices();
yield return YooAssets.InitializeAsync(createParameters);
yield return defaultPackage.InitializeAsync(createParameters);
......
YooAssets.LoadAssetAsync<AudioClip>("bgMusic");
````
@ -104,7 +104,8 @@ IEnumerator Start()
````c#
private void UnloadAssets()
{
YooAssets.UnloadUnusedAssets();
var package = YooAssets.GetAssetsPackage("DefaultPackage");
package.UnloadUnusedAssets();
}
````

View File

@ -65,7 +65,7 @@ go.transform.localScale = Vector3.one;
在运行游戏之前,请保证资源包可以构建成功!
```c#
public static YooAssetPackage AssetPackage;
public static AssetPackage DefaultPackage;
IEnumerator Start()
{
@ -73,24 +73,24 @@ IEnumerator Start()
YooAssets.Initialize();
// 创建资源包实例
AssetPackage = YooAssets.CreateAssetPackage("DefaultPackage");
DefaultPackage = YooAssets.CreateAssetPackage("DefaultPackage");
// 初始化资源包
......
yield return AssetPackage.InitializeAsync(createParameters);
yield return DefaultPackage.InitializeAsync(createParameters);
// 更新资源包版本
......
var operation = AssetPackage.UpdateManifestAsync(packageCRC);
var operation = DefaultPackage.UpdateManifestAsync(packageCRC);
yield return operation;
// 下载更新文件
var downloader = AssetPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
var downloader = DefaultPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
downloader.BeginDownload();
yield return downloader;
// 加载资源对象
var assetHandle = AssetPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
var assetHandle = DefaultPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
yield return assetHandle;
......
}

View File

@ -17,6 +17,10 @@ windows平台添加命令: **-force-gles**
YooAsset依赖于ScriptBuildPipelineSBP在PackageManager里找到SBP插件安装就可以了。
#### 问题使用FileZilla等FTP上传工具后文件下载总是验证失败
把传输类型修改为二进制就可以了。
#### 问题YooAsset支持Unity2018吗
YooAsset分俩部分编辑器代码和运行时代码。因为工具界面是使用UIElements编写的所以在Unity2019以前的版本是使用不了界面化工具。但是这并没有影响我们使用YooAsset以下提供一种解决方案。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 42 KiB