Update document
|
@ -28,9 +28,13 @@
|
|||
|
||||
(4) 模拟构建模式:在编辑器下配合EditorSimulateMode运行模式,来模拟真实运行的环境。
|
||||
|
||||
- **Build Version**
|
||||
|
||||
构建的资源包版本。
|
||||
|
||||
- **Build Package**
|
||||
|
||||
需要构建的资源包名称。
|
||||
构建的资源包名称。
|
||||
|
||||
- **Encryption**
|
||||
|
||||
|
@ -70,38 +74,6 @@
|
|||
|
||||
点击构建按钮会开始构建流程,构建流程分为多个节点顺序执行,如果某个节点发生错误,会导致构建失败。错误信息可以在控制台查看。
|
||||
|
||||
### 资源包加密
|
||||
|
||||
编写继承IEncryptionServices接口的加密类。注意:加密类文件需要放置在Editor文件夹里。
|
||||
|
||||
````C#
|
||||
using System;
|
||||
using YooAsset.Editor;
|
||||
|
||||
public class GameEncryption : IEncryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测资源包是否需要加密
|
||||
/// </summary>
|
||||
bool IEncryptionServices.Check(string bundleName)
|
||||
{
|
||||
// 对配置表相关的资源包进行加密
|
||||
return bundleName.Contains("assets/config/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对数据进行加密,并返回加密后的数据
|
||||
/// </summary>
|
||||
byte[] IEncryptionServices.Encrypt(byte[] fileData)
|
||||
{
|
||||
int offset = 32;
|
||||
var temper = new byte[fileData.Length + offset];
|
||||
Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
|
||||
return temper;
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
### 补丁包
|
||||
|
||||
构建成功后会在输出目录下找到补丁包文件夹,该文件夹名称为本次构建时指定的资源版本号。
|
||||
|
@ -141,7 +113,6 @@ private static void BuildInternal(BuildTarget buildTarget)
|
|||
buildParameters.PackageName = "DefaultPackage";
|
||||
buildParameters.PackageVersion = "1.0.0";
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EncryptionServices = new GameEncryption();
|
||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
|
||||
buildParameters.CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||
|
|
|
@ -126,24 +126,15 @@ private IEnumerator TryUpdateStaticVersion()
|
|||
{
|
||||
// 如果获取远端资源版本成功,说明当前网络连接并无问题,可以走正常更新流程。
|
||||
......
|
||||
|
||||
// 注意:在成功下载所有资源之后,我们需要记录当前最新的资源版本号
|
||||
PlayerPrefs.SetString("STATIC_VERSION", packageCRC);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator TryUpdateStaticVersion()
|
||||
private IEnumerator WeaklyUpdate()
|
||||
{
|
||||
// 如果获取远端资源版本失败,我们走弱联网更新模式。
|
||||
// 注意:如果从来没有保存过版本信息,则需要从内部读取StaticVersion.bytes文件的版本信息。
|
||||
string packageVersion = PlayerPrefs.GetString("STATIC_VERSION", string.Empty);
|
||||
if (packageVersion == string.Empty)
|
||||
{
|
||||
packageVersion = LoadStaticVersionFromStreamingAssets();
|
||||
}
|
||||
|
||||
// 在弱联网情况下更新补丁清单
|
||||
var operation = package.WeaklyUpdateManifestAsync(packageVersion);
|
||||
// 弱联网更新方法,会优先加载沙盒内的清单,如果不存在再加载内置清单。
|
||||
// 在加载清单之后,验证清单内资源内容本地完整性。
|
||||
var operation = package.WeaklyUpdateManifestAsync();
|
||||
yield return operation;
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -151,7 +142,7 @@ private IEnumerator TryUpdateStaticVersion()
|
|||
}
|
||||
else
|
||||
{
|
||||
// 指定版本的资源内容本地并不完整,需要提示玩家更新。
|
||||
// 资源内容本地并不完整,需要提示玩家联网更新。
|
||||
ShowMessageBox("请检查本地网络,有新的游戏内容需要更新!");
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 161 KiB |
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 168 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 26 KiB |