mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-21 07:50:20 +00:00
Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03aa9780eb | ||
|
|
d3a9005964 | ||
|
|
48bcf4a848 | ||
|
|
72f0426531 | ||
|
|
44ec5b3de3 | ||
|
|
292fdb1288 | ||
|
|
76e65286fd | ||
|
|
9397a0ebae | ||
|
|
c37b5e52ac | ||
|
|
ecfced7195 | ||
|
|
1c7a79f7d7 | ||
|
|
1149906786 | ||
|
|
9db111c08a | ||
|
|
0844447b46 | ||
|
|
c7116ad165 | ||
|
|
a805e0639e | ||
|
|
e8e69a2e86 | ||
|
|
3e4761a60f | ||
|
|
3413157c67 | ||
|
|
b5f2174ed0 | ||
|
|
bdc8285255 | ||
|
|
cd79f0e434 | ||
|
|
171f40551e | ||
|
|
ba4efebbce | ||
|
|
2486287a0e | ||
|
|
2599639aeb | ||
|
|
c1192b37c6 | ||
|
|
1f647163f2 | ||
|
|
cc04efe76b | ||
|
|
18426d0481 | ||
|
|
500b469bce | ||
|
|
49c242e7bc | ||
|
|
2d72d6dbc9 | ||
|
|
1f3e55ebea | ||
|
|
0ecb37419b | ||
|
|
c758bf6530 | ||
|
|
46d985a720 | ||
|
|
9404882fc7 | ||
|
|
ec1c3d6070 | ||
|
|
8eb7816e30 | ||
|
|
c196e44bc6 | ||
|
|
989d88f7d3 | ||
|
|
cb4ebb6306 | ||
|
|
92e7ec9682 | ||
|
|
32b7ff1b36 | ||
|
|
5a68ef558f | ||
|
|
18d48ae963 | ||
|
|
d61c723933 | ||
|
|
bb64ff7278 | ||
|
|
d7760cd34d | ||
|
|
f9ecad1cf0 | ||
|
|
a6de89ab74 | ||
|
|
e663dcf83b | ||
|
|
88e8e5cd54 | ||
|
|
9b43d36793 | ||
|
|
794314a8e1 | ||
|
|
0a1c40cee5 | ||
|
|
958cdd25a5 | ||
|
|
2fb77c1bf8 | ||
|
|
3aa46664f7 | ||
|
|
8389ce5793 | ||
|
|
5199430766 |
@@ -2,6 +2,147 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.3.4] - 2022-11-04
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#29)修复了EditorHelper中根据guid找uxml有时候会出错的问题。
|
||||||
|
- (#37)修复了在修改GroupName和GroupDesc时,左侧Group栏显示没刷新的问题。
|
||||||
|
- (#38)修复了工程里没有shader的话,SBP构建会报异常的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了AssetsPackage.CheckPackageContentsAsync()方法
|
||||||
|
|
||||||
|
```c#
|
||||||
|
/// <summary>
|
||||||
|
/// 检查本地包裹内容的完整性
|
||||||
|
/// </summary>
|
||||||
|
public CheckPackageContentsOperation CheckPackageContentsAsync()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 优化了HostPlayMode的初始化逻辑,优先读取沙盒内的清单,如果不存在则读取内置清单。
|
||||||
|
|
||||||
|
- 重写了文件的加密和解密逻辑。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public interface IDecryptionServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件偏移解密方法
|
||||||
|
/// </summary>
|
||||||
|
ulong LoadFromFileOffset(DecryptFileInfo fileInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件内存解密方法
|
||||||
|
/// </summary>
|
||||||
|
byte[] LoadFromMemory(DecryptFileInfo fileInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件流解密方法
|
||||||
|
/// </summary>
|
||||||
|
System.IO.FileStream LoadFromStream(DecryptFileInfo fileInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件流解密的托管缓存大小
|
||||||
|
/// </summary>
|
||||||
|
uint GetManagedReadBufferSize();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- AssetBundleBuilder界面增加了构建版本选项。
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 移除了AssetsPackage.WeaklyUpdateManifestAsync()方法。
|
||||||
|
|
||||||
|
## [1.3.3] - 2022-10-27
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了资源回收方法无效的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了PackageVersion构建参数。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
public class BuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构建的包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string PackageVersion;
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- AssetBundleDebugger窗口增加了包裹名称显示列。
|
||||||
|
- AssetBundleDebugger窗口增加资源对象的加载耗时统计和显示。
|
||||||
|
- AssetBundleDebugger窗口增加帧调试数据导出功能。
|
||||||
|
- AssetBundleBuilder构建流程增加输出目录文件路径过长的检测。
|
||||||
|
- 下载器返回的错误提示增加HTTP Response Code。
|
||||||
|
- UpdateStaticVersionOperation.PackageCRC重名为UpdateStaticVersionOperation.PackageVersion。
|
||||||
|
- AssetPackage.GetHumanReadableVersion()重名为AssetPackage.GetPackageVersion()
|
||||||
|
|
||||||
|
## [1.3.2] - 2022-10-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了AssetBundleCollector界面点击修复按钮界面没有刷新的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了自定义证书认证方法。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
public static class YooAssets
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置下载系统参数,自定义的证书认证实例
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance)
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
- 新增了下载失败后清理文件的方法。
|
||||||
|
|
||||||
|
````c#
|
||||||
|
public static class YooAssets
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置下载系统参数,下载失败后清理文件的HTTP错误码
|
||||||
|
/// </summary>
|
||||||
|
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
- 新增了检查资源定位地址是否有效的方法。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public class AssetsPackage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 检查资源定位地址是否有效
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
public bool CheckLocationValid(string location)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 移除了ILocationServices接口类和初始化字段。
|
||||||
|
- 移除了AssetPackage.GetAssetPath(string location)方法。
|
||||||
|
- 移除了BuildParameters.EnableAddressable字段。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- AssetBundleCollector配置增加了UniqueBundleName设置,用于解决不同包裹之间Bundle名称冲突的问题。
|
||||||
|
|
||||||
## [1.3.1] - 2022-10-18
|
## [1.3.1] - 2022-10-18
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskBuilding(), //开始执行构建
|
new TaskBuilding(), //开始执行构建
|
||||||
new TaskVerifyBuildResult(), //验证构建结果
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
|
new TaskUpdateBuildInfo(), //更新构建信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
@@ -71,6 +72,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskBuilding_SBP(), //开始执行构建
|
new TaskBuilding_SBP(), //开始执行构建
|
||||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
|
new TaskUpdateBuildInfo(), //更新构建信息
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
new TaskCreatePatchPackage(), //制作补丁包
|
new TaskCreatePatchPackage(), //制作补丁包
|
||||||
@@ -86,7 +88,6 @@ namespace YooAsset.Editor
|
|||||||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageCRC = buildParametersContext.OutputPackageCRC;
|
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,27 +64,8 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string MakePipelineOutputDirectory(string outputRoot, string buildPackage, BuildTarget buildTarget, EBuildMode buildMode)
|
public static string MakePipelineOutputDirectory(string outputRoot, string buildPackage, BuildTarget buildTarget, EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
string result = $"{outputRoot}/{buildPackage}/{buildTarget}/{YooAssetSettings.OutputFolderName}";
|
string outputDirectory = $"{outputRoot}/{buildPackage}/{buildTarget}/{YooAssetSettings.OutputFolderName}";
|
||||||
if (buildMode == EBuildMode.DryRunBuild)
|
return outputDirectory;
|
||||||
result += $"_{EBuildMode.DryRunBuild}";
|
|
||||||
else if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
result += $"_{EBuildMode.SimulateBuild}";
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载补丁清单文件
|
|
||||||
/// </summary>
|
|
||||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, string packageName, string packageCRC)
|
|
||||||
{
|
|
||||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC)}";
|
|
||||||
if (File.Exists(filePath) == false)
|
|
||||||
{
|
|
||||||
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
string jsonData = FileUtility.ReadFile(filePath);
|
|
||||||
return PatchManifest.Deserialize(jsonData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,7 @@ namespace YooAsset.Editor
|
|||||||
private TextField _buildOutputField;
|
private TextField _buildOutputField;
|
||||||
private EnumField _buildPipelineField;
|
private EnumField _buildPipelineField;
|
||||||
private EnumField _buildModeField;
|
private EnumField _buildModeField;
|
||||||
|
private TextField _buildVersionField;
|
||||||
private PopupField<string> _buildPackageField;
|
private PopupField<string> _buildPackageField;
|
||||||
private PopupField<string> _encryptionField;
|
private PopupField<string> _encryptionField;
|
||||||
private EnumField _compressionField;
|
private EnumField _compressionField;
|
||||||
@@ -91,6 +92,10 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 构建版本
|
||||||
|
_buildVersionField = root.Q<TextField>("BuildVersion");
|
||||||
|
_buildVersionField.SetValueWithoutNotify(GetBuildPackageVersion());
|
||||||
|
|
||||||
// 构建包裹
|
// 构建包裹
|
||||||
var buildPackageContainer = root.Q("BuildPackageContainer");
|
var buildPackageContainer = root.Q("BuildPackageContainer");
|
||||||
if (_buildPackageNames.Count > 0)
|
if (_buildPackageNames.Count > 0)
|
||||||
@@ -255,9 +260,9 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildTarget = _buildTarget;
|
buildParameters.BuildTarget = _buildTarget;
|
||||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||||
|
buildParameters.PackageVersion = _buildVersionField.value;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
|
||||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||||
@@ -278,6 +283,13 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 构建版本相关
|
||||||
|
private string GetBuildPackageVersion()
|
||||||
|
{
|
||||||
|
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||||
|
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
// 构建包裹相关
|
// 构建包裹相关
|
||||||
private int GetDefaultPackageIndex(string packageName)
|
private int GetDefaultPackageIndex(string packageName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
|
||||||
<uie:EnumField label="Build Mode" name="BuildMode" />
|
<uie:EnumField label="Build Mode" name="BuildMode" />
|
||||||
|
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" style="width: 350px;" />
|
||||||
<ui:VisualElement name="BuildPackageContainer" style="height: 24px;" />
|
<ui:VisualElement name="BuildPackageContainer" style="height: 24px;" />
|
||||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||||
|
|||||||
@@ -14,16 +14,15 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.OutputRoot = defaultOutputRoot;
|
buildParameters.OutputRoot = defaultOutputRoot;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.BuildPackage = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
buildParameters.PackageVersion = "Simulate";
|
||||||
|
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
var buildResult = builder.Run(buildParameters);
|
var buildResult = builder.Run(buildParameters);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildPackage, buildParameters.BuildTarget, buildParameters.BuildMode);
|
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildResult.OutputPackageCRC);
|
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||||
string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
|
||||||
return manifestFilePath;
|
return manifestFilePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算主资源或共享资源的完整包名
|
/// 计算主资源或共享资源的完整包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CalculateFullBundleName()
|
public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
|
||||||
{
|
{
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
{
|
{
|
||||||
@@ -177,15 +177,22 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_referenceBundleNames.Count > 1)
|
||||||
|
{
|
||||||
|
IPackRule packRule = PackDirectory.StaticPackRule;
|
||||||
|
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
||||||
|
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||||
|
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_referenceBundleNames.Count > 1)
|
if (uniqueBundleName)
|
||||||
{
|
{
|
||||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
if (string.IsNullOrEmpty(_shareBundleName) == false)
|
||||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
_shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}";
|
||||||
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
|
||||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,6 +8,40 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class BuildBundleInfo
|
public class BuildBundleInfo
|
||||||
{
|
{
|
||||||
|
public class BuildPatchInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构建内容的哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string ContentHash { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string PatchFileHash { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string PatchFileCRC { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件哈希值
|
||||||
|
/// </summary>
|
||||||
|
public long PatchFileSize { set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建输出的文件路径
|
||||||
|
/// </summary>
|
||||||
|
public string BuildOutputFilePath { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 补丁包输出文件路径
|
||||||
|
/// </summary>
|
||||||
|
public string PatchOutputFilePath { set; get; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -19,6 +53,22 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildAssetInfo> BuildinAssets = new List<BuildAssetInfo>();
|
public readonly List<BuildAssetInfo> BuildinAssets = new List<BuildAssetInfo>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 补丁文件信息
|
||||||
|
/// </summary>
|
||||||
|
public readonly BuildPatchInfo PatchInfo = new BuildPatchInfo();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bundle文件的加载方法
|
||||||
|
/// </summary>
|
||||||
|
public EBundleLoadMethod LoadMethod { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加密生成文件的路径
|
||||||
|
/// 注意:如果未加密该路径为空
|
||||||
|
/// </summary>
|
||||||
|
public string EncryptedFilePath { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为原生文件
|
/// 是否为原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -36,9 +86,18 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建内容哈希值
|
/// 是否为加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ContentHash { set; get; } = "00000000000000000000000000000000"; //32位
|
public bool IsEncryptedFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(EncryptedFilePath))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public BuildBundleInfo(string bundleName)
|
public BuildBundleInfo(string bundleName)
|
||||||
@@ -117,5 +176,20 @@ namespace YooAsset.Editor
|
|||||||
build.assetNames = GetBuildinAssetPaths();
|
build.assetNames = GetBuildinAssetPaths();
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建PatchBundle类
|
||||||
|
/// </summary>
|
||||||
|
internal PatchBundle CreatePatchBundle()
|
||||||
|
{
|
||||||
|
string fileHash = PatchInfo.PatchFileHash;
|
||||||
|
string fileCRC = PatchInfo.PatchFileCRC;
|
||||||
|
long fileSize = PatchInfo.PatchFileSize;
|
||||||
|
bool isRawFile = IsRawFile;
|
||||||
|
byte loadMethod = (byte)LoadMethod;
|
||||||
|
string[] tags = GetBundleTags();
|
||||||
|
PatchBundle patchBundle = new PatchBundle(BundleName, fileHash, fileCRC, fileSize, isRawFile, loadMethod, tags);
|
||||||
|
return patchBundle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int AssetFileCount;
|
public int AssetFileCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,18 +64,6 @@ namespace YooAsset.Editor
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源包的分类标签列表
|
|
||||||
/// </summary>
|
|
||||||
public string[] GetBundleTags(string bundleName)
|
|
||||||
{
|
|
||||||
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
|
|
||||||
{
|
|
||||||
return bundleInfo.GetBundleTags();
|
|
||||||
}
|
|
||||||
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取AssetBundle内构建的资源路径列表
|
/// 获取AssetBundle内构建的资源路径列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||||
|
|
||||||
// 2. 获取所有收集器收集的资源
|
// 2. 获取所有收集器收集的资源
|
||||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
|
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
||||||
|
|
||||||
// 3. 剔除未被引用的依赖资源
|
// 3. 剔除未被引用的依赖资源
|
||||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||||
@@ -72,9 +73,13 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
context.AssetFileCount = buildAssetDic.Count;
|
|
||||||
|
|
||||||
// 6. 填充主动收集资源的依赖列表
|
// 6. 记录关键信息
|
||||||
|
context.AssetFileCount = buildAssetDic.Count;
|
||||||
|
context.EnableAddressable = buildResult.EnableAddressable;
|
||||||
|
context.UniqueBundleName = buildResult.UniqueBundleName;
|
||||||
|
|
||||||
|
// 7. 填充主动收集资源的依赖列表
|
||||||
foreach (var collectAssetInfo in allCollectAssets)
|
foreach (var collectAssetInfo in allCollectAssets)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
@@ -88,13 +93,13 @@ namespace YooAsset.Editor
|
|||||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 计算完整的资源包名
|
// 8. 计算完整的资源包名
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
pair.Value.CalculateFullBundleName();
|
pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 移除不参与构建的资源
|
// 9. 移除不参与构建的资源
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||||
{
|
{
|
||||||
@@ -107,7 +112,7 @@ namespace YooAsset.Editor
|
|||||||
buildAssetDic.Remove(removeValue.AssetPath);
|
buildAssetDic.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 构建资源包
|
// 10. 构建资源包
|
||||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
var allBuildinAssets = buildAssetDic.Values.ToList();
|
||||||
if (allBuildinAssets.Count == 0)
|
if (allBuildinAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
throw new Exception("构建的资源列表不能为空");
|
||||||
|
|||||||
@@ -57,26 +57,21 @@ namespace YooAsset.Editor
|
|||||||
public EBuildMode BuildMode;
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的Package名称
|
/// 构建的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPackage;
|
public string PackageName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 人类可读的版本信息
|
/// 构建的包裹版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string HumanReadableVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool VerifyBuildingResult = false;
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 启用可寻址资源定位
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableAddressable = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密类
|
/// 加密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -11,30 +11,12 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = string.Empty;
|
private string _packageOutputDirectory = string.Empty;
|
||||||
private string _outputPackageCRC = string.Empty;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建参数
|
/// 构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildParameters Parameters { private set; get; }
|
public BuildParameters Parameters { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建输出的包裹清单哈希值
|
|
||||||
/// </summary>
|
|
||||||
public string OutputPackageCRC
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_outputPackageCRC))
|
|
||||||
throw new Exception("Output package file CRC32 is empty !");
|
|
||||||
return _outputPackageCRC;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_outputPackageCRC = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public BuildParametersContext(BuildParameters parameters)
|
public BuildParametersContext(BuildParameters parameters)
|
||||||
{
|
{
|
||||||
@@ -49,7 +31,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
_pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(Parameters.OutputRoot, Parameters.BuildPackage, Parameters.BuildTarget, Parameters.BuildMode);
|
_pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(Parameters.OutputRoot, Parameters.PackageName, Parameters.BuildTarget, Parameters.BuildMode);
|
||||||
}
|
}
|
||||||
return _pipelineOutputDirectory;
|
return _pipelineOutputDirectory;
|
||||||
}
|
}
|
||||||
@@ -61,7 +43,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||||
{
|
{
|
||||||
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildPackage}/{Parameters.BuildTarget}/{OutputPackageCRC}";
|
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.PackageName}/{Parameters.BuildTarget}/{Parameters.PackageVersion}";
|
||||||
}
|
}
|
||||||
return _packageOutputDirectory;
|
return _packageOutputDirectory;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
@@ -56,6 +57,9 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
public static void Serialize(string savePath, BuildReport buildReport)
|
public static void Serialize(string savePath, BuildReport buildReport)
|
||||||
{
|
{
|
||||||
|
if (File.Exists(savePath))
|
||||||
|
File.Delete(savePath);
|
||||||
|
|
||||||
string json = JsonUtility.ToJson(buildReport, true);
|
string json = JsonUtility.ToJson(buildReport, true);
|
||||||
FileUtility.CreateFile(savePath, json);
|
FileUtility.CreateFile(savePath, json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,21 +8,6 @@ namespace YooAsset.Editor
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportBundleInfo
|
public class ReportBundleInfo
|
||||||
{
|
{
|
||||||
public class FlagsData
|
|
||||||
{
|
|
||||||
public bool IsEncrypted { private set; get; }
|
|
||||||
public bool IsBuildin { private set; get; }
|
|
||||||
public bool IsRawFile { private set; get; }
|
|
||||||
public FlagsData(bool isEncrypted, bool isBuildin, bool isRawFile)
|
|
||||||
{
|
|
||||||
IsEncrypted = isEncrypted;
|
|
||||||
IsBuildin = isBuildin;
|
|
||||||
IsRawFile = isRawFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FlagsData _flagData;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -48,33 +33,21 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public long FileSize;
|
public long FileSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为原生文件
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRawFile;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载方法
|
||||||
|
/// </summary>
|
||||||
|
public EBundleLoadMethod LoadMethod;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tags
|
/// Tags
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
public string[] Tags;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Flags
|
|
||||||
/// </summary>
|
|
||||||
public int Flags;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取标志位的解析数据
|
|
||||||
/// </summary>
|
|
||||||
public FlagsData GetFlagData()
|
|
||||||
{
|
|
||||||
if (_flagData == null)
|
|
||||||
{
|
|
||||||
BitMask32 value = Flags;
|
|
||||||
bool isEncrypted = value.Test(0);
|
|
||||||
bool isBuildin = value.Test(1);
|
|
||||||
bool isRawFile = value.Test(2);
|
|
||||||
_flagData = new FlagsData(isEncrypted, isBuildin, isRawFile);
|
|
||||||
}
|
|
||||||
return _flagData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源分类标签的字符串
|
/// 获取资源分类标签的字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -85,16 +58,5 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否为原生文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IsRawFile()
|
|
||||||
{
|
|
||||||
if (System.IO.Path.GetExtension(BundleName) == $".{YooAssetSettingsData.Setting.RawFileVariant}")
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,15 +44,25 @@ namespace YooAsset.Editor
|
|||||||
public EBuildMode BuildMode;
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建包裹
|
/// 构建包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPackage;
|
public string BuildPackageName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string BuildPackageVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密服务类名称
|
/// 加密服务类名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -25,10 +25,5 @@ namespace YooAsset.Editor
|
|||||||
/// 输出的补丁包目录
|
/// 输出的补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OutputPackageDirectory;
|
public string OutputPackageDirectory;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 输出的包裹清单哈希值
|
|
||||||
/// </summary>
|
|
||||||
public string OutputPackageCRC;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,16 +25,19 @@ namespace YooAsset.Editor
|
|||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// 开始构建
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
BuildAssetBundleOptions buildOptions = buildParametersContext.GetPipelineBuildOptions();
|
BuildAssetBundleOptions buildOptions = buildParametersContext.GetPipelineBuildOptions();
|
||||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (buildResults == null)
|
if (buildResults == null)
|
||||||
|
{
|
||||||
throw new Exception("构建过程中发生错误!");
|
throw new Exception("构建过程中发生错误!");
|
||||||
|
}
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
string unityOutputManifestFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{YooAssetSettings.OutputFolderName}";
|
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||||
if(System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,10 +46,10 @@ namespace YooAsset.Editor
|
|||||||
buildResultContext.UnityManifest = buildResults;
|
buildResultContext.UnityManifest = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
||||||
|
// 拷贝原生文件
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
UpdateBuildBundleInfo(buildMapContext, buildParametersContext, buildResultContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,29 +72,5 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新构建结果
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
|
||||||
{
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile)
|
|
||||||
{
|
|
||||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
|
||||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
|
||||||
if (hash.isValid)
|
|
||||||
bundleInfo.ContentHash = hash.ToString();
|
|
||||||
else
|
|
||||||
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,10 +46,10 @@ namespace YooAsset.Editor
|
|||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
||||||
|
// 拷贝原生文件
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
UpdateBuildBundleInfo(buildMapContext, buildParametersContext, buildResultContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,29 +72,5 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新构建结果
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateBuildBundleInfo(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext, BuildResultContext buildResult)
|
|
||||||
{
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile)
|
|
||||||
{
|
|
||||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
|
||||||
bundleInfo.ContentHash = HashUtility.FileMD5(filePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
|
||||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
|
||||||
bundleInfo.ContentHash = value.Hash.ToString();
|
|
||||||
else
|
|
||||||
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,25 +12,30 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None)
|
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext);
|
if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None)
|
||||||
|
{
|
||||||
|
CopyBuildinFilesToStreaming(buildParametersContext, patchManifestContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝首包资源文件
|
/// 拷贝首包资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext)
|
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PatchManifestContext patchManifestContext)
|
||||||
{
|
{
|
||||||
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
||||||
string buildPackageName = buildParametersContext.Parameters.BuildPackage;
|
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||||
string outputPackageCRC = buildParametersContext.OutputPackageCRC;
|
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||||
|
|
||||||
// 加载补丁清单
|
// 加载补丁清单
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(packageOutputDirectory, buildPackageName, outputPackageCRC);
|
PatchManifest patchManifest = patchManifestContext.Manifest;
|
||||||
|
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
||||||
@@ -40,17 +45,25 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 拷贝补丁清单文件
|
// 拷贝补丁清单文件
|
||||||
{
|
{
|
||||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, outputPackageCRC);
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, buildPackageVersion);
|
||||||
string sourcePath = $"{packageOutputDirectory}/{manifestFileName}";
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
string destPath = $"{streamingAssetsDirectory}/{manifestFileName}";
|
string destPath = $"{streamingAssetsDirectory}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝静态版本文件
|
// 拷贝补丁清单哈希文件
|
||||||
{
|
{
|
||||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildPackageName);
|
string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(buildPackageName, buildPackageVersion);
|
||||||
string sourcePath = $"{packageOutputDirectory}/{versionFileName}";
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
string destPath = $"{streamingAssetsDirectory}/{versionFileName}";
|
string destPath = $"{streamingAssetsDirectory}/{fileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝补丁清单版本文件
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(buildPackageName);
|
||||||
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
|
string destPath = $"{streamingAssetsDirectory}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
public class PatchManifestContext : IContextObject
|
||||||
|
{
|
||||||
|
internal PatchManifest Manifest;
|
||||||
|
}
|
||||||
|
|
||||||
[TaskAttribute("创建补丁清单文件")]
|
[TaskAttribute("创建补丁清单文件")]
|
||||||
public class TaskCreatePatchManifest : IBuildTask
|
public class TaskCreatePatchManifest : IBuildTask
|
||||||
{
|
{
|
||||||
@@ -21,24 +26,25 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePatchManifestFile(BuildContext context)
|
private void CreatePatchManifestFile(BuildContext context)
|
||||||
{
|
{
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PatchManifest patchManifest = new PatchManifest();
|
PatchManifest patchManifest = new PatchManifest();
|
||||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||||
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
|
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
|
||||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
patchManifest.PackageName = buildParameters.PackageName;
|
||||||
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
patchManifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||||
|
|
||||||
// 更新Unity内置资源包的引用关系
|
// 更新Unity内置资源包的引用关系
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
if(buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
|
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
|
||||||
@@ -46,24 +52,35 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单文件
|
// 创建补丁清单文件
|
||||||
string manifestFileTempName = YooAssetSettingsData.GetPatchManifestTempFileName(buildParameters.BuildPackage);
|
string packageHash;
|
||||||
string manifestFileTempPath = $"{pipelineOutputDirectory}/{manifestFileTempName}";
|
{
|
||||||
BuildRunner.Log($"创建补丁清单文件:{manifestFileTempPath}");
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
PatchManifest.Serialize(manifestFileTempPath, patchManifest);
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
|
PatchManifest.Serialize(filePath, patchManifest);
|
||||||
|
packageHash = HashUtility.FileMD5(filePath);
|
||||||
|
BuildRunner.Log($"创建补丁清单文件:{filePath}");
|
||||||
|
|
||||||
// 计算补丁清单文件的CRC32
|
var patchManifestContext = new PatchManifestContext();
|
||||||
buildParametersContext.OutputPackageCRC = HashUtility.FileCRC32(manifestFileTempPath);
|
string jsonData = FileUtility.ReadFile(filePath);
|
||||||
|
patchManifestContext.Manifest = PatchManifest.Deserialize(jsonData);
|
||||||
|
context.SetContextObject(patchManifestContext);
|
||||||
|
}
|
||||||
|
|
||||||
// 补丁清单文件重命名
|
// 创建补丁清单哈希文件
|
||||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
{
|
||||||
string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
EditorTools.FileMoveTo(manifestFileTempPath, manifestFilePath);
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
|
FileUtility.CreateFile(filePath, packageHash);
|
||||||
|
BuildRunner.Log($"创建补丁清单哈希文件:{filePath}");
|
||||||
|
}
|
||||||
|
|
||||||
// 创建静态版本文件
|
// 创建补丁清单版本文件
|
||||||
string staticVersionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
{
|
||||||
string staticVersionFilePath = $"{pipelineOutputDirectory}/{staticVersionFileName}";
|
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(buildParameters.PackageName);
|
||||||
BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.CreateFile(staticVersionFilePath, buildParametersContext.OutputPackageCRC);
|
FileUtility.CreateFile(filePath, buildParameters.PackageVersion);
|
||||||
|
BuildRunner.Log($"创建补丁清单版本文件:{filePath}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -71,61 +88,23 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
private List<PatchBundle> GetAllPatchBundle(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
|
||||||
List<PatchBundle> result = new List<PatchBundle>(1000);
|
List<PatchBundle> result = new List<PatchBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
var bundleName = bundleInfo.BundleName;
|
var patchBundle = bundleInfo.CreatePatchBundle();
|
||||||
string fileHash = GetBundleFileHash(bundleInfo, buildParameters);
|
|
||||||
string fileCRC = GetBundleFileCRC(bundleInfo, buildParameters);
|
|
||||||
long fileSize = GetBundleFileSize(bundleInfo, buildParameters);
|
|
||||||
string[] tags = buildMapContext.GetBundleTags(bundleName);
|
|
||||||
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
|
||||||
bool isRawFile = bundleInfo.IsRawFile;
|
|
||||||
|
|
||||||
PatchBundle patchBundle = new PatchBundle(bundleName, fileHash, fileCRC, fileSize, tags);
|
|
||||||
patchBundle.SetFlagsValue(isRawFile, isEncrypted);
|
|
||||||
result.Add(patchBundle);
|
result.Add(patchBundle);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
private string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
|
||||||
{
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000000000000000000000000000"; //32位
|
|
||||||
|
|
||||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
|
||||||
return HashUtility.FileMD5(filePath);
|
|
||||||
}
|
|
||||||
private string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
|
||||||
{
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
|
|
||||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
|
||||||
return HashUtility.FileCRC32(filePath);
|
|
||||||
}
|
|
||||||
private long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
|
||||||
{
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
string filePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/{bundleInfo.BundleName}";
|
|
||||||
return FileUtility.GetFileSize(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源列表
|
/// 获取资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||||
@@ -135,7 +114,7 @@ namespace YooAsset.Editor
|
|||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PatchAsset patchAsset = new PatchAsset();
|
PatchAsset patchAsset = new PatchAsset();
|
||||||
if (buildParameters.Parameters.EnableAddressable)
|
if (buildMapContext.EnableAddressable)
|
||||||
patchAsset.Address = assetInfo.Address;
|
patchAsset.Address = assetInfo.Address;
|
||||||
else
|
else
|
||||||
patchAsset.Address = string.Empty;
|
patchAsset.Address = string.Empty;
|
||||||
@@ -189,6 +168,10 @@ namespace YooAsset.Editor
|
|||||||
shaderBundleReferenceList.Add(valuePair.Key);
|
shaderBundleReferenceList.Add(valuePair.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注意:没有任何资源依赖着色器
|
||||||
|
if (shaderBundleReferenceList.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// 获取着色器资源包索引
|
// 获取着色器资源包索引
|
||||||
Predicate<PatchBundle> predicate = new Predicate<PatchBundle>(s => s.BundleName == shadersBunldeName);
|
Predicate<PatchBundle> predicate = new Predicate<PatchBundle>(s => s.BundleName == shadersBunldeName);
|
||||||
int shaderBundleId = patchManifest.BundleList.FindIndex(predicate);
|
int shaderBundleId = patchManifest.BundleList.FindIndex(predicate);
|
||||||
|
|||||||
@@ -9,47 +9,24 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
CopyPatchFiles(buildParameters);
|
CopyPatchFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPatchFiles(BuildParametersContext buildParametersContext)
|
private void CopyPatchFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
BuildRunner.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝Report文件
|
|
||||||
{
|
|
||||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{reportFileName}";
|
|
||||||
string destPath = $"{packageOutputDirectory}/{reportFileName}";
|
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拷贝补丁清单文件
|
|
||||||
{
|
|
||||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
|
||||||
string destPath = $"{packageOutputDirectory}/{manifestFileName}";
|
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拷贝静态版本文件
|
|
||||||
{
|
|
||||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}";
|
|
||||||
string destPath = $"{packageOutputDirectory}/{versionFileName}";
|
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
// 拷贝构建日志
|
// 拷贝构建日志
|
||||||
@@ -67,7 +44,7 @@ namespace YooAsset.Editor
|
|||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
{
|
{
|
||||||
// 拷贝UnityManifest序列化文件
|
// 拷贝UnityManifest序列化文件
|
||||||
{
|
{
|
||||||
@@ -83,16 +60,17 @@ namespace YooAsset.Editor
|
|||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
int patchFileTotalCount = buildMapContext.BundleInfos.Count;
|
||||||
int patchFileTotalCount = patchManifest.BundleList.Count;
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{patchBundle.BundleName}";
|
EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true);
|
||||||
string destPath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|||||||
@@ -12,24 +12,25 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
var patchManifestContext = context.GetContextObject<PatchManifestContext>();
|
||||||
buildParameters.StopWatch();
|
buildParameters.StopWatch();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext);
|
CreateReportFile(buildParameters, buildMapContext, patchManifestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
float buildSeconds = buildParameters.GetBuildingSeconds();
|
float buildSeconds = buildParameters.GetBuildingSeconds();
|
||||||
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
BuildRunner.Info($"Build time consuming {buildSeconds} seconds.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, PatchManifestContext patchManifestContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
PatchManifest patchManifest = patchManifestContext.Manifest;
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
@@ -45,8 +46,10 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||||
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
|
buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
|
||||||
|
buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
|
||||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
@@ -95,17 +98,14 @@ namespace YooAsset.Editor
|
|||||||
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
reportBundleInfo.FileCRC = patchBundle.FileCRC;
|
||||||
reportBundleInfo.FileSize = patchBundle.FileSize;
|
reportBundleInfo.FileSize = patchBundle.FileSize;
|
||||||
reportBundleInfo.Tags = patchBundle.Tags;
|
reportBundleInfo.Tags = patchBundle.Tags;
|
||||||
reportBundleInfo.Flags = patchBundle.Flags;
|
reportBundleInfo.IsRawFile = patchBundle.IsRawFile;
|
||||||
|
reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod;
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除旧文件
|
|
||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
|
||||||
string filePath = $"{pipelineOutputDirectory}/{fileName}";
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
File.Delete(filePath);
|
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
|
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ namespace YooAsset.Editor
|
|||||||
int fileCount = 0;
|
int fileCount = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsEncrypted)
|
if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
return fileCount;
|
return fileCount;
|
||||||
@@ -189,7 +189,7 @@ namespace YooAsset.Editor
|
|||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.IsEncrypted)
|
if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal)
|
||||||
fileBytes += patchBundle.FileSize;
|
fileBytes += patchBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
|
|||||||
@@ -9,19 +9,6 @@ namespace YooAsset.Editor
|
|||||||
[TaskAttribute("资源包加密")]
|
[TaskAttribute("资源包加密")]
|
||||||
public class TaskEncryption : IBuildTask
|
public class TaskEncryption : IBuildTask
|
||||||
{
|
{
|
||||||
public class EncryptionContext : IContextObject
|
|
||||||
{
|
|
||||||
public List<string> EncryptList;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检测是否为加密文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IsEncryptFile(string bundleName)
|
|
||||||
{
|
|
||||||
return EncryptList.Contains(bundleName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
@@ -30,65 +17,52 @@ namespace YooAsset.Editor
|
|||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
EncryptionContext encryptionContext = new EncryptionContext();
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
|
||||||
context.SetContextObject(encryptionContext);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EncryptionContext encryptionContext = new EncryptionContext();
|
|
||||||
encryptionContext.EncryptList = new List<string>();
|
|
||||||
context.SetContextObject(encryptionContext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密文件
|
/// 加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> EncryptFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||||
|
|
||||||
// 加密资源列表
|
|
||||||
List<string> encryptList = new List<string>();
|
|
||||||
|
|
||||||
// 如果没有设置加密类
|
// 如果没有设置加密类
|
||||||
if (encryptionServices == null)
|
if (encryptionServices == null)
|
||||||
return encryptList;
|
return;
|
||||||
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
if (encryptionServices.Check(bundleInfo.BundleName))
|
bundleInfo.LoadMethod = EBundleLoadMethod.Normal;
|
||||||
|
|
||||||
|
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||||
|
fileInfo.BundleName = bundleInfo.BundleName;
|
||||||
|
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
|
||||||
|
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||||
|
if (encryptResult.LoadMethod != EBundleLoadMethod.Normal)
|
||||||
{
|
{
|
||||||
|
// 注意:原生文件不支持加密
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
UnityEngine.Debug.LogWarning($"Encryption not support raw file : {bundleInfo.BundleName}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptList.Add(bundleInfo.BundleName);
|
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||||
|
FileUtility.CreateFile(filePath, encryptResult.EncryptedData);
|
||||||
// 注意:通过判断文件合法性,规避重复加密一个文件
|
bundleInfo.EncryptedFilePath = filePath;
|
||||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
bundleInfo.LoadMethod = encryptResult.LoadMethod;
|
||||||
byte[] fileData = File.ReadAllBytes(filePath);
|
BuildRunner.Log($"Bundle文件加密完成:{filePath}");
|
||||||
if (EditorTools.CheckBundleFileValid(fileData))
|
|
||||||
{
|
|
||||||
byte[] bytes = encryptionServices.Encrypt(fileData);
|
|
||||||
File.WriteAllBytes(filePath, bytes);
|
|
||||||
BuildRunner.Log($"文件加密完成:{filePath}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
|
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.BundleInfos.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
if(encryptList.Count == 0)
|
|
||||||
UnityEngine.Debug.LogWarning($"没有发现需要加密的文件!");
|
|
||||||
return encryptList;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.BuildPackage);
|
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
BuildRunner.Log("构建内容准备完毕!");
|
BuildRunner.Log("构建内容准备完毕!");
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ namespace YooAsset.Editor
|
|||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
||||||
throw new Exception("请选择目标平台");
|
throw new Exception("请选择目标平台");
|
||||||
if (string.IsNullOrEmpty(buildParameters.BuildPackage))
|
if (string.IsNullOrEmpty(buildParameters.PackageName))
|
||||||
throw new Exception("包裹名称不能为空");
|
throw new Exception("包裹名称不能为空");
|
||||||
|
if(string.IsNullOrEmpty(buildParameters.PackageVersion))
|
||||||
|
throw new Exception("包裹版本不能为空");
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
@@ -40,6 +42,11 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception("首包资源标签不能为空!");
|
throw new Exception("首包资源标签不能为空!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}");
|
||||||
|
|
||||||
// 保存改动的资源
|
// 保存改动的资源
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
}
|
}
|
||||||
@@ -47,7 +54,7 @@ namespace YooAsset.Editor
|
|||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 删除平台总目录
|
// 删除平台总目录
|
||||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.BuildPackage}/{buildParameters.BuildTarget}";
|
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.PackageName}/{buildParameters.BuildTarget}";
|
||||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||||
{
|
{
|
||||||
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[TaskAttribute("更新构建信息")]
|
||||||
|
public class TaskUpdateBuildInfo : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
int outputNameStyle = (int)buildParametersContext.Parameters.OutputNameStyle;
|
||||||
|
|
||||||
|
// 1.检测路径长度
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
// NOTE:检测路径长度不要超过260字符。
|
||||||
|
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
if (filePath.Length >= 260)
|
||||||
|
throw new Exception($"The output bundle name is too long {filePath.Length} chars : {filePath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.更新构建输出的文件路径
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.IsEncryptedFile)
|
||||||
|
bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath;
|
||||||
|
else
|
||||||
|
bundleInfo.PatchInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3.更新文件其它信息
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
||||||
|
bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context);
|
||||||
|
bundleInfo.PatchInfo.PatchFileHash = GetBundleFileHash(buildOutputFilePath, buildParametersContext);
|
||||||
|
bundleInfo.PatchInfo.PatchFileCRC = GetBundleFileCRC(buildOutputFilePath, buildParametersContext);
|
||||||
|
bundleInfo.PatchInfo.PatchFileSize = GetBundleFileSize(buildOutputFilePath, buildParametersContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.更新补丁包输出的文件路径
|
||||||
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
string patchFileName = PatchManifest.CreateBundleFileName(outputNameStyle, bundleInfo.BundleName, bundleInfo.PatchInfo.PatchFileHash);
|
||||||
|
bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetBundleContentHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var parameters = buildParametersContext.Parameters;
|
||||||
|
var buildMode = parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
|
||||||
|
if (bundleInfo.IsRawFile)
|
||||||
|
{
|
||||||
|
string filePath = bundleInfo.PatchInfo.BuildOutputFilePath;
|
||||||
|
return HashUtility.FileMD5(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
|
{
|
||||||
|
var buildResult = context.GetContextObject<TaskBuilding.BuildResultContext>();
|
||||||
|
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||||
|
if (hash.isValid)
|
||||||
|
return hash.ToString();
|
||||||
|
else
|
||||||
|
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
||||||
|
}
|
||||||
|
else if (parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
|
{
|
||||||
|
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||||
|
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||||
|
return value.Hash.ToString();
|
||||||
|
else
|
||||||
|
throw new Exception($"Not found bundle in build result : {bundleInfo.BundleName}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
else
|
||||||
|
return HashUtility.FileMD5(filePath);
|
||||||
|
}
|
||||||
|
private string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
|
return "00000000"; //8位
|
||||||
|
else
|
||||||
|
return HashUtility.FileCRC32(filePath);
|
||||||
|
}
|
||||||
|
private long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return FileUtility.GetFileSize(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a8d6592eded144142afcf85c79cf1ce4
|
guid: 4882f54fbf0bcb04680fb581deae4889
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -62,6 +62,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 4. 验证Asset
|
// 4. 验证Asset
|
||||||
|
/*
|
||||||
bool isPass = true;
|
bool isPass = true;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
@@ -98,6 +99,7 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
BuildRunner.Log("构建结果验证成功!");
|
BuildRunner.Log("构建结果验证成功!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
public interface IEncryptionServices
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 检测是否需要加密
|
|
||||||
/// </summary>
|
|
||||||
bool Check(string bundleName);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加密方法
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fileData">要加密的文件数据</param>
|
|
||||||
/// <returns>返回加密后的字节数据</returns>
|
|
||||||
byte[] Encrypt(byte[] fileData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -132,10 +132,10 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
// 注意:模拟构建模式下只收集主资源
|
// 注意:模拟构建模式下只收集主资源
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
@@ -162,7 +162,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -177,7 +177,7 @@ namespace YooAsset.Editor
|
|||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
@@ -207,7 +207,7 @@ namespace YooAsset.Editor
|
|||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
string address = GetAddress(group, assetPath);
|
string address = GetAddress(group, assetPath);
|
||||||
string bundleName = GetBundleName(group, assetPath);
|
string bundleName = GetBundleName(group, assetPath);
|
||||||
@@ -215,7 +215,7 @@ namespace YooAsset.Editor
|
|||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<string>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "2.0";
|
public const string ConfigVersion = "2.1";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
|
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||||
public const string XmlShowPackageView = "ShowPackageView";
|
public const string XmlShowPackageView = "ShowPackageView";
|
||||||
|
|
||||||
public const string XmlPackage = "Package";
|
public const string XmlPackage = "Package";
|
||||||
@@ -62,6 +63,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 读取公共配置
|
// 读取公共配置
|
||||||
bool enableAddressable = false;
|
bool enableAddressable = false;
|
||||||
|
bool uniqueBundleName = false;
|
||||||
bool showPackageView = false;
|
bool showPackageView = false;
|
||||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
if (commonNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
@@ -69,10 +71,13 @@ namespace YooAsset.Editor
|
|||||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||||
|
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
|
||||||
|
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
|
||||||
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
||||||
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
||||||
|
|
||||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
|
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +151,7 @@ namespace YooAsset.Editor
|
|||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleCollectorSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||||
|
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
@@ -175,6 +181,7 @@ namespace YooAsset.Editor
|
|||||||
// 设置公共配置
|
// 设置公共配置
|
||||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||||
|
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||||
root.AppendChild(commonElement);
|
root.AppendChild(commonElement);
|
||||||
|
|
||||||
@@ -269,7 +276,23 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 更新版本
|
// 更新版本
|
||||||
root.SetAttribute(XmlVersion, "2.0");
|
root.SetAttribute(XmlVersion, "2.0");
|
||||||
|
return UpdateXmlConfig(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.0 -> 2.1
|
||||||
|
if (configVersion == "2.0")
|
||||||
|
{
|
||||||
|
// 添加公共元素属性
|
||||||
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
|
if (commonNodeList.Count > 0)
|
||||||
|
{
|
||||||
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
|
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
|
||||||
|
commonElement.SetAttribute(XmlUniqueBundleName, "False");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新版本
|
||||||
|
root.SetAttribute(XmlVersion, "2.1");
|
||||||
return UpdateXmlConfig(xmlDoc);
|
return UpdateXmlConfig(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ namespace YooAsset.Editor
|
|||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
|
var temper = collector.GetAllCollectAssets(command, this);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
|
var temper = group.GetAllCollectAssets(command);
|
||||||
foreach (var assetInfo in temper)
|
foreach (var assetInfo in temper)
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||||
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (enableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
HashSet<string> adressTemper = new HashSet<string>();
|
HashSet<string> adressTemper = new HashSet<string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示包裹视图
|
/// 是否显示包裹列表视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowPackageView = false;
|
public bool ShowPackageView = false;
|
||||||
|
|
||||||
@@ -18,6 +18,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -76,37 +81,43 @@ namespace YooAsset.Editor
|
|||||||
Debug.LogWarning($"Not found package : {packageName}");
|
Debug.LogWarning($"Not found package : {packageName}");
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹收集的资源文件
|
/// 获取包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
|
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(packageName))
|
if (string.IsNullOrEmpty(packageName))
|
||||||
throw new Exception("Build Package name is null or mepty !");
|
throw new Exception("Build package name is null or mepty !");
|
||||||
|
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
{
|
{
|
||||||
return package.GetAllCollectAssets(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||||
|
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
|
return collectResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception($"Not found collector pacakge : {packageName}");
|
throw new Exception($"Not found collector pacakge : {packageName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有包裹收集的资源文件
|
/// 获取所有包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllPackageAssets(EBuildMode buildMode)
|
public List<CollectResult> GetAllPackageAssets(EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
List<CollectAssetInfo> result = new List<CollectAssetInfo>(1000);
|
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
|
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||||
result.AddRange(temper);
|
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||||
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
|
collectResultList.Add(collectResult);
|
||||||
}
|
}
|
||||||
return result;
|
return collectResultList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,14 +347,20 @@ namespace YooAsset.Editor
|
|||||||
Setting.EnableAddressable = enableAddressable;
|
Setting.EnableAddressable = enableAddressable;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
Setting.UniqueBundleName = uniqueBundleName;
|
||||||
|
IsDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
// 资源包裹编辑相关
|
// 资源包裹编辑相关
|
||||||
public static void CreatePackage(string packageName)
|
public static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||||
{
|
{
|
||||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||||
package.PackageName = packageName;
|
package.PackageName = packageName;
|
||||||
Setting.Packages.Add(package);
|
Setting.Packages.Add(package);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
|
return package;
|
||||||
}
|
}
|
||||||
public static void RemovePackage(AssetBundleCollectorPackage package)
|
public static void RemovePackage(AssetBundleCollectorPackage package)
|
||||||
{
|
{
|
||||||
@@ -376,12 +382,13 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 资源分组编辑相关
|
// 资源分组编辑相关
|
||||||
public static void CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
public static AssetBundleCollectorGroup CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
||||||
{
|
{
|
||||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||||
group.GroupName = groupName;
|
group.GroupName = groupName;
|
||||||
package.Groups.Add(group);
|
package.Groups.Add(group);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private Toggle _showPackageToogle;
|
private Toggle _showPackageToogle;
|
||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
|
private Toggle _uniqueBundleNameToogle;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
@@ -87,6 +88,12 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
});
|
});
|
||||||
|
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
||||||
|
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
||||||
|
RefreshWindow();
|
||||||
|
});
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
@@ -180,6 +187,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
selectGroup.GroupName = evt.newValue;
|
selectGroup.GroupName = evt.newValue;
|
||||||
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
||||||
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -193,6 +201,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
selectGroup.GroupDesc = evt.newValue;
|
selectGroup.GroupDesc = evt.newValue;
|
||||||
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
AssetBundleCollectorSettingData.ModifyGroup(selectPackage, selectGroup);
|
||||||
|
FillGroupViewData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -289,6 +298,7 @@ namespace YooAsset.Editor
|
|||||||
private void FixBtn_clicked()
|
private void FixBtn_clicked()
|
||||||
{
|
{
|
||||||
AssetBundleCollectorSettingData.FixFile();
|
AssetBundleCollectorSettingData.FixFile();
|
||||||
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
private void ExportBtn_clicked()
|
private void ExportBtn_clicked()
|
||||||
{
|
{
|
||||||
@@ -733,8 +743,8 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
|
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||||
|
|||||||
@@ -50,5 +50,13 @@ namespace YooAsset.Editor
|
|||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名称追加包裹名
|
||||||
|
/// </summary>
|
||||||
|
public void BundleNameAppendPackageName(string packageName)
|
||||||
|
{
|
||||||
|
BundleName = $"{packageName.ToLower()}_{BundleName}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class CollectCommand
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 构建模式
|
||||||
|
/// </summary>
|
||||||
|
public EBuildMode BuildMode { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
|
public CollectCommand(EBuildMode buildMode, bool enableAddressable)
|
||||||
|
{
|
||||||
|
BuildMode = buildMode;
|
||||||
|
EnableAddressable = enableAddressable;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 8d996937ba73c9b4bb942b8ba6f43398
|
guid: b1741e85d76b28d41a4da3cd0e3e6f20
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal file
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class CollectResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用可寻址资源定位
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名唯一化
|
||||||
|
/// </summary>
|
||||||
|
public bool UniqueBundleName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集的资源信息列表
|
||||||
|
/// </summary>
|
||||||
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
EnableAddressable = enableAddressable;
|
||||||
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||||
|
{
|
||||||
|
CollectAssets = collectAssets;
|
||||||
|
|
||||||
|
if (UniqueBundleName)
|
||||||
|
{
|
||||||
|
foreach (var collectAsset in CollectAssets)
|
||||||
|
{
|
||||||
|
collectAsset.BundleNameAppendPackageName(PackageName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: cfc81e18e5b5f6f4b821c7427b34d349
|
guid: dbbd465f929ee33408441b62d19c7d10
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -73,6 +73,10 @@ namespace YooAsset.Editor
|
|||||||
var sampleBtn = root.Q<Button>("SampleButton");
|
var sampleBtn = root.Q<Button>("SampleButton");
|
||||||
sampleBtn.clicked += SampleBtn_onClick;
|
sampleBtn.clicked += SampleBtn_onClick;
|
||||||
|
|
||||||
|
// 导出按钮
|
||||||
|
var exportBtn = root.Q<Button>("ExportButton");
|
||||||
|
exportBtn.clicked += ExportBtn_clicked;
|
||||||
|
|
||||||
// 用户列表菜单
|
// 用户列表菜单
|
||||||
_playerName = root.Q<Label>("PlayerName");
|
_playerName = root.Q<Label>("PlayerName");
|
||||||
_playerName.text = "Editor player";
|
_playerName.text = "Editor player";
|
||||||
@@ -251,6 +255,32 @@ namespace YooAsset.Editor
|
|||||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||||
}
|
}
|
||||||
|
private void ExportBtn_clicked()
|
||||||
|
{
|
||||||
|
if (_currentReport == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Debug report is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||||
|
if (resultPath != null)
|
||||||
|
{
|
||||||
|
// 注意:排序保证生成配置的稳定性
|
||||||
|
foreach (var packageData in _currentReport.PackageDatas)
|
||||||
|
{
|
||||||
|
packageData.ProviderInfos.Sort();
|
||||||
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
|
{
|
||||||
|
providerInfo.DependBundleInfos.Sort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||||
|
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||||
|
FileUtility.CreateFile(filePath, fileContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||||
|
<uie:ToolbarButton text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<uie:Toolbar name="FrameToolbar">
|
<uie:Toolbar name="FrameToolbar">
|
||||||
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
|
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
|||||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
|
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
@@ -72,15 +72,24 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
var result = new List<DebugProviderInfo>(debugReport.ProviderInfos.Count);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||||
foreach (var providerInfo in debugReport.ProviderInfos)
|
foreach (var packageData in debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||||
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
continue;
|
{
|
||||||
|
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
providerInfo.PackageName = packageData.PackageName;
|
||||||
|
tempList.Add(providerInfo);
|
||||||
}
|
}
|
||||||
result.Add(providerInfo);
|
|
||||||
|
tempList.Sort();
|
||||||
|
result.AddRange(tempList);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -102,12 +111,22 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 资源列表相关
|
// 顶部列表相关
|
||||||
private VisualElement MakeAssetListViewItem()
|
private VisualElement MakeAssetListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
element.style.flexDirection = FlexDirection.Row;
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label0";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 150;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
@@ -144,7 +163,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 100;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +173,16 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 100;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label6";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
@@ -165,6 +194,10 @@ namespace YooAsset.Editor
|
|||||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||||
var providerInfo = sourceData[index];
|
var providerInfo = sourceData[index];
|
||||||
|
|
||||||
|
// Package Name
|
||||||
|
var label0 = element.Q<Label>("Label0");
|
||||||
|
label0.text = providerInfo.PackageName;
|
||||||
|
|
||||||
// Asset Path
|
// Asset Path
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = providerInfo.AssetPath;
|
label1.text = providerInfo.AssetPath;
|
||||||
@@ -177,9 +210,13 @@ namespace YooAsset.Editor
|
|||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = providerInfo.SpawnTime;
|
label3.text = providerInfo.SpawnTime;
|
||||||
|
|
||||||
// Ref Count
|
// Loading Time
|
||||||
var label4 = element.Q<Label>("Label4");
|
var label4 = element.Q<Label>("Label4");
|
||||||
label4.text = providerInfo.RefCount.ToString();
|
label4.text = providerInfo.LoadingTime.ToString();
|
||||||
|
|
||||||
|
// Ref Count
|
||||||
|
var label5 = element.Q<Label>("Label5");
|
||||||
|
label5.text = providerInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
@@ -187,9 +224,9 @@ namespace YooAsset.Editor
|
|||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
var label5 = element.Q<Label>("Label5");
|
var label6 = element.Q<Label>("Label6");
|
||||||
label5.text = providerInfo.Status.ToString();
|
label6.text = providerInfo.Status.ToString();
|
||||||
label5.style.color = textColor;
|
label6.style.color = textColor;
|
||||||
}
|
}
|
||||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
@@ -200,7 +237,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 依赖列表相关
|
// 底部列表相关
|
||||||
private VisualElement MakeDependListViewItem()
|
private VisualElement MakeDependListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
@@ -255,11 +292,11 @@ namespace YooAsset.Editor
|
|||||||
var label4 = element.Q<Label>("Label4");
|
var label4 = element.Q<Label>("Label4");
|
||||||
label4.text = bundleInfo.Status.ToString();
|
label4.text = bundleInfo.Status.ToString();
|
||||||
}
|
}
|
||||||
private void FillDependListView(DebugProviderInfo providerInfo)
|
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||||
{
|
{
|
||||||
_dependListView.Clear();
|
_dependListView.Clear();
|
||||||
_dependListView.ClearSelection();
|
_dependListView.ClearSelection();
|
||||||
_dependListView.itemsSource = providerInfo.DependBundleInfos;
|
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||||
_dependListView.Rebuild();
|
_dependListView.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
|
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar4" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Loading Time (ms)" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar5" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
|
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar6" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|||||||
@@ -27,14 +27,14 @@ namespace YooAsset.Editor
|
|||||||
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
|
_visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
_bundleListView = _root.Q<ListView>("TopListView");
|
_bundleListView = _root.Q<ListView>("TopListView");
|
||||||
_bundleListView.makeItem = MakeAssetListViewItem;
|
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||||
_bundleListView.bindItem = BindAssetListViewItem;
|
_bundleListView.bindItem = BindBundleListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
#if UNITY_2020_1_OR_NEWER
|
||||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
|||||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||||
_usingListView.bindItem = BindIncludeListViewItem;
|
_usingListView.bindItem = BindIncludeListViewItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空页面
|
/// 清空页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -72,21 +72,33 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
Dictionary<string, DebugBundleInfo> result = new Dictionary<string, DebugBundleInfo>(debugReport.ProviderInfos.Count);
|
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||||
foreach (var providerInfo in debugReport.ProviderInfos)
|
foreach (var pakcageData in debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||||
|
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
continue;
|
{
|
||||||
|
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||||
|
{
|
||||||
|
bundleInfo.PackageName = pakcageData.PackageName;
|
||||||
|
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (result.ContainsKey(bundleInfo.BundleName) == false)
|
|
||||||
result.Add(bundleInfo.BundleName, bundleInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tempList = tempDic.Values.ToList();
|
||||||
|
tempList.Sort();
|
||||||
|
result.AddRange(tempList);
|
||||||
}
|
}
|
||||||
return result.Values.ToList();
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -107,11 +119,21 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
|
|
||||||
// 顶部列表相关
|
// 顶部列表相关
|
||||||
private VisualElement MakeAssetListViewItem()
|
private VisualElement MakeBundleListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
element.style.flexDirection = FlexDirection.Row;
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label0";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 150;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
@@ -144,11 +166,15 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindAssetListViewItem(VisualElement element, int index)
|
private void BindBundleListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||||
var bundleInfo = sourceData[index];
|
var bundleInfo = sourceData[index];
|
||||||
|
|
||||||
|
// Package Name
|
||||||
|
var label0 = element.Q<Label>("Label0");
|
||||||
|
label0.text = bundleInfo.PackageName;
|
||||||
|
|
||||||
// Bundle Name
|
// Bundle Name
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = bundleInfo.BundleName;
|
label1.text = bundleInfo.BundleName;
|
||||||
@@ -172,7 +198,7 @@ namespace YooAsset.Editor
|
|||||||
foreach (var item in objs)
|
foreach (var item in objs)
|
||||||
{
|
{
|
||||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||||
FillUsingListView(bundleInfo.BundleName);
|
FillUsingListView(bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,17 +285,23 @@ namespace YooAsset.Editor
|
|||||||
var label5 = element.Q<Label>("Label5");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label5.text = providerInfo.Status.ToString();
|
label5.text = providerInfo.Status.ToString();
|
||||||
}
|
}
|
||||||
private void FillUsingListView(string bundleName)
|
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||||
foreach (var providerInfo in _debugReport.ProviderInfos)
|
foreach (var packageData in _debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == bundleName)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
source.Add(providerInfo);
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
continue;
|
{
|
||||||
|
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||||
|
{
|
||||||
|
source.Add(providerInfo);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
|
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
private ToolbarButton _topBar1;
|
private ToolbarButton _topBar1;
|
||||||
private ToolbarButton _topBar2;
|
private ToolbarButton _topBar2;
|
||||||
private ToolbarButton _topBar3;
|
private ToolbarButton _topBar3;
|
||||||
private ToolbarButton _topBar4;
|
private ToolbarButton _topBar5;
|
||||||
private ToolbarButton _bottomBar1;
|
private ToolbarButton _bottomBar1;
|
||||||
private ListView _bundleListView;
|
private ListView _bundleListView;
|
||||||
private ListView _includeListView;
|
private ListView _includeListView;
|
||||||
@@ -53,11 +53,11 @@ namespace YooAsset.Editor
|
|||||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
||||||
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
|
_topBar5 = _root.Q<ToolbarButton>("TopBar5");
|
||||||
_topBar1.clicked += TopBar1_clicked;
|
_topBar1.clicked += TopBar1_clicked;
|
||||||
_topBar2.clicked += TopBar2_clicked;
|
_topBar2.clicked += TopBar2_clicked;
|
||||||
_topBar3.clicked += TopBar3_clicked;
|
_topBar3.clicked += TopBar3_clicked;
|
||||||
_topBar4.clicked += TopBar4_clicked;
|
_topBar5.clicked += TopBar4_clicked;
|
||||||
|
|
||||||
// 底部按钮栏
|
// 底部按钮栏
|
||||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||||
@@ -144,7 +144,7 @@ namespace YooAsset.Editor
|
|||||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
||||||
_topBar2.text = "Size";
|
_topBar2.text = "Size";
|
||||||
_topBar3.text = "Hash";
|
_topBar3.text = "Hash";
|
||||||
_topBar4.text = "Tags";
|
_topBar5.text = "Tags";
|
||||||
|
|
||||||
if (_sortMode == ESortMode.BundleName)
|
if (_sortMode == ESortMode.BundleName)
|
||||||
{
|
{
|
||||||
@@ -163,9 +163,9 @@ namespace YooAsset.Editor
|
|||||||
else if (_sortMode == ESortMode.BundleTags)
|
else if (_sortMode == ESortMode.BundleTags)
|
||||||
{
|
{
|
||||||
if (_descendingSort)
|
if (_descendingSort)
|
||||||
_topBar4.text = "Tags ↓";
|
_topBar5.text = "Tags ↓";
|
||||||
else
|
else
|
||||||
_topBar4.text = "Tags ↑";
|
_topBar5.text = "Tags ↑";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -231,6 +231,16 @@ namespace YooAsset.Editor
|
|||||||
label.name = "Label5";
|
label.name = "Label5";
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 150;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label6";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
label.style.flexGrow = 1f;
|
label.style.flexGrow = 1f;
|
||||||
label.style.width = 80;
|
label.style.width = 80;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
@@ -255,9 +265,13 @@ namespace YooAsset.Editor
|
|||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.FileHash;
|
label3.text = bundleInfo.FileHash;
|
||||||
|
|
||||||
// Tags
|
// LoadMethod
|
||||||
var label5 = element.Q<Label>("Label5");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label5.text = bundleInfo.GetTagsString();
|
label5.text = bundleInfo.LoadMethod.ToString();
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
var label6 = element.Q<Label>("Label6");
|
||||||
|
label6.text = bundleInfo.GetTagsString();
|
||||||
}
|
}
|
||||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
@@ -271,7 +285,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void ShowAssetBundleInspector(ReportBundleInfo bundleInfo)
|
private void ShowAssetBundleInspector(ReportBundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsRawFile())
|
if (bundleInfo.IsRawFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar4" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="LoadMethod" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
|
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
|||||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
|||||||
public void FillViewData(BuildReport buildReport)
|
public void FillViewData(BuildReport buildReport)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
|
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
||||||
@@ -66,9 +66,11 @@ namespace YooAsset.Editor
|
|||||||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||||
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||||
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
|
_items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName));
|
||||||
|
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||||
|
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||||
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
|
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
|
|||||||
@@ -8,7 +8,14 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 停靠窗口类型集合
|
/// 停靠窗口类型集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleCollectorWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
public static readonly Type[] DockedWindowTypes =
|
||||||
|
{
|
||||||
|
typeof(AssetBundleBuilderWindow),
|
||||||
|
typeof(AssetBundleCollectorWindow),
|
||||||
|
typeof(AssetBundleDebuggerWindow),
|
||||||
|
typeof(AssetBundleReporterWindow),
|
||||||
|
typeof(ShaderVariantCollectorWindow)
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace YooAsset.Editor
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
|
||||||
|
|
||||||
|
/*
|
||||||
static EditorHelper()
|
static EditorHelper()
|
||||||
{
|
{
|
||||||
// 资源包收集
|
// 资源包收集
|
||||||
@@ -51,6 +52,46 @@ namespace YooAsset.Editor
|
|||||||
throw new System.Exception($"Invalid YooAsset window type : {windowType}");
|
throw new System.Exception($"Invalid YooAsset window type : {windowType}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载窗口的布局文件
|
||||||
|
/// </summary>
|
||||||
|
public static UnityEngine.UIElements.VisualTreeAsset LoadWindowUXML<TWindow>() where TWindow : class
|
||||||
|
{
|
||||||
|
var windowType = typeof(TWindow);
|
||||||
|
|
||||||
|
// 缓存里查询并加载
|
||||||
|
if (_uxmlDic.TryGetValue(windowType, out string uxmlGUID))
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GUIDToAssetPath(uxmlGUID);
|
||||||
|
if (string.IsNullOrEmpty(assetPath))
|
||||||
|
{
|
||||||
|
_uxmlDic.Clear();
|
||||||
|
throw new System.Exception($"Invalid UXML GUID : {uxmlGUID} ! Please close the window and open it again !");
|
||||||
|
}
|
||||||
|
var treeAsset = AssetDatabase.LoadAssetAtPath<UnityEngine.UIElements.VisualTreeAsset>(assetPath);
|
||||||
|
return treeAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 全局搜索并加载
|
||||||
|
string[] guids = AssetDatabase.FindAssets(windowType.Name);
|
||||||
|
if (guids.Length == 0)
|
||||||
|
throw new System.Exception($"Not found any assets : {windowType.Name}");
|
||||||
|
|
||||||
|
foreach (string assetGUID in guids)
|
||||||
|
{
|
||||||
|
string assetPath = AssetDatabase.GUIDToAssetPath(assetGUID);
|
||||||
|
var assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(UnityEngine.UIElements.VisualTreeAsset))
|
||||||
|
{
|
||||||
|
_uxmlDic.Add(windowType, assetGUID);
|
||||||
|
var treeAsset = AssetDatabase.LoadAssetAtPath<UnityEngine.UIElements.VisualTreeAsset>(assetPath);
|
||||||
|
return treeAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new System.Exception($"Not found UXML file : {windowType.Name}");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -349,9 +349,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件移动
|
/// 移动文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void FileMoveTo(string filePath, string destPath)
|
public static void MoveFile(string filePath, string destPath)
|
||||||
{
|
{
|
||||||
if (File.Exists(destPath))
|
if (File.Exists(destPath))
|
||||||
File.Delete(destPath);
|
File.Delete(destPath);
|
||||||
@@ -359,7 +359,7 @@ namespace YooAsset.Editor
|
|||||||
FileInfo fileInfo = new FileInfo(filePath);
|
FileInfo fileInfo = new FileInfo(filePath);
|
||||||
fileInfo.MoveTo(destPath);
|
fileInfo.MoveTo(destPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝文件夹
|
/// 拷贝文件夹
|
||||||
/// 注意:包括所有子目录的文件
|
/// 注意:包括所有子目录的文件
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ using UnityEditor;
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class ShaderVariantCollectionReadme
|
[Serializable]
|
||||||
|
public class ShaderVariantCollectionManifest
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ShaderVariantElement
|
public class ShaderVariantElement
|
||||||
@@ -44,52 +45,49 @@ namespace YooAsset.Editor
|
|||||||
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
|
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class ShaderVariantCollectionManifest
|
/// <summary>
|
||||||
|
/// Number of shaders in this collection
|
||||||
|
/// </summary>
|
||||||
|
public int ShaderTotalCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of total varians in this collection
|
||||||
|
/// </summary>
|
||||||
|
public int VariantTotalCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Shader variants info list.
|
||||||
|
/// </summary>
|
||||||
|
public List<ShaderVariantInfo> ShaderVariantInfos = new List<ShaderVariantInfo>(1000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加着色器变种信息
|
||||||
|
/// </summary>
|
||||||
|
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
|
||||||
{
|
{
|
||||||
/// <summary>
|
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
|
||||||
/// Number of shaders in this collection
|
ShaderVariantElement element = new ShaderVariantElement();
|
||||||
/// </summary>
|
element.PassType = passType;
|
||||||
public int ShaderTotalCount;
|
element.Keywords = keywords;
|
||||||
|
info.ShaderVariantElements.Add(element);
|
||||||
/// <summary>
|
}
|
||||||
/// Number of total varians in this collection
|
private ShaderVariantInfo GetOrCreateShaderVariantInfo(string assetPath, string shaderName)
|
||||||
/// </summary>
|
{
|
||||||
public int VariantTotalCount;
|
var selectList = ShaderVariantInfos.Where(t => t.ShaderName == shaderName && t.AssetPath == assetPath).ToList();
|
||||||
|
if (selectList.Count == 0)
|
||||||
/// <summary>
|
|
||||||
/// Shader variants info list.
|
|
||||||
/// </summary>
|
|
||||||
public List<ShaderVariantInfo> ShaderVariantInfos = new List<ShaderVariantInfo>(1000);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加着色器变种信息
|
|
||||||
/// </summary>
|
|
||||||
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
|
|
||||||
{
|
{
|
||||||
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
|
ShaderVariantInfo newInfo = new ShaderVariantInfo();
|
||||||
ShaderVariantElement element = new ShaderVariantElement();
|
newInfo.AssetPath = assetPath;
|
||||||
element.PassType = passType;
|
newInfo.ShaderName = shaderName;
|
||||||
element.Keywords = keywords;
|
ShaderVariantInfos.Add(newInfo);
|
||||||
info.ShaderVariantElements.Add(element);
|
return newInfo;
|
||||||
}
|
}
|
||||||
private ShaderVariantInfo GetOrCreateShaderVariantInfo(string assetPath, string shaderName)
|
|
||||||
{
|
|
||||||
var selectList = ShaderVariantInfos.Where(t => t.ShaderName == shaderName && t.AssetPath == assetPath).ToList();
|
|
||||||
if (selectList.Count == 0)
|
|
||||||
{
|
|
||||||
ShaderVariantInfo newInfo = new ShaderVariantInfo();
|
|
||||||
newInfo.AssetPath = assetPath;
|
|
||||||
newInfo.ShaderName = shaderName;
|
|
||||||
ShaderVariantInfos.Add(newInfo);
|
|
||||||
return newInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectList.Count != 1)
|
if (selectList.Count != 1)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
return selectList[0];
|
return selectList[0];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ namespace YooAsset.Editor
|
|||||||
// 保存结果
|
// 保存结果
|
||||||
ShaderVariantCollectionHelper.SaveCurrentShaderVariantCollection(_saveFilePath);
|
ShaderVariantCollectionHelper.SaveCurrentShaderVariantCollection(_saveFilePath);
|
||||||
|
|
||||||
// 创建说明文件
|
// 创建清单
|
||||||
CreateReadme();
|
CreateManifest();
|
||||||
|
|
||||||
Debug.Log($"搜集SVC完毕!");
|
Debug.Log($"搜集SVC完毕!");
|
||||||
_completedCallback?.Invoke();
|
_completedCallback?.Invoke();
|
||||||
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
throw new System.Exception("Shader variant file extension is invalid.");
|
throw new System.Exception("Shader variant file extension is invalid.");
|
||||||
|
|
||||||
// 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
// 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
||||||
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
EditorTools.CreateFileDirectory(saveFilePath);
|
EditorTools.CreateFileDirectory(saveFilePath);
|
||||||
_saveFilePath = saveFilePath;
|
_saveFilePath = saveFilePath;
|
||||||
_completedCallback = completedCallback;
|
_completedCallback = completedCallback;
|
||||||
@@ -64,7 +64,7 @@ namespace YooAsset.Editor
|
|||||||
ShaderVariantCollectionHelper.ClearCurrentShaderVariantCollection();
|
ShaderVariantCollectionHelper.ClearCurrentShaderVariantCollection();
|
||||||
|
|
||||||
// 创建临时测试场景
|
// 创建临时测试场景
|
||||||
CreateTemperScene();
|
CreateTempScene();
|
||||||
|
|
||||||
// 收集着色器变种
|
// 收集着色器变种
|
||||||
var materials = GetAllMaterials();
|
var materials = GetAllMaterials();
|
||||||
@@ -76,9 +76,8 @@ namespace YooAsset.Editor
|
|||||||
_elapsedTime.Start();
|
_elapsedTime.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateTemperScene()
|
private static void CreateTempScene()
|
||||||
{
|
{
|
||||||
// 创建临时场景
|
|
||||||
EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
|
EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
|
||||||
}
|
}
|
||||||
private static List<Material> GetAllMaterials()
|
private static List<Material> GetAllMaterials()
|
||||||
@@ -87,9 +86,14 @@ namespace YooAsset.Editor
|
|||||||
List<string> allAssets = new List<string>(1000);
|
List<string> allAssets = new List<string>(1000);
|
||||||
|
|
||||||
// 获取所有打包的资源
|
// 获取所有打包的资源
|
||||||
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
List<CollectAssetInfo> allCollectAssetInfos = new List<CollectAssetInfo>();
|
||||||
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
List<CollectResult> collectResults = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
||||||
foreach (var assetPath in collectAssets)
|
foreach (var collectResult in collectResults)
|
||||||
|
{
|
||||||
|
allCollectAssetInfos.AddRange(collectResult.CollectAssets);
|
||||||
|
}
|
||||||
|
List<string> allAssetPath = allCollectAssetInfos.Select(t => t.AssetPath).ToList();
|
||||||
|
foreach (var assetPath in allAssetPath)
|
||||||
{
|
{
|
||||||
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
|
||||||
foreach (var depend in depends)
|
foreach (var depend in depends)
|
||||||
@@ -97,7 +101,7 @@ namespace YooAsset.Editor
|
|||||||
if (allAssets.Contains(depend) == false)
|
if (allAssets.Contains(depend) == false)
|
||||||
allAssets.Add(depend);
|
allAssets.Add(depend);
|
||||||
}
|
}
|
||||||
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectAssets.Count);
|
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, allAssetPath.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
|
|
||||||
@@ -181,17 +185,17 @@ namespace YooAsset.Editor
|
|||||||
go.transform.position = position;
|
go.transform.position = position;
|
||||||
go.name = $"Sphere_{index}|{material.name}";
|
go.name = $"Sphere_{index}|{material.name}";
|
||||||
}
|
}
|
||||||
private static void CreateReadme()
|
private static void CreateManifest()
|
||||||
{
|
{
|
||||||
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
||||||
|
|
||||||
ShaderVariantCollection svc = AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(_saveFilePath);
|
ShaderVariantCollection svc = AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(_saveFilePath);
|
||||||
if (svc != null)
|
if (svc != null)
|
||||||
{
|
{
|
||||||
var wrapper = ShaderVariantCollectionReadme.Extract(svc);
|
var wrapper = ShaderVariantCollectionManifest.Extract(svc);
|
||||||
string jsonContents = JsonUtility.ToJson(wrapper, true);
|
string jsonData = JsonUtility.ToJson(wrapper, true);
|
||||||
string savePath = _saveFilePath.Replace(".shadervariants", "Manifest.json");
|
string savePath = _saveFilePath.Replace(".shadervariants", ".json");
|
||||||
File.WriteAllText(savePath, jsonContents);
|
File.WriteAllText(savePath, jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
|
||||||
|
|||||||
@@ -1,61 +1,82 @@
|
|||||||
using UnityEngine;
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class ShaderVariantCollectionWindow : EditorWindow
|
public class ShaderVariantCollectorWindow : EditorWindow
|
||||||
{
|
{
|
||||||
static ShaderVariantCollectionWindow _thisInstance;
|
|
||||||
|
|
||||||
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
[MenuItem("YooAsset/ShaderVariant Collector", false, 201)]
|
||||||
static void ShowWindow()
|
public static void ShowExample()
|
||||||
{
|
{
|
||||||
if (_thisInstance == null)
|
ShaderVariantCollectorWindow window = GetWindow<ShaderVariantCollectorWindow>("着色器变种收集工具", true, EditorDefine.DockedWindowTypes);
|
||||||
{
|
window.minSize = new Vector2(800, 600);
|
||||||
_thisInstance = GetWindow<ShaderVariantCollectionWindow>("着色器变种收集工具");
|
|
||||||
_thisInstance.minSize = new Vector2(800, 600);
|
|
||||||
}
|
|
||||||
_thisInstance.Show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShaderVariantCollection _selectSVC;
|
private Button _collectButton;
|
||||||
|
private TextField _collectOutputField;
|
||||||
|
private Label _currentShaderCountField;
|
||||||
|
private Label _currentVariantCountField;
|
||||||
|
|
||||||
private void OnGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.Space();
|
try
|
||||||
ShaderVariantCollectorSettingData.Setting.SavePath = EditorGUILayout.TextField("收集文件保存路径", ShaderVariantCollectorSettingData.Setting.SavePath);
|
|
||||||
|
|
||||||
int currentShaderCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
|
|
||||||
int currentVariantCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount();
|
|
||||||
EditorGUILayout.LabelField($"CurrentShaderCount : {currentShaderCount}");
|
|
||||||
EditorGUILayout.LabelField($"CurrentVariantCount : {currentVariantCount}");
|
|
||||||
|
|
||||||
// 搜集变种
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
|
|
||||||
{
|
{
|
||||||
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath, null);
|
VisualElement root = this.rootVisualElement;
|
||||||
}
|
|
||||||
|
|
||||||
// 查询
|
// 加载布局文件
|
||||||
EditorGUILayout.Space();
|
var visualAsset = EditorHelper.LoadWindowUXML<ShaderVariantCollectorWindow>();
|
||||||
if (GUILayout.Button("查询", GUILayout.MaxWidth(80)))
|
if (visualAsset == null)
|
||||||
{
|
|
||||||
string resultPath = EditorTools.OpenFilePath("Select File", "Assets/", "shadervariants");
|
|
||||||
if (string.IsNullOrEmpty(resultPath))
|
|
||||||
return;
|
return;
|
||||||
string assetPath = EditorTools.AbsolutePathToAssetPath(resultPath);
|
|
||||||
_selectSVC = AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(assetPath);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
|
// 文件输出目录
|
||||||
|
_collectOutputField = root.Q<TextField>("CollectOutput");
|
||||||
|
_collectOutputField.SetValueWithoutNotify(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
|
_collectOutputField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
ShaderVariantCollectorSettingData.Setting.SavePath = _collectOutputField.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
_currentShaderCountField = root.Q<Label>("CurrentShaderCount");
|
||||||
|
_currentVariantCountField = root.Q<Label>("CurrentVariantCount");
|
||||||
|
|
||||||
|
// 变种收集按钮
|
||||||
|
_collectButton = root.Q<Button>("CollectButton");
|
||||||
|
_collectButton.clicked += CollectButton_clicked;
|
||||||
|
|
||||||
|
//RefreshWindow();
|
||||||
}
|
}
|
||||||
if (_selectSVC != null)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
EditorGUILayout.LabelField($"ShaderCount : {_selectSVC.shaderCount}");
|
Debug.LogError(e.ToString());
|
||||||
EditorGUILayout.LabelField($"VariantCount : {_selectSVC.variantCount}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnDestroy()
|
private void Update()
|
||||||
{
|
{
|
||||||
ShaderVariantCollectorSettingData.SaveFile();
|
if (_currentShaderCountField != null)
|
||||||
|
{
|
||||||
|
int currentShaderCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
|
||||||
|
_currentShaderCountField.text = $"Current Shader Count : {currentShaderCount}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_currentVariantCountField != null)
|
||||||
|
{
|
||||||
|
int currentVariantCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount();
|
||||||
|
_currentVariantCountField.text = $"Current Variant Count : {currentVariantCount}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CollectButton_clicked()
|
||||||
|
{
|
||||||
|
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
||||||
|
<ui:VisualElement name="BuildContainer">
|
||||||
|
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" />
|
||||||
|
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" />
|
||||||
|
<ui:Label text="Current Variant Count" display-tooltip-when-elided="true" name="CurrentVariantCount" />
|
||||||
|
<ui:Button text="开始搜集" display-tooltip-when-elided="true" name="CollectButton" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9bff4878063eaf04dab8713e1e662ac5
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
@@ -131,6 +131,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
_loaders.Clear();
|
_loaders.Clear();
|
||||||
|
|
||||||
|
_sceneHandles.Clear();
|
||||||
|
|
||||||
// 注意:调用底层接口释放所有资源
|
// 注意:调用底层接口释放所有资源
|
||||||
Resources.UnloadUnusedAssets();
|
Resources.UnloadUnusedAssets();
|
||||||
}
|
}
|
||||||
@@ -142,6 +144,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load scene. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<SceneOperationHandle>();
|
return completedProvider.CreateHandle<SceneOperationHandle>();
|
||||||
@@ -190,6 +193,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load asset. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||||
@@ -216,6 +220,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to load sub assets. {assetInfo.Error}");
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
completedProvider.SetCompleted(assetInfo.Error);
|
completedProvider.SetCompleted(assetInfo.Error);
|
||||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
@@ -338,10 +343,10 @@ namespace YooAsset
|
|||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||||
providerInfo.PackageName = BundleServices.GetPackageName();
|
|
||||||
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
||||||
providerInfo.SpawnScene = provider.SpawnScene;
|
providerInfo.SpawnScene = provider.SpawnScene;
|
||||||
providerInfo.SpawnTime = provider.SpawnTime;
|
providerInfo.SpawnTime = provider.SpawnTime;
|
||||||
|
providerInfo.LoadingTime = provider.LoadingTime;
|
||||||
providerInfo.RefCount = provider.RefCount;
|
providerInfo.RefCount = provider.RefCount;
|
||||||
providerInfo.Status = (int)provider.Status;
|
providerInfo.Status = (int)provider.Status;
|
||||||
providerInfo.DependBundleInfos = new List<DebugBundleInfo>();
|
providerInfo.DependBundleInfos = new List<DebugBundleInfo>();
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ namespace YooAsset
|
|||||||
None = 0,
|
None = 0,
|
||||||
Download,
|
Download,
|
||||||
CheckDownload,
|
CheckDownload,
|
||||||
|
Unpack,
|
||||||
|
CheckUnpack,
|
||||||
LoadFile,
|
LoadFile,
|
||||||
CheckLoadFile,
|
CheckLoadFile,
|
||||||
Done,
|
Done,
|
||||||
@@ -22,8 +24,10 @@ namespace YooAsset
|
|||||||
private string _fileLoadPath;
|
private string _fileLoadPath;
|
||||||
private bool _isWaitForAsyncComplete = false;
|
private bool _isWaitForAsyncComplete = false;
|
||||||
private bool _isShowWaitForAsyncError = false;
|
private bool _isShowWaitForAsyncError = false;
|
||||||
|
private DownloaderBase _unpacker;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
private AssetBundleCreateRequest _createRequest;
|
private AssetBundleCreateRequest _createRequest;
|
||||||
|
private FileStream _fileStream;
|
||||||
|
|
||||||
|
|
||||||
public AssetBundleFileLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
public AssetBundleFileLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
||||||
@@ -47,8 +51,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
|
#if UNITY_ANDROID
|
||||||
|
EBundleLoadMethod loadMethod = (EBundleLoadMethod)MainBundleInfo.Bundle.LoadMethod;
|
||||||
|
if (loadMethod == EBundleLoadMethod.LoadFromMemory || loadMethod == EBundleLoadMethod.LoadFromStream)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Unpack;
|
||||||
|
_fileLoadPath = MainBundleInfo.Bundle.CachedFilePath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadFile;
|
||||||
|
_fileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||||
|
}
|
||||||
|
#else
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.LoadFile;
|
||||||
_fileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
_fileLoadPath = MainBundleInfo.Bundle.StreamingFilePath;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
{
|
{
|
||||||
@@ -87,7 +105,34 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 加载AssetBundle
|
// 3. 内置文件解压
|
||||||
|
if (_steps == ESteps.Unpack)
|
||||||
|
{
|
||||||
|
int failedTryAgain = 1;
|
||||||
|
var bundleInfo = HostPlayModeImpl.ConvertToUnpackInfo(MainBundleInfo.Bundle);
|
||||||
|
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
|
_steps = ESteps.CheckUnpack;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4.检测内置文件解压结果
|
||||||
|
if (_steps == ESteps.CheckUnpack)
|
||||||
|
{
|
||||||
|
if (_unpacker.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_unpacker.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = _unpacker.GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 加载AssetBundle
|
||||||
if (_steps == ESteps.LoadFile)
|
if (_steps == ESteps.LoadFile)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@@ -103,31 +148,63 @@ namespace YooAsset
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load assetBundle file
|
// Load assetBundle file
|
||||||
if (MainBundleInfo.Bundle.IsEncrypted)
|
var loadMethod = (EBundleLoadMethod)MainBundleInfo.Bundle.LoadMethod;
|
||||||
{
|
if (loadMethod == EBundleLoadMethod.Normal)
|
||||||
if (Impl.DecryptionServices == null)
|
|
||||||
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.Bundle.BundleName}");
|
|
||||||
|
|
||||||
DecryptionFileInfo fileInfo = new DecryptionFileInfo();
|
|
||||||
fileInfo.BundleName = MainBundleInfo.Bundle.BundleName;
|
|
||||||
fileInfo.FileHash = MainBundleInfo.Bundle.FileHash;
|
|
||||||
ulong offset = Impl.DecryptionServices.GetFileOffset(fileInfo);
|
|
||||||
if (_isWaitForAsyncComplete)
|
|
||||||
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
|
||||||
else
|
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath, 0, offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath);
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath);
|
||||||
else
|
else
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath);
|
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Impl.DecryptionServices == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"{nameof(IDecryptionServices)} is null : {MainBundleInfo.Bundle.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DecryptFileInfo fileInfo = new DecryptFileInfo();
|
||||||
|
fileInfo.BundleName = MainBundleInfo.Bundle.BundleName;
|
||||||
|
fileInfo.FilePath = _fileLoadPath;
|
||||||
|
|
||||||
|
if (loadMethod == EBundleLoadMethod.LoadFromFileOffset)
|
||||||
|
{
|
||||||
|
ulong offset = Impl.DecryptionServices.LoadFromFileOffset(fileInfo);
|
||||||
|
if (_isWaitForAsyncComplete)
|
||||||
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
||||||
|
else
|
||||||
|
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath, 0, offset);
|
||||||
|
}
|
||||||
|
else if (loadMethod == EBundleLoadMethod.LoadFromMemory)
|
||||||
|
{
|
||||||
|
byte[] fileData = Impl.DecryptionServices.LoadFromMemory(fileInfo);
|
||||||
|
if (_isWaitForAsyncComplete)
|
||||||
|
CacheBundle = AssetBundle.LoadFromMemory(fileData);
|
||||||
|
else
|
||||||
|
_createRequest = AssetBundle.LoadFromMemoryAsync(fileData);
|
||||||
|
}
|
||||||
|
else if (loadMethod == EBundleLoadMethod.LoadFromStream)
|
||||||
|
{
|
||||||
|
_fileStream = Impl.DecryptionServices.LoadFromStream(fileInfo);
|
||||||
|
uint managedReadBufferSize = Impl.DecryptionServices.GetManagedReadBufferSize();
|
||||||
|
if (_isWaitForAsyncComplete)
|
||||||
|
CacheBundle = AssetBundle.LoadFromStream(_fileStream, 0, managedReadBufferSize);
|
||||||
|
else
|
||||||
|
_createRequest = AssetBundle.LoadFromStreamAsync(_fileStream, 0, managedReadBufferSize);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
_steps = ESteps.CheckLoadFile;
|
_steps = ESteps.CheckLoadFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 检测AssetBundle加载结果
|
// 6. 检测AssetBundle加载结果
|
||||||
if (_steps == ESteps.CheckLoadFile)
|
if (_steps == ESteps.CheckLoadFile)
|
||||||
{
|
{
|
||||||
if (_createRequest != null)
|
if (_createRequest != null)
|
||||||
@@ -177,6 +254,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 销毁
|
||||||
|
/// </summary>
|
||||||
|
public override void Destroy(bool forceDestroy)
|
||||||
|
{
|
||||||
|
base.Destroy(forceDestroy);
|
||||||
|
|
||||||
|
if (_fileStream != null)
|
||||||
|
{
|
||||||
|
_fileStream.Close();
|
||||||
|
_fileStream.Dispose();
|
||||||
|
_fileStream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主线程等待异步操作完毕
|
/// 主线程等待异步操作完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 销毁
|
/// 销毁
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Destroy(bool forceDestroy)
|
public virtual void Destroy(bool forceDestroy)
|
||||||
{
|
{
|
||||||
IsDestroyed = true;
|
IsDestroyed = true;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace YooAsset
|
|||||||
LoadCacheFile,
|
LoadCacheFile,
|
||||||
CheckLoadCacheFile,
|
CheckLoadCacheFile,
|
||||||
LoadWebFile,
|
LoadWebFile,
|
||||||
CheckLoadWebFile,
|
CheckLoadWebFile,
|
||||||
TryLoadWebFile,
|
TryLoadWebFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ namespace YooAsset
|
|||||||
private UnityWebRequest _webRequest;
|
private UnityWebRequest _webRequest;
|
||||||
private AssetBundleCreateRequest _createRequest;
|
private AssetBundleCreateRequest _createRequest;
|
||||||
|
|
||||||
|
|
||||||
public AssetBundleWebLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
public AssetBundleWebLoader(AssetSystemImpl impl, BundleInfo bundleInfo) : base(impl, bundleInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -108,20 +108,18 @@ namespace YooAsset
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load assetBundle file
|
// Load assetBundle file
|
||||||
if (MainBundleInfo.Bundle.IsEncrypted)
|
var loadMethod = (EBundleLoadMethod)MainBundleInfo.Bundle.LoadMethod;
|
||||||
|
if (loadMethod == EBundleLoadMethod.Normal)
|
||||||
{
|
{
|
||||||
if (Impl.DecryptionServices == null)
|
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath);
|
||||||
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.Bundle.BundleName}");
|
|
||||||
|
|
||||||
DecryptionFileInfo fileInfo = new DecryptionFileInfo();
|
|
||||||
fileInfo.BundleName = MainBundleInfo.Bundle.BundleName;
|
|
||||||
fileInfo.FileHash = MainBundleInfo.Bundle.FileHash;
|
|
||||||
ulong offset = Impl.DecryptionServices.GetFileOffset(fileInfo);
|
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath, 0, offset);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath);
|
_steps = ESteps.Done;
|
||||||
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"WebGL not support encrypted bundle file : {MainBundleInfo.Bundle.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
_steps = ESteps.CheckLoadCacheFile;
|
_steps = ESteps.CheckLoadCacheFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Bundle文件的加载方法
|
||||||
|
/// </summary>
|
||||||
|
public enum EBundleLoadMethod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 正常加载(不需要解密)
|
||||||
|
/// </summary>
|
||||||
|
Normal = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过文件偏移来解密加载
|
||||||
|
/// </summary>
|
||||||
|
LoadFromFileOffset = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过文件内存来解密加载
|
||||||
|
/// </summary>
|
||||||
|
LoadFromMemory = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过文件流来解密加载
|
||||||
|
/// </summary>
|
||||||
|
LoadFromStream = 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5e32c14ed62806b4189d20ad48ce7631
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -146,7 +146,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = e.ToString();
|
Error = e.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,14 +171,14 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Prepare,
|
Prepare,
|
||||||
DownloadBuildinFile,
|
Unpack,
|
||||||
CheckDownload,
|
CheckUnpack,
|
||||||
CheckAndCopyFile,
|
CheckAndCopyFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _unpacker;
|
||||||
|
|
||||||
public OfflinePlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
public OfflinePlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
||||||
{
|
{
|
||||||
@@ -203,7 +203,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadBuildinFile;
|
_steps = ESteps.Unpack;
|
||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
{
|
{
|
||||||
@@ -215,27 +215,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 下载文件
|
// 2. 内置文件解压
|
||||||
if (_steps == ESteps.DownloadBuildinFile)
|
if (_steps == ESteps.Unpack)
|
||||||
{
|
{
|
||||||
int failedTryAgain = int.MaxValue;
|
int failedTryAgain = 1;
|
||||||
var bundleInfo = PatchHelper.ConvertToUnpackInfo(_bundleInfo.Bundle);
|
var bundleInfo = HostPlayModeImpl.ConvertToUnpackInfo(_bundleInfo.Bundle);
|
||||||
_downloader = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
_steps = ESteps.CheckDownload;
|
_steps = ESteps.CheckUnpack;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 检测下载结果
|
// 3. 检测内置文件解压结果
|
||||||
if (_steps == ESteps.CheckDownload)
|
if (_steps == ESteps.CheckUnpack)
|
||||||
{
|
{
|
||||||
Progress = _downloader.DownloadProgress;
|
Progress = _unpacker.DownloadProgress;
|
||||||
if (_downloader.IsDone() == false)
|
if (_unpacker.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloader.HasError())
|
if (_unpacker.HasError())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader.GetLastError();
|
Error = _unpacker.GetLastError();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -281,7 +281,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = e.ToString();
|
Error = e.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,14 +306,16 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Prepare,
|
Prepare,
|
||||||
DownloadWebFile,
|
Download,
|
||||||
DownloadBuildinFile,
|
|
||||||
CheckDownload,
|
CheckDownload,
|
||||||
|
Unpack,
|
||||||
|
CheckUnpack,
|
||||||
CheckAndCopyFile,
|
CheckAndCopyFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private DownloaderBase _unpacker;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
|
|
||||||
internal HostPlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
internal HostPlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
||||||
@@ -339,11 +341,11 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadWebFile;
|
_steps = ESteps.Download;
|
||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
{
|
{
|
||||||
_steps = ESteps.DownloadBuildinFile;
|
_steps = ESteps.Unpack;
|
||||||
}
|
}
|
||||||
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
{
|
{
|
||||||
@@ -356,23 +358,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. 下载远端文件
|
// 2. 下载远端文件
|
||||||
if (_steps == ESteps.DownloadWebFile)
|
if (_steps == ESteps.Download)
|
||||||
{
|
{
|
||||||
int failedTryAgain = int.MaxValue;
|
int failedTryAgain = int.MaxValue;
|
||||||
_downloader = DownloadSystem.BeginDownload(_bundleInfo, failedTryAgain);
|
_downloader = DownloadSystem.BeginDownload(_bundleInfo, failedTryAgain);
|
||||||
_steps = ESteps.CheckDownload;
|
_steps = ESteps.CheckDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 下载内置文件
|
// 3. 检测下载结果
|
||||||
if (_steps == ESteps.DownloadBuildinFile)
|
|
||||||
{
|
|
||||||
int failedTryAgain = int.MaxValue;
|
|
||||||
var bundleInfo = PatchHelper.ConvertToUnpackInfo(_bundleInfo.Bundle);
|
|
||||||
_downloader = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
|
||||||
_steps = ESteps.CheckDownload;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 检测下载结果
|
|
||||||
if (_steps == ESteps.CheckDownload)
|
if (_steps == ESteps.CheckDownload)
|
||||||
{
|
{
|
||||||
Progress = _downloader.DownloadProgress;
|
Progress = _downloader.DownloadProgress;
|
||||||
@@ -391,6 +384,34 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. 解压内置文件
|
||||||
|
if (_steps == ESteps.Unpack)
|
||||||
|
{
|
||||||
|
int failedTryAgain = 1;
|
||||||
|
var bundleInfo = HostPlayModeImpl.ConvertToUnpackInfo(_bundleInfo.Bundle);
|
||||||
|
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||||
|
_steps = ESteps.CheckUnpack;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 检测解压结果
|
||||||
|
if (_steps == ESteps.CheckUnpack)
|
||||||
|
{
|
||||||
|
Progress = _unpacker.DownloadProgress;
|
||||||
|
if (_unpacker.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_unpacker.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _unpacker.GetLastError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 5. 检测并拷贝原生文件
|
// 5. 检测并拷贝原生文件
|
||||||
if (_steps == ESteps.CheckAndCopyFile)
|
if (_steps == ESteps.CheckAndCopyFile)
|
||||||
{
|
{
|
||||||
@@ -429,7 +450,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = e.ToString();
|
Error = e.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
DebugRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -66,6 +68,7 @@ namespace YooAsset
|
|||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class BundledProvider : ProviderBase
|
internal abstract class BundledProvider : ProviderBase
|
||||||
{
|
{
|
||||||
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
|
protected AssetBundleLoaderBase OwnerBundle { private set; get; }
|
||||||
protected DependAssetBundleGroup DependBundleGroup { private set; get; }
|
protected DependAssetBundleGroup DependBundleGroup { private set; get; }
|
||||||
|
|
||||||
public BundledProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
public BundledProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||||
{
|
{
|
||||||
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
|
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
|
||||||
OwnerBundle.Reference();
|
OwnerBundle.Reference();
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
DebugRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ namespace YooAsset
|
|||||||
SceneManager.SetActiveScene(SceneObject);
|
SceneManager.SetActiveScene(SceneObject);
|
||||||
|
|
||||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||||
if(Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
{
|
{
|
||||||
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
||||||
YooLogger.Error(LastError);
|
YooLogger.Error(LastError);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
DebugRecording();
|
||||||
|
|
||||||
if (IsDone)
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -238,6 +238,15 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string SpawnTime = string.Empty;
|
public string SpawnTime = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载耗时(单位:毫秒)
|
||||||
|
/// </summary>
|
||||||
|
public long LoadingTime { protected set; get; }
|
||||||
|
|
||||||
|
// 加载耗时统计
|
||||||
|
private bool _isRecording = false;
|
||||||
|
private Stopwatch _watch;
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
public void InitSpawnDebugInfo()
|
public void InitSpawnDebugInfo()
|
||||||
{
|
{
|
||||||
@@ -251,6 +260,25 @@ namespace YooAsset
|
|||||||
float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
|
float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
|
||||||
return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
|
return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
protected void DebugRecording()
|
||||||
|
{
|
||||||
|
if (_isRecording == false)
|
||||||
|
{
|
||||||
|
_isRecording = true;
|
||||||
|
_watch = Stopwatch.StartNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_watch != null)
|
||||||
|
{
|
||||||
|
if (IsDone)
|
||||||
|
{
|
||||||
|
LoadingTime = _watch.ElapsedMilliseconds;
|
||||||
|
_watch = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ namespace YooAsset
|
|||||||
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||||
private EPlayMode _playMode;
|
private EPlayMode _playMode;
|
||||||
private IBundleServices _bundleServices;
|
private IBundleServices _bundleServices;
|
||||||
private ILocationServices _locationServices;
|
|
||||||
private AssetSystemImpl _assetSystemImpl;
|
private AssetSystemImpl _assetSystemImpl;
|
||||||
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||||
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||||
@@ -33,7 +32,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal AssetsPackage()
|
private AssetsPackage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal AssetsPackage(string packageName)
|
internal AssetsPackage(string packageName)
|
||||||
@@ -62,7 +61,6 @@ namespace YooAsset
|
|||||||
_initializeStatus = EOperationStatus.None;
|
_initializeStatus = EOperationStatus.None;
|
||||||
|
|
||||||
_bundleServices = null;
|
_bundleServices = null;
|
||||||
_locationServices = null;
|
|
||||||
_editorSimulateModeImpl = null;
|
_editorSimulateModeImpl = null;
|
||||||
_offlinePlayModeImpl = null;
|
_offlinePlayModeImpl = null;
|
||||||
_hostPlayModeImpl = null;
|
_hostPlayModeImpl = null;
|
||||||
@@ -72,8 +70,6 @@ namespace YooAsset
|
|||||||
_assetSystemImpl.DestroyAll();
|
_assetSystemImpl.DestroyAll();
|
||||||
_assetSystemImpl = null;
|
_assetSystemImpl = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log("YooAssets destroy all !");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +83,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
InitializationOperation initializeOperation;
|
InitializationOperation initializeOperation;
|
||||||
_locationServices = parameters.LocationServices;
|
|
||||||
_assetSystemImpl = new AssetSystemImpl();
|
_assetSystemImpl = new AssetSystemImpl();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
@@ -119,7 +114,8 @@ namespace YooAsset
|
|||||||
initializeParameters.LocationToLower,
|
initializeParameters.LocationToLower,
|
||||||
initializeParameters.DefaultHostServer,
|
initializeParameters.DefaultHostServer,
|
||||||
initializeParameters.FallbackHostServer,
|
initializeParameters.FallbackHostServer,
|
||||||
initializeParameters.QueryServices);
|
initializeParameters.QueryServices,
|
||||||
|
PackageName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -127,6 +123,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 监听初始化结果
|
// 监听初始化结果
|
||||||
|
_isInitialize = true;
|
||||||
initializeOperation.Completed += InitializeOperation_Completed;
|
initializeOperation.Completed += InitializeOperation_Completed;
|
||||||
return initializeOperation;
|
return initializeOperation;
|
||||||
}
|
}
|
||||||
@@ -143,14 +140,11 @@ namespace YooAsset
|
|||||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (parameters.LocationServices == null)
|
|
||||||
throw new Exception($"{nameof(ILocationServices)} is null.");
|
|
||||||
|
|
||||||
if (parameters is EditorSimulateModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
{
|
{
|
||||||
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||||
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
|
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
|
||||||
throw new Exception($"${editorSimulateModeParameters.SimulatePatchManifestPath} is null or empty.");
|
throw new Exception($"{nameof(editorSimulateModeParameters.SimulatePatchManifestPath)} is null or empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters is HostPlayModeParameters)
|
if (parameters is HostPlayModeParameters)
|
||||||
@@ -188,7 +182,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求静态资源版本
|
/// 向网络端请求最新的资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||||
@@ -219,9 +213,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新补丁清单
|
/// 向网络端请求并更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageCRC">更新的资源包裹版本</param>
|
/// <param name="packageVersion">更新的包裹版本</param>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
public UpdateManifestOperation UpdateManifestAsync(string packageCRC, int timeout = 60)
|
public UpdateManifestOperation UpdateManifestAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
DebugCheckUpdateManifest();
|
DebugCheckUpdateManifest();
|
||||||
@@ -239,7 +233,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageCRC, timeout);
|
return _hostPlayModeImpl.UpdatePatchManifestAsync(PackageName, packageVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -248,28 +242,26 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 弱联网情况下加载补丁清单
|
/// 检查本地包裹内容的完整性
|
||||||
/// 注意:当指定版本内容验证失败后会返回失败。
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageCRC">指定的资源包裹版本</param>
|
public CheckPackageContentsOperation CheckPackageContentsAsync()
|
||||||
public UpdateManifestOperation WeaklyUpdateManifestAsync(string packageCRC)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorPlayModeUpdateManifestOperation();
|
var operation = new EditorSimulateModeCheckPackageContentsOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
var operation = new OfflinePlayModeUpdateManifestOperation();
|
var operation = new OfflinePlayModeCheckPackageContentsOperation();
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.WeaklyUpdatePatchManifestAsync(PackageName, packageCRC);
|
return _hostPlayModeImpl.CheckPackageContentsAsync(PackageName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -278,22 +270,22 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取人类可读的版本信息
|
/// 获取包裹的版本信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetHumanReadableVersion()
|
public string GetPackageVersion()
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
return _editorSimulateModeImpl.GetHumanReadableVersion();
|
return _editorSimulateModeImpl.GetPackageVersion();
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
{
|
{
|
||||||
return _offlinePlayModeImpl.GetHumanReadableVersion();
|
return _offlinePlayModeImpl.GetPackageVersion();
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.GetHumanReadableVersion();
|
return _hostPlayModeImpl.GetPackageVersion();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -306,11 +298,9 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UnloadUnusedAssets()
|
public void UnloadUnusedAssets()
|
||||||
{
|
{
|
||||||
if (_isInitialize)
|
DebugCheckInitialize();
|
||||||
{
|
_assetSystemImpl.Update();
|
||||||
_assetSystemImpl.Update();
|
_assetSystemImpl.UnloadUnusedAssets();
|
||||||
_assetSystemImpl.UnloadUnusedAssets();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -318,10 +308,8 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ForceUnloadAllAssets()
|
public void ForceUnloadAllAssets()
|
||||||
{
|
{
|
||||||
if (_isInitialize)
|
DebugCheckInitialize();
|
||||||
{
|
_assetSystemImpl.ForceUnloadAllAssets();
|
||||||
_assetSystemImpl.ForceUnloadAllAssets();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -335,7 +323,10 @@ namespace YooAsset
|
|||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
@@ -397,14 +388,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源路径
|
/// 检查资源定位地址是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
public bool CheckLocationValid(string location)
|
||||||
public string GetAssetPath(string location)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return _locationServices.ConvertLocationToAssetPath(this, location);
|
string assetPath = _bundleServices.TryMappingToAssetPath(location);
|
||||||
|
return string.IsNullOrEmpty(assetPath) == false;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -429,8 +420,6 @@ namespace YooAsset
|
|||||||
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return GetRawFileInternal(assetInfo, copyPath);
|
return GetRawFileInternal(assetInfo, copyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,6 +428,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
|
YooLogger.Error($"Failed to get raw file. {assetInfo.Error}");
|
||||||
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
||||||
OperationSystem.StartOperation(operation);
|
OperationSystem.StartOperation(operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -508,8 +498,6 @@ namespace YooAsset
|
|||||||
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
@@ -523,8 +511,6 @@ namespace YooAsset
|
|||||||
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,8 +546,6 @@ namespace YooAsset
|
|||||||
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,14 +577,17 @@ namespace YooAsset
|
|||||||
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
if (assetInfo.IsInvalid == false)
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
|
||||||
{
|
{
|
||||||
string error = $"Cannot load raw file using LoadAsset method !";
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
YooLogger.Error(error);
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
{
|
||||||
completedProvider.SetCompleted(error);
|
string error = $"Cannot load raw file using LoadAsset method !";
|
||||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
YooLogger.Error(error);
|
||||||
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
|
completedProvider.SetCompleted(error);
|
||||||
|
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -619,8 +606,6 @@ namespace YooAsset
|
|||||||
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,8 +641,6 @@ namespace YooAsset
|
|||||||
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (assetInfo.IsInvalid)
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -689,14 +672,17 @@ namespace YooAsset
|
|||||||
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
if (assetInfo.IsInvalid == false)
|
||||||
if (bundleInfo.Bundle.IsRawFile)
|
|
||||||
{
|
{
|
||||||
string error = $"Cannot load raw file using LoadSubAssets method !";
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
YooLogger.Error(error);
|
if (bundleInfo.Bundle.IsRawFile)
|
||||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
{
|
||||||
completedProvider.SetCompleted(error);
|
string error = $"Cannot load raw file using LoadSubAssets method !";
|
||||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
YooLogger.Error(error);
|
||||||
|
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||||
|
completedProvider.SetCompleted(error);
|
||||||
|
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -911,9 +897,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
|
/// 创建资源包裹下载器,用于下载更新指定资源版本所有的资源包文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageCRC">指定更新的资源包裹版本</param>
|
/// <param name="packageVersion">指定更新的包裹版本</param>
|
||||||
/// <param name="timeout">超时时间</param>
|
/// <param name="timeout">超时时间</param>
|
||||||
public UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60)
|
public UpdatePackageOperation UpdatePackageAsync(string packageVersion, int timeout = 60)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
@@ -930,7 +916,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageCRC, timeout);
|
return _hostPlayModeImpl.UpdatePackageAsync(PackageName, packageVersion, timeout);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -940,14 +926,6 @@ namespace YooAsset
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
/// <summary>
|
|
||||||
/// 资源定位地址转换为资源完整路径
|
|
||||||
/// </summary>
|
|
||||||
internal string MappingToAssetPath(string location)
|
|
||||||
{
|
|
||||||
return _bundleServices.MappingToAssetPath(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含资源文件
|
/// 是否包含资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -965,9 +943,9 @@ namespace YooAsset
|
|||||||
private void DebugCheckInitialize()
|
private void DebugCheckInitialize()
|
||||||
{
|
{
|
||||||
if (_initializeStatus == EOperationStatus.None)
|
if (_initializeStatus == EOperationStatus.None)
|
||||||
throw new Exception("YooAssets initialize not completed !");
|
throw new Exception("Package initialize not completed !");
|
||||||
else if (_initializeStatus == EOperationStatus.Failed)
|
else if (_initializeStatus == EOperationStatus.Failed)
|
||||||
throw new Exception($"YooAssets initialize failed : {_initializeError}");
|
throw new Exception($"Package initialize failed ! {_initializeError}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Conditional("DEBUG")]
|
[Conditional("DEBUG")]
|
||||||
@@ -1000,9 +978,12 @@ namespace YooAsset
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 调试信息
|
#region 调试信息
|
||||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
internal DebugPackageData GetDebugPackageData()
|
||||||
{
|
{
|
||||||
return _assetSystemImpl.GetDebugReportInfos();
|
DebugPackageData data = new DebugPackageData();
|
||||||
|
data.PackageName = PackageName;
|
||||||
|
data.ProviderInfos = _assetSystemImpl.GetDebugReportInfos();
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1014,7 +995,7 @@ namespace YooAsset
|
|||||||
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||||
{
|
{
|
||||||
DebugCheckLocation(location);
|
DebugCheckLocation(location);
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(this, location);
|
string assetPath = _bundleServices.MappingToAssetPath(location);
|
||||||
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
|
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
|
||||||
if (patchAsset != null)
|
if (patchAsset != null)
|
||||||
{
|
{
|
||||||
@@ -1028,7 +1009,6 @@ namespace YooAsset
|
|||||||
error = $"The location is null or empty !";
|
error = $"The location is null or empty !";
|
||||||
else
|
else
|
||||||
error = $"The location is invalid : {location}";
|
error = $"The location is invalid : {location}";
|
||||||
YooLogger.Error(error);
|
|
||||||
AssetInfo assetInfo = new AssetInfo(error);
|
AssetInfo assetInfo = new AssetInfo(error);
|
||||||
return assetInfo;
|
return assetInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载文件校验结果
|
/// 下载文件校验结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EVerifyResult
|
internal enum EVerifyResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件不存在
|
/// 文件不存在
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
internal class DebugBundleInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名称
|
|
||||||
/// </summary>
|
|
||||||
public string BundleName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 引用计数
|
|
||||||
/// </summary>
|
|
||||||
public int RefCount;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载状态
|
|
||||||
/// </summary>
|
|
||||||
public int Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
39
Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs
Normal file
39
Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public string BundleName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 引用计数
|
||||||
|
/// </summary>
|
||||||
|
public int RefCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载状态
|
||||||
|
/// </summary>
|
||||||
|
public int Status;
|
||||||
|
|
||||||
|
public int CompareTo(DebugBundleInfo other)
|
||||||
|
{
|
||||||
|
return Compare(this, other);
|
||||||
|
}
|
||||||
|
public int Compare(DebugBundleInfo a, DebugBundleInfo b)
|
||||||
|
{
|
||||||
|
return string.CompareOrdinal(a.BundleName, b.BundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs
Normal file
21
Assets/YooAsset/Runtime/DiagnosticSystem/DebugPackageData.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
internal class DebugPackageData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹名称
|
||||||
|
/// </summary>
|
||||||
|
public string PackageName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 调试数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 583d0c3e5520c6748b2aeacd209cf8b6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -8,9 +8,9 @@ namespace YooAsset
|
|||||||
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
|
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属的资源包裹
|
/// 包裹名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName;
|
public string PackageName { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象路径
|
/// 资源对象路径
|
||||||
@@ -27,6 +27,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string SpawnTime;
|
public string SpawnTime;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载耗时(单位:毫秒)
|
||||||
|
/// </summary>
|
||||||
|
public long LoadingTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -12,17 +12,21 @@ namespace YooAsset
|
|||||||
[Serializable]
|
[Serializable]
|
||||||
internal class DebugReport
|
internal class DebugReport
|
||||||
{
|
{
|
||||||
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏帧
|
/// 游戏帧
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int FrameCount;
|
public int FrameCount;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 调试的包裹数据列表
|
||||||
|
/// </summary>
|
||||||
|
public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化
|
/// 序列化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static byte[] Serialize(DebugReport debugReport)
|
public static byte[] Serialize(DebugReport debugReport)
|
||||||
{
|
{
|
||||||
return Encoding.UTF8.GetBytes(JsonUtility.ToJson(debugReport));
|
return Encoding.UTF8.GetBytes(JsonUtility.ToJson(debugReport));
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -15,11 +16,22 @@ namespace YooAsset
|
|||||||
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
||||||
private static readonly List<string> _removeList = new List<string>(100);
|
private static readonly List<string> _removeList = new List<string>(100);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传的文件大小
|
/// 自定义的证书认证实例
|
||||||
|
/// </summary>
|
||||||
|
public static CertificateHandler CertificateHandlerInstance;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用断点续传功能文件的最小字节数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
|
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下载失败后清理文件的HTTP错误码
|
||||||
|
/// </summary>
|
||||||
|
public static List<long> ClearFileResponseCodes { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新所有下载器
|
/// 更新所有下载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace YooAsset
|
|||||||
protected string _requestURL;
|
protected string _requestURL;
|
||||||
|
|
||||||
protected string _lastError = string.Empty;
|
protected string _lastError = string.Empty;
|
||||||
|
protected long _lastCode = 0;
|
||||||
protected float _downloadProgress = 0f;
|
protected float _downloadProgress = 0f;
|
||||||
protected ulong _downloadedBytes = 0;
|
protected ulong _downloadedBytes = 0;
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetLastError()
|
public string GetLastError()
|
||||||
{
|
{
|
||||||
return $"Failed to download : {_requestURL} Error : {_lastError}";
|
return $"Failed to download : {_requestURL} Error : {_lastError} Code : {_lastCode}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,12 @@ namespace YooAsset
|
|||||||
_downloadHandle = handler;
|
_downloadHandle = handler;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (DownloadSystem.CertificateHandlerInstance != null)
|
||||||
|
{
|
||||||
|
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
|
||||||
|
_webRequest.disposeCertificateHandlerOnDispose = false;
|
||||||
|
}
|
||||||
|
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
if (fileLength > 0)
|
if (fileLength > 0)
|
||||||
@@ -128,12 +134,14 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
_lastError = _webRequest.error;
|
_lastError = _webRequest.error;
|
||||||
|
_lastCode = _webRequest.responseCode;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
_lastError = _webRequest.error;
|
_lastError = _webRequest.error;
|
||||||
|
_lastCode = _webRequest.responseCode;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -145,6 +153,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
_lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}";
|
_lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}";
|
||||||
|
_lastCode = _webRequest.responseCode;
|
||||||
|
|
||||||
// 验证失败后删除文件
|
// 验证失败后删除文件
|
||||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||||
@@ -156,13 +165,26 @@ namespace YooAsset
|
|||||||
// 如果下载失败
|
// 如果下载失败
|
||||||
if (hasError)
|
if (hasError)
|
||||||
{
|
{
|
||||||
// 注意:非断点续传下载失败后删除文件
|
// 注意:非断点续传下载失败之后删除文件
|
||||||
if (_breakResume == false)
|
if (_breakResume == false)
|
||||||
{
|
{
|
||||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||||
if (File.Exists(cacheFilePath))
|
if (File.Exists(cacheFilePath))
|
||||||
File.Delete(cacheFilePath);
|
File.Delete(cacheFilePath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 注意:下载断点续传文件发生特殊错误码之后删除文件
|
||||||
|
if (DownloadSystem.ClearFileResponseCodes != null)
|
||||||
|
{
|
||||||
|
if (DownloadSystem.ClearFileResponseCodes.Contains(_webRequest.responseCode))
|
||||||
|
{
|
||||||
|
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||||
|
if (File.Exists(cacheFilePath))
|
||||||
|
File.Delete(cacheFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 失败后重新尝试
|
// 失败后重新尝试
|
||||||
if (_failedTryAgain > 0)
|
if (_failedTryAgain > 0)
|
||||||
@@ -179,6 +201,7 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_lastError = string.Empty;
|
_lastError = string.Empty;
|
||||||
|
_lastCode = 0;
|
||||||
_steps = ESteps.Succeed;
|
_steps = ESteps.Succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +227,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Failed;
|
||||||
_lastError = "user abort";
|
_lastError = "user abort";
|
||||||
|
_lastCode = 0;
|
||||||
DisposeWebRequest();
|
DisposeWebRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LocationToLower = false;
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源定位服务接口
|
|
||||||
/// </summary>
|
|
||||||
public ILocationServices LocationServices = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件解密服务接口
|
/// 文件解密服务接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 检查本地包裹内容的完整性
|
||||||
|
/// </summary>
|
||||||
|
public abstract class CheckPackageContentsOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class EditorSimulateModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||||
|
{
|
||||||
|
internal EditorSimulateModeCheckPackageContentsOperation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal sealed class OfflinePlayModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||||
|
{
|
||||||
|
internal OfflinePlayModeCheckPackageContentsOperation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal sealed class HostPlayModeCheckPackageContentsOperation : CheckPackageContentsOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
CheckLoadedManifest,
|
||||||
|
InitVerifyingCache,
|
||||||
|
UpdateVerifyingCache,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly string _packageName;
|
||||||
|
private readonly CacheVerifier _cacheVerifier;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private float _verifyTime;
|
||||||
|
|
||||||
|
internal HostPlayModeCheckPackageContentsOperation(HostPlayModeImpl impl, string packageName)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
_packageName = packageName;
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
_cacheVerifier = new CacheVerifierWithoutThread();
|
||||||
|
#else
|
||||||
|
_cacheVerifier = new CacheVerifierWithThread();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckLoadedManifest;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckLoadedManifest)
|
||||||
|
{
|
||||||
|
if (_impl.LocalPatchManifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Not found loaded package : {_packageName}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.InitVerifyingCache;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
|
{
|
||||||
|
var verifyInfos = _impl.GetVerifyInfoList(true);
|
||||||
|
_cacheVerifier.InitVerifier(verifyInfos);
|
||||||
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
|
{
|
||||||
|
Progress = _cacheVerifier.GetVerifierProgress();
|
||||||
|
if (_cacheVerifier.UpdateVerifier())
|
||||||
|
{
|
||||||
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||||
|
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||||
|
|
||||||
|
bool verifySucceed = true;
|
||||||
|
foreach (var verifyInfo in _cacheVerifier.VerifyFailList)
|
||||||
|
{
|
||||||
|
// 注意:跳过内置资源文件
|
||||||
|
if (verifyInfo.IsBuildinFile)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
verifySucceed = false;
|
||||||
|
YooLogger.Warning($"Failed verify file : {verifyInfo.VerifyFilePath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verifySucceed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"The package resource {_packageName} content has verify failed file !";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d400b2548d79ca42bec7370f5d66b78
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -57,7 +57,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
catch (System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Failed delete cache file : {filePath} Exception : {e}");
|
YooLogger.Warning($"Failed delete cache file : {filePath} ! {e.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_unusedCacheFilePaths.RemoveAt(i);
|
_unusedCacheFilePaths.RemoveAt(i);
|
||||||
@@ -84,7 +84,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetUnusedCacheFilePaths()
|
private List<string> GetUnusedCacheFilePaths()
|
||||||
{
|
{
|
||||||
string cacheFolderPath = SandboxHelper.GetCacheFolderPath();
|
string cacheFolderPath = PersistentHelper.GetCacheFolderPath();
|
||||||
if (Directory.Exists(cacheFolderPath) == false)
|
if (Directory.Exists(cacheFolderPath) == false)
|
||||||
return new List<string>();
|
return new List<string>();
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InitializationOperation : AsyncOperationBase
|
public abstract class InitializationOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化内部加载的包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string InitializedPackageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -25,7 +29,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly EditorSimulateModeImpl _impl;
|
private readonly EditorSimulateModeImpl _impl;
|
||||||
private string _simulatePatchManifestPath;
|
private readonly string _simulatePatchManifestPath;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
||||||
@@ -45,16 +49,26 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Manifest file not found : {_simulatePatchManifestPath}";
|
Error = $"Not found simulation manifest file : {_simulatePatchManifestPath}";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Load manifest file : {_simulatePatchManifestPath}");
|
try
|
||||||
string jsonContent = FileUtility.ReadFile(_simulatePatchManifestPath);
|
{
|
||||||
var simulatePatchManifest = PatchManifest.Deserialize(jsonContent);
|
YooLogger.Log($"Load simulation manifest file : {_simulatePatchManifestPath}");
|
||||||
_impl.SetSimulatePatchManifest(simulatePatchManifest);
|
string jsonContent = FileUtility.ReadFile(_simulatePatchManifestPath);
|
||||||
_steps = ESteps.Done;
|
var manifest = PatchManifest.Deserialize(jsonContent);
|
||||||
Status = EOperationStatus.Succeed;
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
|
_impl.SetSimulatePatchManifest(manifest);
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = e.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,6 +81,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
QueryAppPackageVersion,
|
||||||
LoadAppManifest,
|
LoadAppManifest,
|
||||||
InitVerifyingCache,
|
InitVerifyingCache,
|
||||||
UpdateVerifyingCache,
|
UpdateVerifyingCache,
|
||||||
@@ -74,39 +89,63 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly OfflinePlayModeImpl _impl;
|
private readonly OfflinePlayModeImpl _impl;
|
||||||
private readonly AppManifestLoader _appManifestLoader;
|
private readonly string _packageName;
|
||||||
private readonly CacheVerifier _patchCacheVerifier;
|
private readonly CacheVerifier _cacheVerifier;
|
||||||
|
private readonly AppPackageVersionQuerier _appPackageVersionQuerier;
|
||||||
|
private AppManifestLoader _appManifestLoader;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, string buildinPackageName)
|
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, string packageName)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_appManifestLoader = new AppManifestLoader(buildinPackageName);
|
_packageName = packageName;
|
||||||
|
_appPackageVersionQuerier = new AppPackageVersionQuerier(packageName);
|
||||||
|
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
_patchCacheVerifier = new CacheVerifierWithoutThread();
|
_cacheVerifier = new CacheVerifierWithoutThread();
|
||||||
#else
|
#else
|
||||||
_patchCacheVerifier = new CacheVerifierWithThread();
|
_cacheVerifier = new CacheVerifierWithThread();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadAppManifest;
|
_steps = ESteps.QueryAppPackageVersion;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.QueryAppPackageVersion)
|
||||||
|
{
|
||||||
|
_appPackageVersionQuerier.Update();
|
||||||
|
if (_appPackageVersionQuerier.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string error = _appPackageVersionQuerier.Error;
|
||||||
|
if (string.IsNullOrEmpty(error) == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_appManifestLoader = new AppManifestLoader(_packageName, _appPackageVersionQuerier.Version);
|
||||||
|
_steps = ESteps.LoadAppManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadAppManifest)
|
if (_steps == ESteps.LoadAppManifest)
|
||||||
{
|
{
|
||||||
_appManifestLoader.Update();
|
_appManifestLoader.Update();
|
||||||
Progress = _appManifestLoader.Progress();
|
Progress = _appManifestLoader.Progress;
|
||||||
if (_appManifestLoader.IsDone() == false)
|
if (_appManifestLoader.IsDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_appManifestLoader.Result == null)
|
var manifest = _appManifestLoader.Manifest;
|
||||||
|
if (manifest == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
@@ -114,28 +153,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
|
_impl.SetAppPatchManifest(manifest);
|
||||||
_steps = ESteps.InitVerifyingCache;
|
_steps = ESteps.InitVerifyingCache;
|
||||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitVerifyingCache)
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
{
|
{
|
||||||
var verifyInfos = _impl.GetVerifyInfoList();
|
var verifyInfos = _impl.GetVerifyInfoList();
|
||||||
_patchCacheVerifier.InitVerifier(verifyInfos);
|
_cacheVerifier.InitVerifier(verifyInfos);
|
||||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
_steps = ESteps.UpdateVerifyingCache;
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.UpdateVerifyingCache)
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
{
|
{
|
||||||
Progress = _patchCacheVerifier.GetVerifierProgress();
|
Progress = _cacheVerifier.GetVerifierProgress();
|
||||||
if (_patchCacheVerifier.UpdateVerifier())
|
if (_cacheVerifier.UpdateVerifier())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||||
YooLogger.Log($"Verify result : Success {_patchCacheVerifier.VerifySuccessList.Count}, Fail {_patchCacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,22 +183,246 @@ namespace YooAsset
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机运行模式的初始化操作
|
/// 联机运行模式的初始化操作
|
||||||
|
/// 注意:优先从沙盒里加载清单,如果沙盒里不存在就尝试把内置清单拷贝到沙盒并加载该清单。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
internal HostPlayModeInitializationOperation()
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
None,
|
||||||
|
TryLoadCacheManifest,
|
||||||
|
QueryAppPackageVersion,
|
||||||
|
CopyAppManifest,
|
||||||
|
LoadAppManifest,
|
||||||
|
InitVerifyingCache,
|
||||||
|
UpdateVerifyingCache,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly string _packageName;
|
||||||
|
private readonly CacheVerifier _cacheVerifier;
|
||||||
|
private readonly AppPackageVersionQuerier _appPackageVersionQuerier;
|
||||||
|
private AppManifestCopyer _appManifestCopyer;
|
||||||
|
private AppManifestLoader _appManifestLoader;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private float _verifyTime;
|
||||||
|
|
||||||
|
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, string packageName)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
_packageName = packageName;
|
||||||
|
_appPackageVersionQuerier = new AppPackageVersionQuerier(packageName);
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
_cacheVerifier = new CacheVerifierWithoutThread();
|
||||||
|
#else
|
||||||
|
_cacheVerifier = new CacheVerifierWithThread();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
Status = EOperationStatus.Succeed;
|
_steps = ESteps.TryLoadCacheManifest;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.TryLoadCacheManifest)
|
||||||
|
{
|
||||||
|
if (PersistentHelper.CheckCacheManifestFileExists(_packageName))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var manifest = PersistentHelper.LoadCacheManifestFile(_packageName);
|
||||||
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
|
_impl.SetLocalPatchManifest(manifest);
|
||||||
|
_steps = ESteps.InitVerifyingCache;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,我们主动把损坏的文件删除。
|
||||||
|
YooLogger.Warning($"Failed to load cache manifest file : {e.Message}");
|
||||||
|
PersistentHelper.DeleteCacheManifestFile(_packageName);
|
||||||
|
_steps = ESteps.QueryAppPackageVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.QueryAppPackageVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.QueryAppPackageVersion)
|
||||||
|
{
|
||||||
|
_appPackageVersionQuerier.Update();
|
||||||
|
if (_appPackageVersionQuerier.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 注意:为了兼容MOD模式,初始化动态新增的包裹的时候,如果内置清单不存在也不需要报错!
|
||||||
|
string error = _appPackageVersionQuerier.Error;
|
||||||
|
if (string.IsNullOrEmpty(error) == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
YooLogger.Log($"Failed to load buildin package version file : {error}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_appManifestCopyer = new AppManifestCopyer(_packageName, _appPackageVersionQuerier.Version);
|
||||||
|
_appManifestLoader = new AppManifestLoader(_packageName, _appPackageVersionQuerier.Version);
|
||||||
|
_steps = ESteps.CopyAppManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyAppManifest)
|
||||||
|
{
|
||||||
|
_appManifestCopyer.Update();
|
||||||
|
Progress = _appManifestCopyer.Progress;
|
||||||
|
if (_appManifestCopyer.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string error = _appManifestCopyer.Error;
|
||||||
|
if (string.IsNullOrEmpty(error) == false)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadAppManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadAppManifest)
|
||||||
|
{
|
||||||
|
_appManifestLoader.Update();
|
||||||
|
Progress = _appManifestLoader.Progress;
|
||||||
|
if (_appManifestLoader.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var manifest = _appManifestLoader.Manifest;
|
||||||
|
if (manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _appManifestLoader.Error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InitializedPackageVersion = manifest.PackageVersion;
|
||||||
|
_impl.SetLocalPatchManifest(manifest);
|
||||||
|
_steps = ESteps.InitVerifyingCache;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
|
{
|
||||||
|
var verifyInfos = _impl.GetVerifyInfoList(false);
|
||||||
|
_cacheVerifier.InitVerifier(verifyInfos);
|
||||||
|
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||||
|
_steps = ESteps.UpdateVerifyingCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UpdateVerifyingCache)
|
||||||
|
{
|
||||||
|
Progress = _cacheVerifier.GetVerifierProgress();
|
||||||
|
if (_cacheVerifier.UpdateVerifier())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||||
|
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置补丁清单版本查询器
|
||||||
|
/// </summary>
|
||||||
|
internal class AppPackageVersionQuerier
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
LoadStaticVersion,
|
||||||
|
CheckStaticVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly string _buildinPackageName;
|
||||||
|
private ESteps _steps = ESteps.LoadStaticVersion;
|
||||||
|
private UnityWebDataRequester _downloader;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string Version { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志
|
||||||
|
/// </summary>
|
||||||
|
public string Error { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已经完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDone
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _steps == ESteps.Done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AppPackageVersionQuerier(string buildinPackageName)
|
||||||
|
{
|
||||||
|
_buildinPackageName = buildinPackageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新流程
|
||||||
|
/// </summary>
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (IsDone)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadStaticVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_buildinPackageName);
|
||||||
|
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||||
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
|
_downloader = new UnityWebDataRequester();
|
||||||
|
_downloader.SendRequest(url);
|
||||||
|
_steps = ESteps.CheckStaticVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckStaticVersion)
|
||||||
|
{
|
||||||
|
if (_downloader.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader.HasError())
|
||||||
|
{
|
||||||
|
Error = _downloader.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Version = _downloader.GetText();
|
||||||
|
if (string.IsNullOrEmpty(Version))
|
||||||
|
Error = $"Buildin package version file content is empty !";
|
||||||
|
}
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
_downloader.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置补丁清单加载器
|
/// 内置补丁清单加载器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -166,55 +430,55 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
LoadStaticVersion,
|
|
||||||
CheckStaticVersion,
|
|
||||||
LoadAppManifest,
|
LoadAppManifest,
|
||||||
CheckAppManifest,
|
CheckAppManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _buildinPackageName;
|
private readonly string _buildinPackageName;
|
||||||
private ESteps _steps = ESteps.LoadStaticVersion;
|
private readonly string _buildinPackageVersion;
|
||||||
private UnityWebDataRequester _downloader1;
|
private ESteps _steps = ESteps.LoadAppManifest;
|
||||||
private UnityWebDataRequester _downloader2;
|
private UnityWebDataRequester _downloader;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载结果
|
||||||
|
/// </summary>
|
||||||
|
public PatchManifest Manifest { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误日志
|
/// 错误日志
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Error { private set; get; }
|
public string Error { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载结果
|
|
||||||
/// </summary>
|
|
||||||
public PatchManifest Result { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置补丁清单CRC
|
|
||||||
/// </summary>
|
|
||||||
public string BuildinPackageCRC { private set; get; }
|
|
||||||
|
|
||||||
|
|
||||||
public AppManifestLoader(string buildinPackageName)
|
|
||||||
{
|
|
||||||
_buildinPackageName = buildinPackageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否已经完成
|
/// 是否已经完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDone()
|
public bool IsDone
|
||||||
{
|
{
|
||||||
return _steps == ESteps.Done;
|
get
|
||||||
|
{
|
||||||
|
return _steps == ESteps.Done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载进度
|
/// 加载进度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Progress()
|
public float Progress
|
||||||
{
|
{
|
||||||
if (_downloader2 == null)
|
get
|
||||||
return 0;
|
{
|
||||||
return _downloader2.Progress();
|
if (_downloader == null)
|
||||||
|
return 0;
|
||||||
|
return _downloader.Progress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AppManifestLoader(string buildinPackageName, string buildinPackageVersion)
|
||||||
|
{
|
||||||
|
_buildinPackageName = buildinPackageName;
|
||||||
|
_buildinPackageVersion = buildinPackageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -222,66 +486,42 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (IsDone())
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.LoadStaticVersion)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetStaticVersionFileName(_buildinPackageName);
|
|
||||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
|
||||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
|
||||||
_downloader1 = new UnityWebDataRequester();
|
|
||||||
_downloader1.SendRequest(url);
|
|
||||||
_steps = ESteps.CheckStaticVersion;
|
|
||||||
YooLogger.Log($"Load static version file : {filePath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.CheckStaticVersion)
|
|
||||||
{
|
|
||||||
if (_downloader1.IsDone() == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_downloader1.HasError())
|
|
||||||
{
|
|
||||||
Error = _downloader1.GetError();
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BuildinPackageCRC = _downloader1.GetText();
|
|
||||||
_steps = ESteps.LoadAppManifest;
|
|
||||||
}
|
|
||||||
_downloader1.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadAppManifest)
|
if (_steps == ESteps.LoadAppManifest)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, BuildinPackageCRC);
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion);
|
||||||
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||||
string url = PathHelper.ConvertToWWWPath(filePath);
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
_downloader2 = new UnityWebDataRequester();
|
_downloader = new UnityWebDataRequester();
|
||||||
_downloader2.SendRequest(url);
|
_downloader.SendRequest(url);
|
||||||
_steps = ESteps.CheckAppManifest;
|
_steps = ESteps.CheckAppManifest;
|
||||||
YooLogger.Log($"Load patch manifest file : {filePath}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckAppManifest)
|
if (_steps == ESteps.CheckAppManifest)
|
||||||
{
|
{
|
||||||
if (_downloader2.IsDone() == false)
|
if (_downloader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloader2.HasError())
|
if (_downloader.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloader2.GetError();
|
Error = _downloader.GetError();
|
||||||
_steps = ESteps.Done;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 解析APP里的补丁清单
|
// 解析APP里的补丁清单
|
||||||
Result = PatchManifest.Deserialize(_downloader2.GetText());
|
try
|
||||||
_steps = ESteps.Done;
|
{
|
||||||
|
Manifest = PatchManifest.Deserialize(_downloader.GetText());
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Error = e.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_downloader2.Dispose();
|
_steps = ESteps.Done;
|
||||||
|
_downloader.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,10 +538,10 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _buildinPackageName;
|
private readonly string _buildinPackageName;
|
||||||
private string _buildinPackageCRC;
|
private readonly string _buildinPackageVersion;
|
||||||
private ESteps _steps = ESteps.CopyAppManifest;
|
private ESteps _steps = ESteps.CopyAppManifest;
|
||||||
private UnityWebFileRequester _downloader1;
|
private UnityWebFileRequester _downloader;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 错误日志
|
/// 错误日志
|
||||||
@@ -309,15 +549,34 @@ namespace YooAsset
|
|||||||
public string Error { private set; get; }
|
public string Error { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝结果
|
/// 是否已经完成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Result { private set; get; }
|
public bool IsDone
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _steps == ESteps.Done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载进度
|
||||||
|
/// </summary>
|
||||||
|
public float Progress
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_downloader == null)
|
||||||
|
return 0;
|
||||||
|
return _downloader.Progress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public AppManifestCopyer(string buildinPackageName, string buildinPackageCRC)
|
public AppManifestCopyer(string buildinPackageName, string buildinPackageVersion)
|
||||||
{
|
{
|
||||||
_buildinPackageName = buildinPackageName;
|
_buildinPackageName = buildinPackageName;
|
||||||
_buildinPackageCRC = buildinPackageCRC;
|
_buildinPackageVersion = buildinPackageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -325,56 +584,32 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (IsDone())
|
if (IsDone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.CopyAppManifest)
|
if (_steps == ESteps.CopyAppManifest)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageCRC);
|
string savePath = PersistentHelper.GetCacheManifestFilePath(_buildinPackageName);
|
||||||
string destFilePath = PathHelper.MakePersistentLoadPath(fileName);
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_buildinPackageName, _buildinPackageVersion);
|
||||||
if (File.Exists(destFilePath))
|
string filePath = PathHelper.MakeStreamingLoadPath(fileName);
|
||||||
{
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
Result = true;
|
_downloader = new UnityWebFileRequester();
|
||||||
_steps = ESteps.Done;
|
_downloader.SendRequest(url, savePath);
|
||||||
return;
|
_steps = ESteps.CheckAppManifest;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Log($"Copy application patch manifest.");
|
|
||||||
string sourceFilePath = PathHelper.MakeStreamingLoadPath(fileName);
|
|
||||||
string url = PathHelper.ConvertToWWWPath(sourceFilePath);
|
|
||||||
_downloader1 = new UnityWebFileRequester();
|
|
||||||
_downloader1.SendRequest(url, destFilePath);
|
|
||||||
_steps = ESteps.CheckAppManifest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckAppManifest)
|
if (_steps == ESteps.CheckAppManifest)
|
||||||
{
|
{
|
||||||
if (_downloader1.IsDone() == false)
|
if (_downloader.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloader1.HasError())
|
if (_downloader.HasError())
|
||||||
{
|
{
|
||||||
Result = false;
|
Error = _downloader.GetError();
|
||||||
Error = _downloader1.GetError();
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
}
|
}
|
||||||
else
|
_steps = ESteps.Done;
|
||||||
{
|
_downloader.Dispose();
|
||||||
Result = true;
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
}
|
|
||||||
_downloader1.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 是否已经完成
|
|
||||||
/// </summary>
|
|
||||||
public bool IsDone()
|
|
||||||
{
|
|
||||||
return _steps == ESteps.Done;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否发现了新的补丁清单
|
/// 是否发现了新的补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FoundNewManifest { protected set; get; }
|
public bool FoundNewManifest { protected set; get; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -46,13 +46,17 @@ namespace YooAsset
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机模式的更新清单操作
|
/// 联机模式的更新清单操作
|
||||||
|
/// 注意:优先比对沙盒清单哈希值,如果有变化就更新远端清单文件,并保存到本地。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class HostPlayModeUpdateManifestOperation : UpdateManifestOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
CheckManifestHash,
|
TryLoadCacheHash,
|
||||||
|
LoadWebHash,
|
||||||
|
CheckWebHash,
|
||||||
|
LoadCacheManifest,
|
||||||
LoadWebManifest,
|
LoadWebManifest,
|
||||||
CheckWebManifest,
|
CheckWebManifest,
|
||||||
InitVerifyingCache,
|
InitVerifyingCache,
|
||||||
@@ -63,18 +67,21 @@ namespace YooAsset
|
|||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageCRC;
|
private readonly string _packageVersion;
|
||||||
|
private readonly CacheVerifier _cacheVerifier;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader1;
|
||||||
private CacheVerifier _cacheVerifier;
|
private UnityWebDataRequester _downloader2;
|
||||||
|
|
||||||
|
private string _cacheManifestHash;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private float _verifyTime;
|
private float _verifyTime;
|
||||||
|
|
||||||
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout)
|
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_packageCRC = packageCRC;
|
_packageVersion = packageVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
|
|
||||||
#if UNITY_WEBGL
|
#if UNITY_WEBGL
|
||||||
@@ -86,70 +93,121 @@ namespace YooAsset
|
|||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
RequestCount++;
|
RequestCount++;
|
||||||
_steps = ESteps.CheckManifestHash;
|
_steps = ESteps.TryLoadCacheHash;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.CheckManifestHash)
|
if (_steps == ESteps.TryLoadCacheHash)
|
||||||
{
|
{
|
||||||
string cachedManifestCRC = GetSandboxPatchManifestFileHash(_packageName, _packageCRC);
|
string filePath = PersistentHelper.GetCacheManifestFilePath(_packageName);
|
||||||
|
if (File.Exists(filePath))
|
||||||
// 如果补丁清单文件的哈希值相同
|
|
||||||
if (cachedManifestCRC == _packageCRC)
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Patch manifest file hash is not change : {_packageCRC}");
|
_cacheManifestHash = HashUtility.FileMD5(filePath);
|
||||||
LoadSandboxPatchManifest(_packageName, _packageCRC);
|
_steps = ESteps.LoadWebHash;
|
||||||
FoundNewManifest = false;
|
|
||||||
_steps = ESteps.InitVerifyingCache;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Patch manifest hash is change : {cachedManifestCRC} -> {_packageCRC}");
|
_steps = ESteps.LoadWebManifest;
|
||||||
FoundNewManifest = true;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadWebHash)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPatchManifestHashFileName(_packageName, _packageVersion);
|
||||||
|
string webURL = GetPatchManifestRequestURL(fileName);
|
||||||
|
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
||||||
|
_downloader1 = new UnityWebDataRequester();
|
||||||
|
_downloader1.SendRequest(webURL, _timeout);
|
||||||
|
_steps = ESteps.CheckWebHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckWebHash)
|
||||||
|
{
|
||||||
|
if (_downloader1.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader1.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _downloader1.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string webManifestHash = _downloader1.GetText();
|
||||||
|
if (_cacheManifestHash == webManifestHash)
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Not found new package : {_packageName}");
|
||||||
|
_steps = ESteps.LoadCacheManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Package {_packageName} is change : {_cacheManifestHash} -> {webManifestHash}");
|
||||||
|
_steps = ESteps.LoadWebManifest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downloader1.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadCacheManifest)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var manifest = PersistentHelper.LoadCacheManifestFile(_packageName);
|
||||||
|
_impl.SetLocalPatchManifest(manifest);
|
||||||
|
_steps = ESteps.InitVerifyingCache;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
// 注意:如果加载沙盒内的清单报错,为了避免流程被卡住,我们主动把损坏的文件删除。
|
||||||
|
YooLogger.Warning($"Failed to load cache manifest file : {e.Message}");
|
||||||
|
PersistentHelper.DeleteCacheManifestFile(_packageName);
|
||||||
_steps = ESteps.LoadWebManifest;
|
_steps = ESteps.LoadWebManifest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifest)
|
if (_steps == ESteps.LoadWebManifest)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC);
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion);
|
||||||
string webURL = GetPatchManifestRequestURL(fileName);
|
string webURL = GetPatchManifestRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader2 = new UnityWebDataRequester();
|
||||||
_downloader.SendRequest(webURL, _timeout);
|
_downloader2.SendRequest(webURL, _timeout);
|
||||||
_steps = ESteps.CheckWebManifest;
|
_steps = ESteps.CheckWebManifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckWebManifest)
|
if (_steps == ESteps.CheckWebManifest)
|
||||||
{
|
{
|
||||||
if (_downloader.IsDone() == false)
|
if (_downloader2.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check error
|
if (_downloader2.HasError())
|
||||||
if (_downloader.HasError())
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloader.GetError();
|
Error = _downloader2.GetError();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 解析补丁清单
|
try
|
||||||
if (ParseAndSaveRemotePatchManifest(_packageName, _packageCRC, _downloader.GetText()))
|
|
||||||
{
|
{
|
||||||
|
string content = _downloader2.GetText();
|
||||||
|
var manifest = PersistentHelper.SaveCacheManifestFile(_packageName, content);
|
||||||
|
_impl.SetLocalPatchManifest(manifest);
|
||||||
|
FoundNewManifest = true;
|
||||||
_steps = ESteps.InitVerifyingCache;
|
_steps = ESteps.InitVerifyingCache;
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"URL : {_downloader.URL} Error : remote patch manifest content is invalid";
|
Error = e.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_downloader.Dispose();
|
_downloader2.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitVerifyingCache)
|
if (_steps == ESteps.InitVerifyingCache)
|
||||||
@@ -184,164 +242,5 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
return _impl.GetPatchDownloadMainURL(fileName);
|
return _impl.GetPatchDownloadMainURL(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 解析并保存远端请求的补丁清单
|
|
||||||
/// </summary>
|
|
||||||
private bool ParseAndSaveRemotePatchManifest(string packageName, string packageCRC, string content)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var remotePatchManifest = PatchManifest.Deserialize(content);
|
|
||||||
_impl.SetLocalPatchManifest(remotePatchManifest);
|
|
||||||
|
|
||||||
YooLogger.Log("Save remote patch manifest file.");
|
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
|
|
||||||
string savePath = PathHelper.MakePersistentLoadPath(fileName);
|
|
||||||
PatchManifest.Serialize(savePath, remotePatchManifest);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error(e.ToString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载沙盒内的补丁清单
|
|
||||||
/// 注意:在加载本地补丁清单之前,已经验证过文件的哈希值
|
|
||||||
/// </summary>
|
|
||||||
private void LoadSandboxPatchManifest(string packageName, string packageCRC)
|
|
||||||
{
|
|
||||||
YooLogger.Log("Load sandbox patch manifest file.");
|
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(fileName);
|
|
||||||
string jsonData = File.ReadAllText(filePath);
|
|
||||||
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
|
|
||||||
_impl.SetLocalPatchManifest(sandboxPatchManifest);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒内补丁清单文件的哈希值
|
|
||||||
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
|
|
||||||
/// </summary>
|
|
||||||
private string GetSandboxPatchManifestFileHash(string packageName, string packageCRC)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(fileName);
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
return HashUtility.FileCRC32(filePath);
|
|
||||||
else
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 联机模式的更新清单操作(弱联网)
|
|
||||||
/// </summary>
|
|
||||||
internal sealed class HostPlayModeWeaklyUpdateManifestOperation : UpdateManifestOperation
|
|
||||||
{
|
|
||||||
private enum ESteps
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
LoadSandboxManifestHash,
|
|
||||||
InitVerifyingCache,
|
|
||||||
UpdateVerifyingCache,
|
|
||||||
Done,
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly HostPlayModeImpl _impl;
|
|
||||||
private readonly string _packageName;
|
|
||||||
private readonly string _packageCRC;
|
|
||||||
private ESteps _steps = ESteps.None;
|
|
||||||
private CacheVerifier _cacheVerifier;
|
|
||||||
private float _verifyTime;
|
|
||||||
|
|
||||||
internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC)
|
|
||||||
{
|
|
||||||
_impl = impl;
|
|
||||||
_packageName = packageName;
|
|
||||||
_packageCRC = packageCRC;
|
|
||||||
|
|
||||||
#if UNITY_WEBGL
|
|
||||||
_cacheVerifier = new CacheVerifierWithoutThread();
|
|
||||||
#else
|
|
||||||
_cacheVerifier = new CacheVerifierWithThread();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
internal override void Start()
|
|
||||||
{
|
|
||||||
_steps = ESteps.LoadSandboxManifestHash;
|
|
||||||
}
|
|
||||||
internal override void Update()
|
|
||||||
{
|
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadSandboxManifestHash)
|
|
||||||
{
|
|
||||||
LoadSandboxPatchManifest(_packageName, _packageCRC);
|
|
||||||
_steps = ESteps.InitVerifyingCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.InitVerifyingCache)
|
|
||||||
{
|
|
||||||
var verifyInfos = _impl.GetVerifyInfoList(true);
|
|
||||||
_cacheVerifier.InitVerifier(verifyInfos);
|
|
||||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
|
||||||
_steps = ESteps.UpdateVerifyingCache;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.UpdateVerifyingCache)
|
|
||||||
{
|
|
||||||
Progress = _cacheVerifier.GetVerifierProgress();
|
|
||||||
if (_cacheVerifier.UpdateVerifier())
|
|
||||||
{
|
|
||||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
|
||||||
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
|
||||||
|
|
||||||
bool verifySucceed = true;
|
|
||||||
foreach (var verifyInfo in _cacheVerifier.VerifyFailList)
|
|
||||||
{
|
|
||||||
// 注意:跳过内置资源文件
|
|
||||||
if (verifyInfo.IsBuildinFile)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
verifySucceed = false;
|
|
||||||
YooLogger.Warning($"Failed verify file : {verifyInfo.VerifyFilePath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verifySucceed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"The package resource {_packageName}_{_packageCRC} content has verify failed file !";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载沙盒内的补丁清单
|
|
||||||
/// 注意:在加载本地补丁清单之前,未验证过文件的哈希值
|
|
||||||
/// </summary>
|
|
||||||
private void LoadSandboxPatchManifest(string packageName, string packageCRC)
|
|
||||||
{
|
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC);
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(fileName);
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
YooLogger.Log("Load sandbox patch manifest file.");
|
|
||||||
string jsonData = File.ReadAllText(filePath);
|
|
||||||
var sandboxPatchManifest = PatchManifest.Deserialize(jsonData);
|
|
||||||
_impl.SetLocalPatchManifest(sandboxPatchManifest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,17 +80,17 @@ namespace YooAsset
|
|||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly string _packageName;
|
private readonly string _packageName;
|
||||||
private readonly string _packageCRC;
|
private readonly string _packageVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader;
|
private UnityWebDataRequester _downloader;
|
||||||
private PatchManifest _remotePatchManifest;
|
private PatchManifest _remotePatchManifest;
|
||||||
|
|
||||||
internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout)
|
internal HostPlayModeUpdatePackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageName = packageName;
|
_packageName = packageName;
|
||||||
_packageCRC = packageCRC;
|
_packageVersion = packageVersion;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
@@ -105,7 +105,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifest)
|
if (_steps == ESteps.LoadWebManifest)
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageCRC);
|
string fileName = YooAssetSettingsData.GetPatchManifestFileName(_packageName, _packageVersion);
|
||||||
string webURL = GetPatchManifestRequestURL(fileName);
|
string webURL = GetPatchManifestRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader = new UnityWebDataRequester();
|
||||||
@@ -128,17 +128,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 解析补丁清单
|
// 解析补丁清单
|
||||||
if (ParseRemotePatchManifest(_downloader.GetText()))
|
try
|
||||||
{
|
{
|
||||||
|
_remotePatchManifest = PatchManifest.Deserialize(_downloader.GetText());
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
catch(System.Exception e)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"URL : {_downloader.URL} Error : remote patch manifest content is invalid";
|
Error = e.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_downloader.Dispose();
|
_downloader.Dispose();
|
||||||
@@ -176,23 +177,6 @@ namespace YooAsset
|
|||||||
return _impl.GetPatchDownloadMainURL(fileName);
|
return _impl.GetPatchDownloadMainURL(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 解析远端请求的补丁清单
|
|
||||||
/// </summary>
|
|
||||||
private bool ParseRemotePatchManifest(string content)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_remotePatchManifest = PatchManifest.Deserialize(content);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Warning(e.ToString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取下载列表
|
/// 获取下载列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新静态版本操作
|
/// 获取包裹的最新版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UpdateStaticVersionOperation : AsyncOperationBase
|
public abstract class UpdateStaticVersionOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹文件的哈希值
|
/// 当前最新的包裹版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageCRC { protected set; get; } = string.Empty;
|
public string PackageVersion { protected set; get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的更新静态版本操作
|
/// 编辑器下模拟运行的获取包裹的最新版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class EditorPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class EditorPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
@@ -29,7 +30,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的更新静态版本操作
|
/// 离线模式的获取包裹的最新版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
@@ -43,7 +44,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机模式的更新静态版本操作
|
/// 联机模式的获取包裹的最新版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
@@ -80,8 +81,8 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.LoadStaticVersion)
|
if (_steps == ESteps.LoadStaticVersion)
|
||||||
{
|
{
|
||||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(_packageName);
|
string fileName = YooAssetSettingsData.GetPatchManifestVersionFileName(_packageName);
|
||||||
string webURL = GetStaticVersionRequestURL(versionFileName);
|
string webURL = GetStaticVersionRequestURL(fileName);
|
||||||
YooLogger.Log($"Beginning to request static version : {webURL}");
|
YooLogger.Log($"Beginning to request static version : {webURL}");
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader = new UnityWebDataRequester();
|
||||||
_downloader.SendRequest(webURL, _timeout);
|
_downloader.SendRequest(webURL, _timeout);
|
||||||
@@ -102,16 +103,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string packageCRC = _downloader.GetText();
|
PackageVersion = _downloader.GetText();
|
||||||
if(string.IsNullOrEmpty(packageCRC))
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"URL : {_downloader.URL} Error : static version content is empty.";
|
Error = $"Static package version is empty : {_downloader.URL}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PackageCRC = packageCRC;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user