mirror of https://github.com/tuyoogame/YooAsset
update editor
1. 编辑器界面支持本地化配置。 2. 资源构建过程中的异常输出增加错误码提示。 3. 修复了资源构建界面乱码问题。 4. 修复了自动收集着色器对依赖资源无效的问题。pull/189/head
parent
db889366ac
commit
0c70f27560
|
@ -23,7 +23,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 检测构建参数是否为空
|
// 检测构建参数是否为空
|
||||||
if (buildPipeline.Count == 0)
|
if (buildPipeline.Count == 0)
|
||||||
throw new Exception($"Build pipeline is empty !");
|
throw new Exception($"Build pipeline is empty !");
|
||||||
|
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_buildContext.ClearAllContext();
|
_buildContext.ClearAllContext();
|
||||||
|
@ -41,12 +41,12 @@ namespace YooAsset.Editor
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
BuildLogger.Log("Resource pipeline build success");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !");
|
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||||
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}");
|
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||||
BuildLogger.Error(buildResult.ErrorInfo);
|
BuildLogger.Error(buildResult.ErrorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace YooAsset.Editor
|
||||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||||
public static void OpenWindow()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes);
|
string windowName = Localization.Language(ELanguageKey.ABB_WindowTitle);
|
||||||
|
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>(windowName, true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ namespace YooAsset.Editor
|
||||||
if (packageNames.Count == 0)
|
if (packageNames.Count == 0)
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.text = "没有发现可构建的资源包";
|
label.text = Localization.Language(ELanguageKey.AAB_NoPackageTips);
|
||||||
label.style.width = 100;
|
label.style.width = 100;
|
||||||
_toolbar.Add(label);
|
_toolbar.Add(label);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace YooAsset.Editor
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(string assetPath)
|
||||||
{
|
{
|
||||||
CollectorType = ECollectorType.None;
|
CollectorType = ECollectorType.None;
|
||||||
|
BundleName = string.Empty;
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
|
|
||||||
|
@ -84,6 +85,16 @@ namespace YooAsset.Editor
|
||||||
AllDependAssetInfos = dependAssetInfos;
|
AllDependAssetInfos = dependAssetInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置为统一的着色器包名
|
||||||
|
/// </summary>
|
||||||
|
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
// 获取着色器打包规则结果
|
||||||
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加资源的分类标签
|
/// 添加资源的分类标签
|
||||||
/// 说明:原始定义的资源分类标签
|
/// 说明:原始定义的资源分类标签
|
||||||
|
|
|
@ -71,14 +71,13 @@ namespace YooAsset.Editor
|
||||||
/// 资源包加密服务类
|
/// 资源包加密服务类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEncryptionServices EncryptionServices;
|
public IEncryptionServices EncryptionServices;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = string.Empty;
|
private string _packageOutputDirectory = string.Empty;
|
||||||
private string _packageRootDirectory = string.Empty;
|
private string _packageRootDirectory = string.Empty;
|
||||||
private string _buildinRootDirectory = string.Empty;
|
private string _buildinRootDirectory = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测构建参数是否合法
|
/// 检测构建参数是否合法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -86,25 +85,46 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
// 检测当前是否正在构建资源包
|
// 检测当前是否正在构建资源包
|
||||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||||
throw new Exception("当前正在构建资源包,请结束后再试");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||||
// 检测构建参数合法性
|
throw new Exception(message);
|
||||||
if (BuildTarget == BuildTarget.NoTarget)
|
}
|
||||||
throw new Exception("请选择目标平台!");
|
|
||||||
if (string.IsNullOrEmpty(PackageName))
|
|
||||||
throw new Exception("包裹名称不能为空!");
|
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
|
||||||
throw new Exception("包裹版本不能为空!");
|
|
||||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
|
||||||
throw new Exception("构建输出的根目录为空!");
|
|
||||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
|
||||||
throw new Exception("内置资源根目录为空!");
|
|
||||||
|
|
||||||
// 检测是否有未保存场景
|
// 检测是否有未保存场景
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
if (BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (EditorTools.HasDirtyScenes())
|
if (EditorTools.HasDirtyScenes())
|
||||||
throw new Exception("检测到未保存的场景文件");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测构建参数合法性
|
||||||
|
if (BuildTarget == BuildTarget.NoTarget)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageName))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制构建删除包裹目录
|
// 强制构建删除包裹目录
|
||||||
|
@ -113,7 +133,7 @@ namespace YooAsset.Editor
|
||||||
string packageRootDirectory = GetPackageRootDirectory();
|
string packageRootDirectory = GetPackageRootDirectory();
|
||||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
{
|
{
|
||||||
BuildLogger.Log($"删除包裹目录:{packageRootDirectory}");
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,14 +142,17 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
string packageOutputDirectory = GetPackageOutputDirectory();
|
||||||
if (Directory.Exists(packageOutputDirectory))
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果输出目录不存在
|
// 如果输出目录不存在
|
||||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
BuildLogger.Log($"创建输出目录:{pipelineOutputDirectory}");
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
BuildLogger.Log($"内置文件拷贝完成:{buildinRootDirectory}");
|
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,9 +3,6 @@ using System.Linq;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using UnityEditor.Build.Pipeline;
|
|
||||||
using UnityEditor.Build.Pipeline.Interfaces;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class ManifestContext : IContextObject
|
public class ManifestContext : IContextObject
|
||||||
|
@ -55,7 +52,7 @@ namespace YooAsset.Editor
|
||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
ManifestTools.SerializeToJson(filePath, manifest);
|
ManifestTools.SerializeToJson(filePath, manifest);
|
||||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单二进制文件
|
// 创建补丁清单二进制文件
|
||||||
|
@ -65,7 +62,7 @@ namespace YooAsset.Editor
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||||
packageHash = HashUtility.FileMD5(filePath);
|
packageHash = HashUtility.FileMD5(filePath);
|
||||||
BuildLogger.Log($"创建补丁清单文件:{filePath}");
|
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||||
|
|
||||||
ManifestContext manifestContext = new ManifestContext();
|
ManifestContext manifestContext = new ManifestContext();
|
||||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||||
|
@ -78,7 +75,7 @@ namespace YooAsset.Editor
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.WriteAllText(filePath, packageHash);
|
FileUtility.WriteAllText(filePath, packageHash);
|
||||||
BuildLogger.Log($"创建补丁清单哈希文件:{filePath}");
|
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单版本文件
|
// 创建补丁清单版本文件
|
||||||
|
@ -86,7 +83,7 @@ namespace YooAsset.Editor
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||||
BuildLogger.Log($"创建补丁清单版本文件:{filePath}");
|
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +187,8 @@ namespace YooAsset.Editor
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||||
UnityEngine.Debug.LogWarning($"发现游离的资源包 {index} ! {packageBundle.BundleName}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +211,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found cached bundle ID : {bundleName}");
|
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace YooAsset.Editor
|
||||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
BuildReport.Serialize(filePath, buildReport);
|
BuildReport.Serialize(filePath, buildReport);
|
||||||
BuildLogger.Log($"资源构建报告文件创建完成:{filePath}");
|
BuildLogger.Log($"Create build report file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -148,7 +148,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
if (findAssetInfo == null)
|
if (findAssetInfo == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}");
|
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||||
}
|
}
|
||||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,6 @@ namespace YooAsset.Editor
|
||||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||||
fileInfo.BundleName = bundleInfo.BundleName;
|
fileInfo.BundleName = bundleInfo.BundleName;
|
||||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
|
|
||||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||||
if (encryptResult.Encrypted)
|
if (encryptResult.Encrypted)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +34,7 @@ namespace YooAsset.Editor
|
||||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||||
bundleInfo.EncryptedFilePath = filePath;
|
bundleInfo.EncryptedFilePath = filePath;
|
||||||
bundleInfo.Encrypted = true;
|
bundleInfo.Encrypted = true;
|
||||||
BuildLogger.Log($"Bundle文件加密完成:{filePath}");
|
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -43,7 +42,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Collection.Count);
|
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
||||||
// 2. 剔除未被引用的依赖项资源
|
// 2. 剔除未被引用的依赖项资源
|
||||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
||||||
|
|
||||||
// 3. 录入所有收集器收集的资源
|
// 3. 录入所有收集器主动收集的资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||||
|
@ -36,7 +36,8 @@ namespace YooAsset.Editor
|
||||||
if (collectAssetInfo.AssetTags.Count > 0)
|
if (collectAssetInfo.AssetTags.Count > 0)
|
||||||
{
|
{
|
||||||
collectAssetInfo.AssetTags.Clear();
|
collectAssetInfo.AssetTags.Clear();
|
||||||
BuildLogger.Warning($"The tags has been cleared ! {collectAssetInfo.AssetPath} ");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 录入所有收集资源的依赖资源
|
// 4. 录入所有收集资源依赖的其它资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
string bundleName = collectAssetInfo.BundleName;
|
string bundleName = collectAssetInfo.BundleName;
|
||||||
|
@ -83,12 +84,27 @@ namespace YooAsset.Editor
|
||||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 记录关键信息
|
// 6. 自动收集所有依赖的着色器
|
||||||
|
if (collectResult.Command.AutoCollectShaders)
|
||||||
|
{
|
||||||
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
|
{
|
||||||
|
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 记录关键信息
|
||||||
BuildMapContext context = new BuildMapContext();
|
BuildMapContext context = new BuildMapContext();
|
||||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||||
context.Command = collectResult.Command;
|
context.Command = collectResult.Command;
|
||||||
|
|
||||||
// 7. 记录冗余资源
|
// 8. 记录冗余资源
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
if (buildAssetInfo.IsRedundancyAsset())
|
||||||
|
@ -103,7 +119,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 移除不参与构建的资源
|
// 9. 移除不参与构建的资源
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
|
@ -115,10 +131,13 @@ namespace YooAsset.Editor
|
||||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 构建资源列表
|
// 10. 构建资源列表
|
||||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||||
if (allPackAssets.Count == 0)
|
if (allPackAssets.Count == 0)
|
||||||
throw new Exception("构建的资源列表不能为空");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
foreach (var assetInfo in allPackAssets)
|
foreach (var assetInfo in allPackAssets)
|
||||||
{
|
{
|
||||||
context.PackAsset(assetInfo);
|
context.PackAsset(assetInfo);
|
||||||
|
@ -162,7 +181,8 @@ namespace YooAsset.Editor
|
||||||
// 4. 移除所有零引用的依赖资源
|
// 4. 移除所有零引用的依赖资源
|
||||||
foreach (var removeValue in removeList)
|
foreach (var removeValue in removeList)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"发现未被依赖的资源并自动移除 : {removeValue.AssetPath}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
allCollectAssetInfos.Remove(removeValue);
|
allCollectAssetInfos.Remove(removeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@ namespace YooAsset.Editor
|
||||||
// NOTE:检测文件名长度不要超过260字符。
|
// NOTE:检测文件名长度不要超过260字符。
|
||||||
string fileName = bundleInfo.BundleName;
|
string fileName = bundleInfo.BundleName;
|
||||||
if (fileName.Length >= 260)
|
if (fileName.Length >= 260)
|
||||||
throw new Exception($"The output bundle name is too long {fileName.Length} chars : {fileName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.更新构建输出的文件路径
|
// 2.更新构建输出的文件路径
|
||||||
|
|
|
@ -7,7 +7,6 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建内容打包")]
|
|
||||||
public class TaskBuilding_BBP : IBuildTask
|
public class TaskBuilding_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
|
@ -29,22 +28,26 @@ namespace YooAsset.Editor
|
||||||
// 开始构建
|
// 开始构建
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||||
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (buildResults == null)
|
if (unityManifest == null)
|
||||||
{
|
{
|
||||||
throw new Exception("构建过程中发生错误!");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||||
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||||
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("Unity引擎打包成功!");
|
BuildLogger.Log("UnityEngine build success !");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.UnityManifest = buildResults;
|
buildResultContext.UnityManifest = unityManifest;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("拷贝内置文件")]
|
|
||||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建清单文件")]
|
|
||||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("制作包裹")]
|
|
||||||
public class TaskCreatePackage_BBP : IBuildTask
|
public class TaskCreatePackage_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -13,18 +12,18 @@ namespace YooAsset.Editor
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝UnityManifest序列化文件
|
// 拷贝UnityManifest序列化文件
|
||||||
{
|
{
|
||||||
|
@ -46,7 +45,7 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建构建报告文件")]
|
|
||||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源包加密")]
|
|
||||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -7,7 +7,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("获取资源构建内容")]
|
|
||||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建准备工作")]
|
|
||||||
public class TaskPrepare_BBP : IBuildTask
|
public class TaskPrepare_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -22,7 +21,8 @@ namespace YooAsset.Editor
|
||||||
#if UNITY_2021_3_OR_NEWER
|
#if UNITY_2021_3_OR_NEWER
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning("Unity2021版本开始内置构建管线不再维护,推荐使用可编程构建管线(SBP)!");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("更新资源包信息")]
|
|
||||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -28,9 +27,14 @@ namespace YooAsset.Editor
|
||||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||||
if (hash.isValid)
|
if (hash.isValid)
|
||||||
|
{
|
||||||
return hash.ToString();
|
return hash.ToString();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
@ -46,9 +50,14 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.BuildOutputFilePath;
|
string filePath = bundleInfo.BuildOutputFilePath;
|
||||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||||
|
{
|
||||||
return crc;
|
return crc;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
||||||
|
|
|
@ -8,7 +8,6 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("验证构建结果")]
|
|
||||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -46,9 +45,12 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
|
||||||
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
|
@ -57,12 +59,15 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
|
||||||
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("构建结果验证成功!");
|
BuildLogger.Log("Build results verify success!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -22,15 +22,15 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
{
|
{
|
||||||
new TaskPrepare_BBP(), //前期准备工作
|
new TaskPrepare_BBP(),
|
||||||
new TaskGetBuildMap_BBP(), //获取构建列表
|
new TaskGetBuildMap_BBP(),
|
||||||
new TaskBuilding_BBP(), //开始执行构建
|
new TaskBuilding_BBP(),
|
||||||
new TaskVerifyBuildResult_BBP(), //验证构建结果
|
new TaskVerifyBuildResult_BBP(),
|
||||||
new TaskUpdateBundleInfo_BBP(), //更新资源包信息
|
new TaskUpdateBundleInfo_BBP(),
|
||||||
new TaskCreateManifest_BBP(), //创建清单文件
|
new TaskCreateManifest_BBP(),
|
||||||
new TaskCreateReport_BBP(), //创建报告文件
|
new TaskCreateReport_BBP(),
|
||||||
new TaskCreatePackage_BBP(), //制作包裹
|
new TaskCreatePackage_BBP(),
|
||||||
new TaskCopyBuildinFiles_BBP(), //拷贝内置文件
|
new TaskCopyBuildinFiles_BBP(),
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建内容打包")]
|
|
||||||
public class TaskBuilding_RFBP : IBuildTask
|
public class TaskBuilding_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("拷贝内置文件")]
|
|
||||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建清单文件")]
|
|
||||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("制作包裹")]
|
|
||||||
public class TaskCreatePackage_RFBP : IBuildTask
|
public class TaskCreatePackage_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -13,19 +12,17 @@ namespace YooAsset.Editor
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
|
@ -33,7 +30,7 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建构建报告文件")]
|
|
||||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -7,7 +7,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("获取资源构建内容")]
|
|
||||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -29,7 +28,10 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.MainAssets.Count != 1)
|
if (bundleInfo.MainAssets.Count != 1)
|
||||||
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建准备工作")]
|
|
||||||
public class TaskPrepare_RFBP : IBuildTask
|
public class TaskPrepare_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -19,9 +18,15 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测不被支持的构建模式
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("更新资源包信息")]
|
|
||||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -22,14 +22,14 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
{
|
{
|
||||||
new TaskPrepare_RFBP(), //前期准备工作
|
new TaskPrepare_RFBP(),
|
||||||
new TaskGetBuildMap_RFBP(), //获取构建列表
|
new TaskGetBuildMap_RFBP(),
|
||||||
new TaskBuilding_RFBP(), //开始执行构建
|
new TaskBuilding_RFBP(),
|
||||||
new TaskUpdateBundleInfo_RFBP(), //更新资源包信息
|
new TaskUpdateBundleInfo_RFBP(),
|
||||||
new TaskCreateManifest_RFBP(), //创建清单文件
|
new TaskCreateManifest_RFBP(),
|
||||||
new TaskCreateReport_RFBP(), //创建报告文件
|
new TaskCreateReport_RFBP(),
|
||||||
new TaskCreatePackage_RFBP(), //制作包裹
|
new TaskCreatePackage_RFBP(),
|
||||||
new TaskCopyBuildinFiles_RFBP(), //拷贝内置文件
|
new TaskCopyBuildinFiles_RFBP(),
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ using UnityEditor.Build.Pipeline.Tasks;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建内容打包")]
|
|
||||||
public class TaskBuilding_SBP : IBuildTask
|
public class TaskBuilding_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
|
@ -37,7 +36,8 @@ namespace YooAsset.Editor
|
||||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
throw new Exception($"构建过程中发生错误 : {exitCode}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
||||||
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建着色器信息
|
// 创建着色器信息
|
||||||
|
@ -49,7 +49,7 @@ namespace YooAsset.Editor
|
||||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("Unity引擎打包成功!");
|
BuildLogger.Log("UnityEngine build success!");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("拷贝内置文件")]
|
|
||||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -7,7 +7,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建清单文件")]
|
|
||||||
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
||||||
|
@ -23,7 +22,10 @@ namespace YooAsset.Editor
|
||||||
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
|
||||||
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
|
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
|
||||||
throw new Exception($"Not found bundle in SBP build results : {bundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("制作包裹")]
|
|
||||||
public class TaskCreatePackage_SBP : IBuildTask
|
public class TaskCreatePackage_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -13,19 +12,19 @@ namespace YooAsset.Editor
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝构建日志
|
// 拷贝构建日志
|
||||||
{
|
{
|
||||||
|
@ -48,7 +47,7 @@ namespace YooAsset.Editor
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("创建构建报告文件")]
|
|
||||||
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源包加密")]
|
|
||||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -7,7 +7,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("获取资源构建内容")]
|
|
||||||
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("资源构建准备工作")]
|
|
||||||
public class TaskPrepare_SBP : IBuildTask
|
public class TaskPrepare_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -19,9 +18,15 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测不被支持的构建模式
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("更新资源包信息")]
|
|
||||||
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -28,9 +27,14 @@ namespace YooAsset.Editor
|
||||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||||
|
{
|
||||||
return value.Hash.ToString();
|
return value.Hash.ToString();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
@ -46,9 +50,14 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||||
|
{
|
||||||
return value.Crc;
|
return value.Crc;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
||||||
|
|
|
@ -9,7 +9,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute("验证构建结果")]
|
|
||||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
@ -47,9 +46,12 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
|
||||||
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
|
@ -58,12 +60,15 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
BuildLogger.Warning($"差异资源包: {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
throw new System.Exception("存在差异资源包!请查看警告信息!");
|
|
||||||
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("构建结果验证成功!");
|
BuildLogger.Log("Build results verify success!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,67 +4,64 @@ using UnityEngine.U2D;
|
||||||
using UnityEditor.Build.Pipeline.Injector;
|
using UnityEditor.Build.Pipeline.Injector;
|
||||||
using UnityEditor.Build.Pipeline.Interfaces;
|
using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace UnityEditor.Build.Pipeline.Tasks
|
namespace UnityEditor.Build.Pipeline.Tasks
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
/// Ref https://zhuanlan.zhihu.com/p/586918159
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
public class RemoveSpriteAtlasRedundancy : IBuildTask
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
public int Version => 1;
|
||||||
public int Version => 1;
|
|
||||||
|
|
||||||
[InjectContext]
|
[InjectContext]
|
||||||
IBundleWriteData writeDataParam;
|
IBundleWriteData writeDataParam;
|
||||||
|
|
||||||
/// <inheritdoc />
|
public ReturnCode Run()
|
||||||
public ReturnCode Run()
|
{
|
||||||
{
|
#if UNITY_2020_3_OR_NEWER
|
||||||
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
BundleWriteData writeData = (BundleWriteData)writeDataParam;
|
||||||
|
|
||||||
// 所有图集散图的 guid 集合
|
// 图集引用的精灵图片集合
|
||||||
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
HashSet<GUID> spriteGuids = new HashSet<GUID>();
|
||||||
|
foreach (var pair in writeData.FileToObjects)
|
||||||
|
{
|
||||||
|
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
||||||
|
{
|
||||||
|
var assetPath = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
||||||
|
var assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(SpriteAtlas))
|
||||||
|
{
|
||||||
|
var spritePaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||||
|
foreach (string spritePath in spritePaths)
|
||||||
|
{
|
||||||
|
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
||||||
|
spriteGuids.Add(spriteGuild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 遍历资源包里的资源记录其中图集的散图 guid
|
// 移除图集引用的精力图片对象
|
||||||
foreach (var pair in writeData.FileToObjects)
|
foreach (var pair in writeData.FileToObjects)
|
||||||
{
|
{
|
||||||
foreach (ObjectIdentifier objectIdentifier in pair.Value)
|
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
||||||
{
|
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
||||||
string path = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
|
{
|
||||||
Object asset = AssetDatabase.LoadAssetAtPath<Object>(path);
|
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
||||||
if (asset is SpriteAtlas)
|
if (spriteGuids.Contains(objectIdentifier.guid))
|
||||||
{
|
{
|
||||||
List<string> spritePaths = AssetDatabase.GetDependencies(path, false).ToList();
|
if (objectIdentifier.localIdentifierInFile == 2800000)
|
||||||
foreach (string spritePath in spritePaths)
|
{
|
||||||
{
|
// 删除图集散图的冗余纹理
|
||||||
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
|
objectIdentifiers.RemoveAt(i);
|
||||||
spriteGuids.Add(spriteGuild);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// 将 writeData.FileToObjects 包含的图集散图的 texture 删掉避免冗余
|
return ReturnCode.Success;
|
||||||
foreach (var pair in writeData.FileToObjects)
|
}
|
||||||
{
|
}
|
||||||
List<ObjectIdentifier> objectIdentifiers = pair.Value;
|
|
||||||
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
|
|
||||||
if (spriteGuids.Contains(objectIdentifier.guid))
|
|
||||||
{
|
|
||||||
if (objectIdentifier.localIdentifierInFile == 2800000)
|
|
||||||
{
|
|
||||||
// 删除图集散图的冗余 texture
|
|
||||||
objectIdentifiers.RemoveAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ReturnCode.Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -22,15 +22,15 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
{
|
{
|
||||||
new TaskPrepare_SBP(), //前期准备工作
|
new TaskPrepare_SBP(),
|
||||||
new TaskGetBuildMap_SBP(), //获取构建列表
|
new TaskGetBuildMap_SBP(),
|
||||||
new TaskBuilding_SBP(), //开始执行构建
|
new TaskBuilding_SBP(),
|
||||||
new TaskVerifyBuildResult_SBP(), //验证构建结果
|
new TaskVerifyBuildResult_SBP(),
|
||||||
new TaskUpdateBundleInfo_SBP(), //更新补丁信息
|
new TaskUpdateBundleInfo_SBP(),
|
||||||
new TaskCreateManifest_SBP(), //创建清单文件
|
new TaskCreateManifest_SBP(),
|
||||||
new TaskCreateReport_SBP(), //创建报告文件
|
new TaskCreateReport_SBP(),
|
||||||
new TaskCreatePackage_SBP(), //制作补丁包
|
new TaskCreatePackage_SBP(),
|
||||||
new TaskCopyBuildinFiles_SBP(), //拷贝内置文件
|
new TaskCopyBuildinFiles_SBP(),
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class BuildLogger
|
internal static class BuildLogger
|
||||||
{
|
{
|
||||||
private static bool _enableLog = true;
|
private static bool _enableLog = true;
|
||||||
|
|
||||||
|
@ -29,5 +29,10 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
Debug.LogError(message);
|
Debug.LogError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetErrorMessage(ErrorCode code, string message)
|
||||||
|
{
|
||||||
|
return $"[ErrorCode{(int)code}] {message}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -36,17 +36,15 @@ namespace YooAsset.Editor
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_buildWatch = Stopwatch.StartNew();
|
_buildWatch = Stopwatch.StartNew();
|
||||||
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>();
|
string taskName = task.GetType().Name.Split('_')[0];
|
||||||
if (taskAttribute != null)
|
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
||||||
BuildLogger.Log($"---------------------------------------->{taskAttribute.TaskDesc}<---------------------------------------");
|
|
||||||
task.Run(context);
|
task.Run(context);
|
||||||
_buildWatch.Stop();
|
_buildWatch.Stop();
|
||||||
|
|
||||||
// 统计耗时
|
// 统计耗时
|
||||||
int seconds = GetBuildSeconds();
|
int seconds = GetBuildSeconds();
|
||||||
TotalSeconds += seconds;
|
TotalSeconds += seconds;
|
||||||
if (taskAttribute != null)
|
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
||||||
BuildLogger.Log($"{taskAttribute.TaskDesc}耗时:{seconds}秒");
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +57,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回运行结果
|
// 返回运行结果
|
||||||
BuildLogger.Log($"构建过程总计耗时:{TotalSeconds}秒");
|
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
|
||||||
public class TaskAttribute : Attribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 任务说明
|
|
||||||
/// </summary>
|
|
||||||
public string TaskDesc;
|
|
||||||
|
|
||||||
public TaskAttribute(string taskDesc)
|
|
||||||
{
|
|
||||||
TaskDesc = taskDesc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -39,7 +39,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
private void CreateView(VisualElement parent)
|
private void CreateView(VisualElement parent)
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
@ -48,25 +48,25 @@ namespace YooAsset.Editor
|
||||||
Root.style.flexGrow = 1f;
|
Root.style.flexGrow = 1f;
|
||||||
parent.Add(Root);
|
parent.Add(Root);
|
||||||
|
|
||||||
// 输出目录
|
// 输出目录
|
||||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||||
_buildOutputField.SetEnabled(false);
|
_buildOutputField.SetEnabled(false);
|
||||||
|
|
||||||
// 构建版本
|
// 构建版本
|
||||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||||
_buildVersionField.style.width = StyleWidth;
|
_buildVersionField.style.width = StyleWidth;
|
||||||
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||||
|
|
||||||
// 构建模式
|
// 构建模式
|
||||||
{
|
{
|
||||||
var buildModeContainer = Root.Q("BuildModeContainer");
|
var buildModeContainer = Root.Q("BuildModeContainer");
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
var buildModeList = GetSupportBuildModes();
|
var buildModeList = GetSupportBuildModes();
|
||||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
||||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
||||||
_buildModeField.label = "BuildMode";
|
_buildModeField.label = "ABB_BuildMode";
|
||||||
_buildModeField.style.width = StyleWidth;
|
_buildModeField.style.width = StyleWidth;
|
||||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -75,7 +75,7 @@ namespace YooAsset.Editor
|
||||||
buildModeContainer.Add(_buildModeField);
|
buildModeContainer.Add(_buildModeField);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加密方法
|
// 加密方法
|
||||||
{
|
{
|
||||||
var encryptionContainer = Root.Q("EncryptionContainer");
|
var encryptionContainer = Root.Q("EncryptionContainer");
|
||||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||||
|
@ -84,7 +84,7 @@ namespace YooAsset.Editor
|
||||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "ABB_Encryption";
|
||||||
_encryptionField.style.width = StyleWidth;
|
_encryptionField.style.width = StyleWidth;
|
||||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
@ -95,13 +95,13 @@ namespace YooAsset.Editor
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_encryptionField = new PopupField<Type>();
|
_encryptionField = new PopupField<Type>();
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "ABB_Encryption";
|
||||||
_encryptionField.style.width = StyleWidth;
|
_encryptionField.style.width = StyleWidth;
|
||||||
encryptionContainer.Add(_encryptionField);
|
encryptionContainer.Add(_encryptionField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 压缩方式选项
|
// 压缩方式选项
|
||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
_compressionField = Root.Q<EnumField>("Compression");
|
_compressionField = Root.Q<EnumField>("Compression");
|
||||||
_compressionField.Init(compressOption);
|
_compressionField.Init(compressOption);
|
||||||
|
@ -112,7 +112,7 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 输出文件名称样式
|
// 输出文件名称样式
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||||
_outputNameStyleField.Init(fileNameStyle);
|
_outputNameStyleField.Init(fileNameStyle);
|
||||||
|
@ -123,7 +123,7 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 首包文件拷贝选项
|
// 首包文件拷贝选项
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||||
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
||||||
|
@ -135,7 +135,7 @@ namespace YooAsset.Editor
|
||||||
RefreshView();
|
RefreshView();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 首包文件拷贝参数
|
// 首包文件拷贝参数
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileTags");
|
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileTags");
|
||||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||||
|
@ -144,9 +144,20 @@ namespace YooAsset.Editor
|
||||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 构建按钮
|
// 构建按钮
|
||||||
var buildButton = Root.Q<Button>("Build");
|
var buildButton = Root.Q<Button>("Build");
|
||||||
buildButton.clicked += BuildButton_clicked;
|
buildButton.clicked += BuildButton_clicked;
|
||||||
|
|
||||||
|
// 本地化设置
|
||||||
|
UIElementsLocalize.Localize(_buildOutputField);
|
||||||
|
UIElementsLocalize.Localize(_buildVersionField);
|
||||||
|
UIElementsLocalize.Localize(_buildModeField);
|
||||||
|
UIElementsLocalize.Localize(_encryptionField);
|
||||||
|
UIElementsLocalize.Localize(_compressionField);
|
||||||
|
UIElementsLocalize.Localize(_outputNameStyleField);
|
||||||
|
UIElementsLocalize.Localize(_copyBuildinFileOptionField);
|
||||||
|
UIElementsLocalize.Localize(_copyBuildinFileTagsField);
|
||||||
|
UIElementsLocalize.Localize(buildButton);
|
||||||
}
|
}
|
||||||
private void RefreshView()
|
private void RefreshView()
|
||||||
{
|
{
|
||||||
|
@ -157,29 +168,29 @@ namespace YooAsset.Editor
|
||||||
private void BuildButton_clicked()
|
private void BuildButton_clicked()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||||
{
|
{
|
||||||
EditorTools.ClearUnityConsole();
|
EditorTools.ClearUnityConsole();
|
||||||
EditorApplication.delayCall += ExecuteBuild;
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning("[Build] 打包已经取消");
|
Debug.LogWarning("[Build] 打包已经取消");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行构建任务
|
/// 执行构建任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void ExecuteBuild();
|
protected abstract void ExecuteBuild();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线支持的构建模式集合
|
/// 获取构建管线支持的构建模式集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract List<Enum> GetSupportBuildModes();
|
protected abstract List<Enum> GetSupportBuildModes();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建版本
|
/// 获取构建版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected string GetPackageVersion()
|
protected string GetPackageVersion()
|
||||||
{
|
{
|
||||||
|
@ -187,7 +198,7 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建加密类实例
|
/// 创建加密类实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IEncryptionServices CreateEncryptionInstance()
|
protected IEncryptionServices CreateEncryptionInstance()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<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">
|
<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">
|
||||||
<ui:VisualElement name="BuildContainer">
|
<ui:VisualElement name="BuildContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="ABB_BuildOutput" name="BuildOutput" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
<ui:TextField picking-mode="Ignore" label="ABB_BuildVersion" name="BuildVersion" />
|
||||||
<ui:VisualElement name="BuildModeContainer" style="height: 24px;" />
|
<ui:VisualElement name="BuildModeContainer" 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="ABB_Compression" value="Center" name="Compression" />
|
||||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
<uie:EnumField label="ABB_FileNameStyle" value="Center" name="FileNameStyle" />
|
||||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
<uie:EnumField label="ABB_CopyBuildinFileOption" value="Center" name="CopyBuildinFileOption" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Tags" name="CopyBuildinFileTags" />
|
<ui:TextField picking-mode="Ignore" label="ABB_CopyBuildinFileTags" name="CopyBuildinFileTags" />
|
||||||
<ui:VisualElement name="ExtensionContainer" />
|
<ui:VisualElement name="ExtensionContainer" />
|
||||||
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
<ui:Button text="ABB_ClickBuild" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|
|
@ -92,7 +92,6 @@ namespace YooAsset.Editor
|
||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(AddressByFileName),
|
typeof(AddressByFileName),
|
||||||
typeof(AddressByFilePath),
|
|
||||||
typeof(AddressByFolderAndFileName),
|
typeof(AddressByFolderAndFileName),
|
||||||
typeof(AddressByGroupAndFileName),
|
typeof(AddressByGroupAndFileName),
|
||||||
typeof(AddressDisable)
|
typeof(AddressDisable)
|
||||||
|
|
|
@ -20,15 +20,6 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("定位地址: 文件路径")]
|
|
||||||
public class AddressByFilePath : IAddressRule
|
|
||||||
{
|
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
|
||||||
{
|
|
||||||
throw new System.Exception("可寻址模式下已经默认支持通过资源路径加载!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DisplayName("定位地址: 分组名_文件名")]
|
[DisplayName("定位地址: 分组名_文件名")]
|
||||||
public class AddressByGroupAndFileName : IAddressRule
|
public class AddressByGroupAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
internal enum ErrorCode
|
||||||
|
{
|
||||||
|
// TaskPrepare
|
||||||
|
ThePipelineIsBuiding = 100,
|
||||||
|
FoundUnsavedScene = 101,
|
||||||
|
NoBuildTarget = 110,
|
||||||
|
PackageNameIsNullOrEmpty = 111,
|
||||||
|
PackageVersionIsNullOrEmpty = 112,
|
||||||
|
BuildOutputRootIsNullOrEmpty = 113,
|
||||||
|
BuildinFileRootIsNullOrEmpty = 114,
|
||||||
|
PackageOutputDirectoryExists = 115,
|
||||||
|
RecommendScriptBuildPipeline = 130,
|
||||||
|
BuildPipelineNotSupportBuildMode = 140,
|
||||||
|
|
||||||
|
// TaskGetBuildMap
|
||||||
|
RemoveInvalidTags = 200,
|
||||||
|
FoundUndependedAsset = 201,
|
||||||
|
PackAssetListIsEmpty = 202,
|
||||||
|
NotSupportMultipleRawAsset = 210,
|
||||||
|
|
||||||
|
// TaskBuilding
|
||||||
|
UnityEngineBuildFailed = 300,
|
||||||
|
UnityEngineBuildFatal = 301,
|
||||||
|
|
||||||
|
// TaskUpdateBundleInfo
|
||||||
|
CharactersOverTheLimit = 400,
|
||||||
|
NotFoundUnityBundleHash = 401,
|
||||||
|
NotFoundUnityBundleCRC = 402,
|
||||||
|
|
||||||
|
// TaskVerifyBuildResult
|
||||||
|
UnintendedBuildBundle = 500,
|
||||||
|
UnintendedBuildResult = 501,
|
||||||
|
|
||||||
|
// TaskCreateManifest
|
||||||
|
NotFoundUnityBundleInBuildResult = 600,
|
||||||
|
FoundStrayBundle = 601,
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 35749e57d9a3da84aa60c348bc6bbe9d
|
guid: c3a10fd19801c0c428bac53081a96517
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,5 +1,4 @@
|
||||||
#if UNITY_2019_4_OR_NEWER
|
using System;
|
||||||
using System;
|
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
@ -13,5 +12,4 @@ namespace YooAsset.Editor
|
||||||
Application.OpenURL("https://www.yooasset.com/");
|
Application.OpenURL("https://www.yooasset.com/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 13015ce973f2b96489045e9f305427ac
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public interface ILocalization
|
||||||
|
{
|
||||||
|
string GetLanguage(ELanguageKey key);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a034d1ededabd44dbb1c7b4cf4772f6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public enum ELanguageKey
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
|
||||||
|
// AssetBundleBuilder
|
||||||
|
ABB_WindowTitle,
|
||||||
|
AAB_NoPackageTips,
|
||||||
|
ABB_BuildOutput,
|
||||||
|
ABB_BuildVersion,
|
||||||
|
ABB_BuildMode,
|
||||||
|
ABB_Encryption,
|
||||||
|
ABB_Compression,
|
||||||
|
ABB_FileNameStyle,
|
||||||
|
ABB_CopyBuildinFileOption,
|
||||||
|
ABB_CopyBuildinFileTags,
|
||||||
|
ABB_ClickBuild,
|
||||||
|
|
||||||
|
// AssetBundleCollector
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5fef97c24f81187488b84dfa60f36d62
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cd20abe0407ec2f469ee2f8166248262
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ChineseSimplified : ILocalization
|
||||||
|
{
|
||||||
|
public string GetLanguage(ELanguageKey key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case ELanguageKey.None: return "Invalid language";
|
||||||
|
|
||||||
|
// AssetBundleBuilder
|
||||||
|
case ELanguageKey.ABB_WindowTitle: return "资源包构建工具";
|
||||||
|
case ELanguageKey.AAB_NoPackageTips: return "没有发现可构建的资源包";
|
||||||
|
case ELanguageKey.ABB_BuildOutput: return "构建输出目录";
|
||||||
|
case ELanguageKey.ABB_BuildVersion: return "构建版本";
|
||||||
|
case ELanguageKey.ABB_BuildMode: return "构建模式";
|
||||||
|
case ELanguageKey.ABB_Encryption: return "加密方法";
|
||||||
|
case ELanguageKey.ABB_Compression: return "压缩方式";
|
||||||
|
case ELanguageKey.ABB_FileNameStyle: return "文件命名方式";
|
||||||
|
case ELanguageKey.ABB_CopyBuildinFileOption: return "内置文件拷贝选项";
|
||||||
|
case ELanguageKey.ABB_CopyBuildinFileTags: return "内置文件拷贝参数";
|
||||||
|
case ELanguageKey.ABB_ClickBuild: return "开始构建";
|
||||||
|
|
||||||
|
// AssetBundleCollector
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
Debug.LogError($"Not found language : {key}");
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65cd951ca39cd1b469691424350f5bc6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,7 @@
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 27a994f8cae769f4e9aa986c3ecb5079
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
internal static class Localization
|
||||||
|
{
|
||||||
|
private static ILocalization _localization;
|
||||||
|
|
||||||
|
static Localization()
|
||||||
|
{
|
||||||
|
var types = EditorTools.GetAssignableTypes(typeof(ILocalization));
|
||||||
|
_localization = (ILocalization)Activator.CreateInstance(types[0]);
|
||||||
|
CheckContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测多语言是否配置完整
|
||||||
|
/// </summary>
|
||||||
|
private static void CheckContent()
|
||||||
|
{
|
||||||
|
foreach (ELanguageKey key in Enum.GetValues(typeof(ELanguageKey)))
|
||||||
|
{
|
||||||
|
_localization.GetLanguage(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串转换为枚举类型
|
||||||
|
/// </summary>
|
||||||
|
public static ELanguageKey Convert(string enumName)
|
||||||
|
{
|
||||||
|
return (ELanguageKey)Enum.Parse(typeof(ELanguageKey), enumName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取多语言内容
|
||||||
|
/// </summary>
|
||||||
|
public static string Language(ELanguageKey key, params object[] args)
|
||||||
|
{
|
||||||
|
string content = _localization.GetLanguage(key);
|
||||||
|
if (args.Length > 0)
|
||||||
|
return string.Format(content, args);
|
||||||
|
else
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f2558d1b74a918449486d37aecdd850
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,43 @@
|
||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public static class UIElementsLocalize
|
||||||
|
{
|
||||||
|
public static void Localize(TextField element)
|
||||||
|
{
|
||||||
|
ELanguageKey key = Localization.Convert(element.label);
|
||||||
|
element.label = Localization.Language(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Localize(Button element)
|
||||||
|
{
|
||||||
|
ELanguageKey key = Localization.Convert(element.text);
|
||||||
|
element.text = Localization.Language(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Localize(EnumField element)
|
||||||
|
{
|
||||||
|
ELanguageKey key = Localization.Convert(element.label);
|
||||||
|
element.label = Localization.Language(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Localize(PopupField<Enum> element)
|
||||||
|
{
|
||||||
|
ELanguageKey key = Localization.Convert(element.label);
|
||||||
|
element.label = Localization.Language(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Localize(PopupField<Type> element)
|
||||||
|
{
|
||||||
|
ELanguageKey key = Localization.Convert(element.label);
|
||||||
|
element.label = Localization.Language(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d4124369e9ae444888b46fa07816908
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue