mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-28 03:28:47 +00:00
Update document
This commit is contained in:
@@ -39,25 +39,25 @@
|
||||
````C#
|
||||
public class AssetEncrypter : IAssetEncrypter
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测资源包是否需要加密
|
||||
/// </summary>
|
||||
bool IAssetEncrypter.Check(string filePath)
|
||||
{
|
||||
// 对配置表相关的资源包进行加密
|
||||
return filePath.Contains("Assets/Config/");
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测资源包是否需要加密
|
||||
/// </summary>
|
||||
bool IAssetEncrypter.Check(string filePath)
|
||||
{
|
||||
// 对配置表相关的资源包进行加密
|
||||
return filePath.Contains("Assets/Config/");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对数据进行加密,并返回加密后的数据
|
||||
/// </summary>
|
||||
byte[] IAssetEncrypter.Encrypt(byte[] fileData)
|
||||
{
|
||||
int offset = 32;
|
||||
var temper = new byte[fileData.Length + offset];
|
||||
Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
|
||||
return temper;
|
||||
}
|
||||
/// <summary>
|
||||
/// 对数据进行加密,并返回加密后的数据
|
||||
/// </summary>
|
||||
byte[] IAssetEncrypter.Encrypt(byte[] fileData)
|
||||
{
|
||||
int offset = 32;
|
||||
var temper = new byte[fileData.Length + offset];
|
||||
Buffer.BlockCopy(fileData, 0, temper, offset, fileData.Length);
|
||||
return temper;
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
@@ -82,52 +82,52 @@ public class AssetEncrypter : IAssetEncrypter
|
||||
````c#
|
||||
private static void BuildInternal(BuildTarget buildTarget)
|
||||
{
|
||||
Debug.Log($"开始构建 : {buildTarget}");
|
||||
Debug.Log($"开始构建 : {buildTarget}");
|
||||
|
||||
// 打印命令行参数
|
||||
int buildVersion = GetBuildVersion();
|
||||
bool isForceBuild = IsForceBuild();
|
||||
Debug.Log($"资源版本 : {buildVersion}");
|
||||
Debug.Log($"强制重建 : {isForceBuild}");
|
||||
// 打印命令行参数
|
||||
int buildVersion = GetBuildVersion();
|
||||
bool isForceBuild = IsForceBuild();
|
||||
Debug.Log($"资源版本 : {buildVersion}");
|
||||
Debug.Log($"强制重建 : {isForceBuild}");
|
||||
|
||||
// 构建参数
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
AssetBundleBuilder.BuildParameters buildParameters = new AssetBundleBuilder.BuildParameters();
|
||||
buildParameters.IsVerifyBuildingResult = true;
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = buildTarget;
|
||||
buildParameters.BuildVersion = buildVersion;
|
||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||
buildParameters.AppendFileExtension = false;
|
||||
buildParameters.IsForceRebuild = isForceBuild;
|
||||
buildParameters.BuildinTags = "buildin";
|
||||
// 构建参数
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
AssetBundleBuilder.BuildParameters buildParameters = new AssetBundleBuilder.BuildParameters();
|
||||
buildParameters.IsVerifyBuildingResult = true;
|
||||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = buildTarget;
|
||||
buildParameters.BuildVersion = buildVersion;
|
||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||
buildParameters.AppendFileExtension = false;
|
||||
buildParameters.IsForceRebuild = isForceBuild;
|
||||
buildParameters.BuildinTags = "buildin";
|
||||
|
||||
// 执行构建
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
builder.Run(buildParameters);
|
||||
// 执行构建
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
builder.Run(buildParameters);
|
||||
|
||||
// 构建完成
|
||||
Debug.Log("构建完成");
|
||||
// 构建完成
|
||||
Debug.Log("构建完成");
|
||||
}
|
||||
|
||||
// 从构建命令里获取参数
|
||||
private static int GetBuildVersion()
|
||||
{
|
||||
foreach (string arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (arg.StartsWith("buildVersion"))
|
||||
return int.Parse(arg.Split("="[0])[1]);
|
||||
}
|
||||
return -1;
|
||||
foreach (string arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (arg.StartsWith("buildVersion"))
|
||||
return int.Parse(arg.Split("="[0])[1]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
private static bool IsForceBuild()
|
||||
{
|
||||
foreach (string arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (arg.StartsWith("forceBuild"))
|
||||
return arg.Split("="[0])[1] == "true" ? true : false;
|
||||
}
|
||||
return false;
|
||||
foreach (string arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (arg.StartsWith("forceBuild"))
|
||||
return arg.Split("="[0])[1] == "true" ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
````
|
||||
|
||||
|
||||
Reference in New Issue
Block a user