mirror of https://github.com/tuyoogame/YooAsset
style : Code text indent format
parent
544832c46a
commit
727f356eea
|
@ -8,49 +8,49 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleBuilder
|
public class AssetBundleBuilder
|
||||||
{
|
{
|
||||||
private readonly BuildContext _buildContext = new BuildContext();
|
private readonly BuildContext _buildContext = new BuildContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建资源包
|
/// 构建资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline, bool enableLog)
|
||||||
{
|
{
|
||||||
// 检测构建参数是否为空
|
// 检测构建参数是否为空
|
||||||
if (buildParameters == null)
|
if (buildParameters == null)
|
||||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||||
|
|
||||||
// 检测构建参数是否为空
|
// 检测构建参数是否为空
|
||||||
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();
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
|
||||||
// 初始化日志
|
// 初始化日志
|
||||||
BuildLogger.InitLogger(enableLog);
|
BuildLogger.InitLogger(enableLog);
|
||||||
|
|
||||||
// 执行构建流程
|
// 执行构建流程
|
||||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log("Resource pipeline build success");
|
BuildLogger.Log("Resource pipeline build success");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||||
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||||
BuildLogger.Error(buildResult.ErrorInfo);
|
BuildLogger.Error(buildResult.ErrorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,23 +6,23 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class AssetBundleBuilderHelper
|
public static class AssetBundleBuilderHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的输出根路录
|
/// 获取默认的输出根路录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetDefaultBuildOutputRoot()
|
public static string GetDefaultBuildOutputRoot()
|
||||||
{
|
{
|
||||||
string projectPath = EditorTools.GetProjectPath();
|
string projectPath = EditorTools.GetProjectPath();
|
||||||
return $"{projectPath}/Bundles";
|
return $"{projectPath}/Bundles";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取流文件夹路径
|
/// 获取流文件夹路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetStreamingAssetsRoot()
|
public static string GetStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,90 +4,90 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class AssetBundleBuilderSetting
|
public static class AssetBundleBuilderSetting
|
||||||
{
|
{
|
||||||
// EBuildPipeline
|
// EBuildPipeline
|
||||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EBuildMode
|
// EBuildMode
|
||||||
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||||
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||||
EditorPrefs.SetInt(key, (int)buildMode);
|
EditorPrefs.SetInt(key, (int)buildMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECompressOption
|
// ECompressOption
|
||||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||||
}
|
}
|
||||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)compressOption);
|
EditorPrefs.SetInt(key, (int)compressOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EFileNameStyle
|
// EFileNameStyle
|
||||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||||
}
|
}
|
||||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EBuildinFileCopyOption
|
// EBuildinFileCopyOption
|
||||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildFileCopyParams
|
// BuildFileCopyParams
|
||||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
return EditorPrefs.GetString(key, string.Empty);
|
||||||
}
|
}
|
||||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncyptionClassName
|
// EncyptionClassName
|
||||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
return EditorPrefs.GetString(key, string.Empty);
|
||||||
}
|
}
|
||||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||||
EditorPrefs.SetString(key, encyptionClassName);
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,153 +9,153 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleBuilderWindow : EditorWindow
|
public class AssetBundleBuilderWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||||
public static void OpenWindow()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _buildPackage;
|
private string _buildPackage;
|
||||||
private EBuildPipeline _buildPipeline;
|
private EBuildPipeline _buildPipeline;
|
||||||
|
|
||||||
private Toolbar _toolbar;
|
private Toolbar _toolbar;
|
||||||
private ToolbarMenu _packageMenu;
|
private ToolbarMenu _packageMenu;
|
||||||
private ToolbarMenu _pipelineMenu;
|
private ToolbarMenu _pipelineMenu;
|
||||||
private VisualElement _container;
|
private VisualElement _container;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
_toolbar = root.Q<Toolbar>("Toolbar");
|
_toolbar = root.Q<Toolbar>("Toolbar");
|
||||||
_container = root.Q("Container");
|
_container = root.Q("Container");
|
||||||
|
|
||||||
// 检测构建包裹
|
// 检测构建包裹
|
||||||
var packageNames = GetBuildPackageNames();
|
var packageNames = GetBuildPackageNames();
|
||||||
if (packageNames.Count == 0)
|
if (packageNames.Count == 0)
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.text = "Not found any package";
|
label.text = "Not found any package";
|
||||||
label.style.width = 100;
|
label.style.width = 100;
|
||||||
_toolbar.Add(label);
|
_toolbar.Add(label);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建包裹
|
// 构建包裹
|
||||||
{
|
{
|
||||||
_buildPackage = packageNames[0];
|
_buildPackage = packageNames[0];
|
||||||
_packageMenu = new ToolbarMenu();
|
_packageMenu = new ToolbarMenu();
|
||||||
_packageMenu.style.width = 200;
|
_packageMenu.style.width = 200;
|
||||||
foreach (var packageName in packageNames)
|
foreach (var packageName in packageNames)
|
||||||
{
|
{
|
||||||
_packageMenu.menu.AppendAction(packageName, PackageMenuAction, PackageMenuFun, packageName);
|
_packageMenu.menu.AppendAction(packageName, PackageMenuAction, PackageMenuFun, packageName);
|
||||||
}
|
}
|
||||||
_toolbar.Add(_packageMenu);
|
_toolbar.Add(_packageMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建管线
|
// 构建管线
|
||||||
{
|
{
|
||||||
_pipelineMenu = new ToolbarMenu();
|
_pipelineMenu = new ToolbarMenu();
|
||||||
_pipelineMenu.style.width = 200;
|
_pipelineMenu.style.width = 200;
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||||
_toolbar.Add(_pipelineMenu);
|
_toolbar.Add(_pipelineMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError(e.ToString());
|
Debug.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshBuildPipelineView()
|
private void RefreshBuildPipelineView()
|
||||||
{
|
{
|
||||||
// 清空扩展区域
|
// 清空扩展区域
|
||||||
_container.Clear();
|
_container.Clear();
|
||||||
|
|
||||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||||
_packageMenu.text = _buildPackage;
|
_packageMenu.text = _buildPackage;
|
||||||
_pipelineMenu.text = _buildPipeline.ToString();
|
_pipelineMenu.text = _buildPipeline.ToString();
|
||||||
|
|
||||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
{
|
{
|
||||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||||
}
|
}
|
||||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||||
}
|
}
|
||||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||||
{
|
{
|
||||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetBuildPackageNames()
|
private List<string> GetBuildPackageNames()
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||||
{
|
{
|
||||||
result.Add(package.PackageName);
|
result.Add(package.PackageName);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PackageMenuAction(DropdownMenuAction action)
|
private void PackageMenuAction(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var packageName = (string)action.userData;
|
var packageName = (string)action.userData;
|
||||||
if (_buildPackage != packageName)
|
if (_buildPackage != packageName)
|
||||||
{
|
{
|
||||||
_buildPackage = packageName;
|
_buildPackage = packageName;
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status PackageMenuFun(DropdownMenuAction action)
|
private DropdownMenuAction.Status PackageMenuFun(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var packageName = (string)action.userData;
|
var packageName = (string)action.userData;
|
||||||
if (_buildPackage == packageName)
|
if (_buildPackage == packageName)
|
||||||
return DropdownMenuAction.Status.Checked;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PipelineMenuAction(DropdownMenuAction action)
|
private void PipelineMenuAction(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
var pipelineType = (EBuildPipeline)action.userData;
|
||||||
if (_buildPipeline != pipelineType)
|
if (_buildPipeline != pipelineType)
|
||||||
{
|
{
|
||||||
_buildPipeline = pipelineType;
|
_buildPipeline = pipelineType;
|
||||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
var pipelineType = (EBuildPipeline)action.userData;
|
||||||
if (_buildPipeline == pipelineType)
|
if (_buildPipeline == pipelineType)
|
||||||
return DropdownMenuAction.Status.Checked;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -3,98 +3,98 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class AssetBundleSimulateBuilder
|
public static class AssetBundleSimulateBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模拟构建
|
/// 模拟构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||||
{
|
{
|
||||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
||||||
{
|
{
|
||||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
buildParameters.BuildPipeline = buildPipelineName;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
|
||||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, false);
|
var buildResult = pipeline.Run(buildParameters, false);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||||
return manifestFilePath;
|
return manifestFilePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
||||||
{
|
{
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
buildParameters.BuildPipeline = buildPipelineName;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||||
return manifestFilePath;
|
return manifestFilePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
||||||
{
|
{
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
buildParameters.BuildPipeline = buildPipelineName;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||||
return manifestFilePath;
|
return manifestFilePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(buildPipelineName);
|
throw new System.NotImplementedException(buildPipelineName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,155 +5,155 @@ using System.Linq;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildAssetInfo
|
public class BuildAssetInfo
|
||||||
{
|
{
|
||||||
private bool _isAddAssetTags = false;
|
private bool _isAddAssetTags = false;
|
||||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器类型
|
/// 收集器类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECollectorType CollectorType { private set; get; }
|
public ECollectorType CollectorType { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包完整名称
|
/// 资源包完整名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { private set; get; }
|
public string BundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址
|
/// 可寻址地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public string AssetPath { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源GUID
|
/// 资源GUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetGUID { private set; get; }
|
public string AssetGUID { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源类型
|
/// 资源类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public System.Type AssetType { private set; get; }
|
public System.Type AssetType { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<string> AssetTags = new List<string>();
|
public readonly List<string> AssetTags = new List<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的所有资源
|
/// 依赖的所有资源
|
||||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
|
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
}
|
}
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(string assetPath)
|
||||||
{
|
{
|
||||||
CollectorType = ECollectorType.None;
|
CollectorType = ECollectorType.None;
|
||||||
BundleName = string.Empty;
|
BundleName = string.Empty;
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
|
|
||||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置所有依赖的资源
|
/// 设置所有依赖的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||||
{
|
{
|
||||||
if (AllDependAssetInfos != null)
|
if (AllDependAssetInfos != null)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
AllDependAssetInfos = dependAssetInfos;
|
AllDependAssetInfos = dependAssetInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置为统一的着色器包名
|
/// 设置为统一的着色器包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
// 获取着色器打包规则结果
|
||||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加资源的分类标签
|
/// 添加资源的分类标签
|
||||||
/// 说明:原始定义的资源分类标签
|
/// 说明:原始定义的资源分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddAssetTags(List<string> tags)
|
public void AddAssetTags(List<string> tags)
|
||||||
{
|
{
|
||||||
if (_isAddAssetTags)
|
if (_isAddAssetTags)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
_isAddAssetTags = true;
|
_isAddAssetTags = true;
|
||||||
|
|
||||||
foreach (var tag in tags)
|
foreach (var tag in tags)
|
||||||
{
|
{
|
||||||
if (AssetTags.Contains(tag) == false)
|
if (AssetTags.Contains(tag) == false)
|
||||||
{
|
{
|
||||||
AssetTags.Add(tag);
|
AssetTags.Add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加关联的资源包名称
|
/// 添加关联的资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddReferenceBundleName(string bundleName)
|
public void AddReferenceBundleName(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||||
_referenceBundleNames.Add(bundleName);
|
_referenceBundleNames.Add(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名是否存在
|
/// 资源包名是否存在
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasBundleName()
|
public bool HasBundleName()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(BundleName))
|
if (string.IsNullOrEmpty(BundleName))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断是否为冗余资源
|
/// 判断是否为冗余资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsRedundancyAsset()
|
public bool IsRedundancyAsset()
|
||||||
{
|
{
|
||||||
if (HasBundleName())
|
if (HasBundleName())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return _referenceBundleNames.Count > 1;
|
return _referenceBundleNames.Count > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取关联资源包的数量
|
/// 获取关联资源包的数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int GetReferenceBundleCount()
|
public int GetReferenceBundleCount()
|
||||||
{
|
{
|
||||||
return _referenceBundleNames.Count;
|
return _referenceBundleNames.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,171 +6,171 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildBundleInfo
|
public class BuildBundleInfo
|
||||||
{
|
{
|
||||||
#region 补丁文件的关键信息
|
#region 补丁文件的关键信息
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageUnityHash { set; get; }
|
public string PackageUnityHash { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unity引擎生成的CRC
|
/// Unity引擎生成的CRC
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public uint PackageUnityCRC { set; get; }
|
public uint PackageUnityCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageFileHash { set; get; }
|
public string PackageFileHash { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageFileCRC { set; get; }
|
public string PackageFileCRC { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long PackageFileSize { set; get; }
|
public long PackageFileSize { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出的文件路径
|
/// 构建输出的文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildOutputFilePath { set; get; }
|
public string BuildOutputFilePath { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁包的源文件路径
|
/// 补丁包的源文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageSourceFilePath { set; get; }
|
public string PackageSourceFilePath { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁包的目标文件路径
|
/// 补丁包的目标文件路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageDestFilePath { set; get; }
|
public string PackageDestFilePath { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密生成文件的路径
|
/// 加密生成文件的路径
|
||||||
/// 注意:如果未加密该路径为空
|
/// 注意:如果未加密该路径为空
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string EncryptedFilePath { set; get; }
|
public string EncryptedFilePath { set; get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源列表
|
/// 参与构建的资源列表
|
||||||
/// 注意:不包含零依赖资源和冗余资源
|
/// 注意:不包含零依赖资源和冗余资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { private set; get; }
|
public string BundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密文件
|
/// 加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Encrypted { set; get; }
|
public bool Encrypted { set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BuildBundleInfo(string bundleName)
|
public BuildBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个打包资源
|
/// 添加一个打包资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
if (IsContainsAsset(assetInfo.AssetPath))
|
if (IsContainsAsset(assetInfo.AssetPath))
|
||||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
||||||
|
|
||||||
MainAssets.Add(assetInfo);
|
MainAssets.Add(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含指定资源
|
/// 是否包含指定资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
public bool IsContainsAsset(string assetPath)
|
||||||
{
|
{
|
||||||
foreach (var assetInfo in MainAssets)
|
foreach (var assetInfo in MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AssetPath == assetPath)
|
if (assetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建的资源路径列表
|
/// 获取构建的资源路径列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetAllMainAssetPaths()
|
public string[] GetAllMainAssetPaths()
|
||||||
{
|
{
|
||||||
return MainAssets.Select(t => t.AssetPath).ToArray();
|
return MainAssets.Select(t => t.AssetPath).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GetAllBuiltinAssetPaths()
|
public List<string> GetAllBuiltinAssetPaths()
|
||||||
{
|
{
|
||||||
var packAssets = GetAllMainAssetPaths();
|
var packAssets = GetAllMainAssetPaths();
|
||||||
List<string> result = new List<string>(packAssets);
|
List<string> result = new List<string>(packAssets);
|
||||||
foreach (var assetInfo in MainAssets)
|
foreach (var assetInfo in MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AllDependAssetInfos == null)
|
if (assetInfo.AllDependAssetInfos == null)
|
||||||
continue;
|
continue;
|
||||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||||
{
|
{
|
||||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||||
if (dependAssetInfo.HasBundleName() == false)
|
if (dependAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建AssetBundleBuild类
|
/// 创建AssetBundleBuild类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||||
{
|
{
|
||||||
// 注意:我们不在支持AssetBundle的变种机制
|
// 注意:我们不在支持AssetBundle的变种机制
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
build.assetNames = GetAllMainAssetPaths();
|
build.assetNames = GetAllMainAssetPaths();
|
||||||
return build;
|
return build;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有写入补丁清单的资源
|
/// 获取所有写入补丁清单的资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||||
{
|
{
|
||||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建PackageBundle类
|
/// 创建PackageBundle类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal PackageBundle CreatePackageBundle()
|
internal PackageBundle CreatePackageBundle()
|
||||||
{
|
{
|
||||||
PackageBundle packageBundle = new PackageBundle();
|
PackageBundle packageBundle = new PackageBundle();
|
||||||
packageBundle.BundleName = BundleName;
|
packageBundle.BundleName = BundleName;
|
||||||
packageBundle.UnityCRC = PackageUnityCRC;
|
packageBundle.UnityCRC = PackageUnityCRC;
|
||||||
packageBundle.FileHash = PackageFileHash;
|
packageBundle.FileHash = PackageFileHash;
|
||||||
packageBundle.FileCRC = PackageFileCRC;
|
packageBundle.FileCRC = PackageFileCRC;
|
||||||
packageBundle.FileSize = PackageFileSize;
|
packageBundle.FileSize = PackageFileSize;
|
||||||
packageBundle.Encrypted = Encrypted;
|
packageBundle.Encrypted = Encrypted;
|
||||||
return packageBundle;
|
return packageBundle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,106 +6,106 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildMapContext : IContextObject
|
public class BuildMapContext : IContextObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包集合
|
/// 资源包集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 冗余的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int AssetFileCount;
|
public int AssetFileCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源收集命令
|
/// 资源收集命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CollectCommand Command { set; get; }
|
public CollectCommand Command { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包信息列表
|
/// 资源包信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _bundleInfoDic.Values;
|
return _bundleInfoDic.Values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个打包资源
|
/// 添加一个打包资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
string bundleName = assetInfo.BundleName;
|
string bundleName = assetInfo.BundleName;
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||||
{
|
{
|
||||||
bundleInfo.PackAsset(assetInfo);
|
bundleInfo.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||||
newBundleInfo.PackAsset(assetInfo);
|
newBundleInfo.PackAsset(assetInfo);
|
||||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否包含资源包
|
/// 是否包含资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsBundle(string bundleName)
|
public bool IsContainsBundle(string bundleName)
|
||||||
{
|
{
|
||||||
return _bundleInfoDic.ContainsKey(bundleName);
|
return _bundleInfoDic.ContainsKey(bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包信息,如果没找到返回NULL
|
/// 获取资源包信息,如果没找到返回NULL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildBundleInfo GetBundleInfo(string bundleName)
|
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线里需要的数据
|
/// 获取构建管线里需要的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||||
{
|
{
|
||||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||||
{
|
{
|
||||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||||
}
|
}
|
||||||
return builds.ToArray();
|
return builds.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建着色器信息类
|
/// 创建着色器信息类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||||
{
|
{
|
||||||
if (IsContainsBundle(shadersBundleName) == false)
|
if (IsContainsBundle(shadersBundleName) == false)
|
||||||
{
|
{
|
||||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,204 +6,204 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建参数
|
/// 构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BuildParameters
|
public abstract class BuildParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出的根目录
|
/// 构建输出的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildOutputRoot;
|
public string BuildOutputRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的根目录
|
/// 内置文件的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildinFileRoot;
|
public string BuildinFileRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建管线
|
/// 构建管线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPipeline;
|
public string BuildPipeline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的平台
|
/// 构建的平台
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode;
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的包裹名称
|
/// 构建的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName;
|
public string PackageName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的包裹版本
|
/// 构建的包裹版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool VerifyBuildingResult = false;
|
public bool VerifyBuildingResult = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称样式
|
/// 资源包名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝选项
|
/// 内置文件的拷贝选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
public EBuildinFileCopyOption BuildinFileCopyOption;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝参数
|
/// 内置文件的拷贝参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildinFileCopyParams;
|
public string BuildinFileCopyParams;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包加密服务类
|
/// 资源包加密服务类
|
||||||
/// </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>
|
||||||
public virtual void CheckBuildParameters()
|
public virtual void CheckBuildParameters()
|
||||||
{
|
{
|
||||||
// 检测当前是否正在构建资源包
|
// 检测当前是否正在构建资源包
|
||||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测是否有未保存场景
|
// 检测是否有未保存场景
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
if (BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (EditorTools.HasDirtyScenes())
|
if (EditorTools.HasDirtyScenes())
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测构建参数合法性
|
// 检测构建参数合法性
|
||||||
if (BuildTarget == BuildTarget.NoTarget)
|
if (BuildTarget == BuildTarget.NoTarget)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(PackageName))
|
if (string.IsNullOrEmpty(PackageName))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制构建删除包裹目录
|
// 强制构建删除包裹目录
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
if (BuildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
string packageRootDirectory = GetPackageRootDirectory();
|
string packageRootDirectory = GetPackageRootDirectory();
|
||||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
{
|
{
|
||||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测包裹输出目录是否存在
|
// 检测包裹输出目录是否存在
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
if (BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
string packageOutputDirectory = GetPackageOutputDirectory();
|
||||||
if (Directory.Exists(packageOutputDirectory))
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果输出目录不存在
|
// 如果输出目录不存在
|
||||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线的输出目录
|
/// 获取构建管线的输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string GetPipelineOutputDirectory()
|
public virtual string GetPipelineOutputDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||||
{
|
{
|
||||||
_pipelineOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
_pipelineOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||||
}
|
}
|
||||||
return _pipelineOutputDirectory;
|
return _pipelineOutputDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁输出目录
|
/// 获取本次构建的补丁输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string GetPackageOutputDirectory()
|
public virtual string GetPackageOutputDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||||
{
|
{
|
||||||
_packageOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
_packageOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
||||||
}
|
}
|
||||||
return _packageOutputDirectory;
|
return _packageOutputDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁根目录
|
/// 获取本次构建的补丁根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string GetPackageRootDirectory()
|
public virtual string GetPackageRootDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageRootDirectory))
|
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||||
{
|
{
|
||||||
_packageRootDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
_packageRootDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
||||||
}
|
}
|
||||||
return _packageRootDirectory;
|
return _packageRootDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置资源的根目录
|
/// 获取内置资源的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual string GetBuildinRootDirectory()
|
public virtual string GetBuildinRootDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||||
{
|
{
|
||||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||||
}
|
}
|
||||||
return _buildinRootDirectory;
|
return _buildinRootDirectory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,58 +6,58 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildParametersContext : IContextObject
|
public class BuildParametersContext : IContextObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建参数
|
/// 构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildParameters Parameters { private set; get; }
|
public BuildParameters Parameters { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BuildParametersContext(BuildParameters parameters)
|
public BuildParametersContext(BuildParameters parameters)
|
||||||
{
|
{
|
||||||
Parameters = parameters;
|
Parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测构建参数是否合法
|
/// 检测构建参数是否合法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckBuildParameters()
|
public void CheckBuildParameters()
|
||||||
{
|
{
|
||||||
Parameters.CheckBuildParameters();
|
Parameters.CheckBuildParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建管线的输出目录
|
/// 获取构建管线的输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetPipelineOutputDirectory()
|
public string GetPipelineOutputDirectory()
|
||||||
{
|
{
|
||||||
return Parameters.GetPipelineOutputDirectory();
|
return Parameters.GetPipelineOutputDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁输出目录
|
/// 获取本次构建的补丁输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageOutputDirectory()
|
public string GetPackageOutputDirectory()
|
||||||
{
|
{
|
||||||
return Parameters.GetPackageOutputDirectory();
|
return Parameters.GetPackageOutputDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取本次构建的补丁根目录
|
/// 获取本次构建的补丁根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetPackageRootDirectory()
|
public string GetPackageRootDirectory()
|
||||||
{
|
{
|
||||||
return Parameters.GetPackageRootDirectory();
|
return Parameters.GetPackageRootDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置资源的根目录
|
/// 获取内置资源的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBuildinRootDirectory()
|
public string GetBuildinRootDirectory()
|
||||||
{
|
{
|
||||||
return Parameters.GetBuildinRootDirectory();
|
return Parameters.GetBuildinRootDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,77 +6,77 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCopyBuildinFiles
|
public class TaskCopyBuildinFiles
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝首包资源文件
|
/// 拷贝首包资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||||
|
|
||||||
// 清空内置文件的目录
|
// 清空内置文件的目录
|
||||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||||
{
|
{
|
||||||
EditorTools.ClearFolder(buildinRootDirectory);
|
EditorTools.ClearFolder(buildinRootDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单文件
|
// 拷贝补丁清单文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单哈希文件
|
// 拷贝补丁清单哈希文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
||||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝补丁清单版本文件
|
// 拷贝补丁清单版本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝文件列表(所有文件)
|
// 拷贝文件列表(所有文件)
|
||||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||||
{
|
{
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝文件列表(带标签的文件)
|
// 拷贝文件列表(带标签的文件)
|
||||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||||
{
|
{
|
||||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (packageBundle.HasTag(tags) == false)
|
if (packageBundle.HasTag(tags) == false)
|
||||||
continue;
|
continue;
|
||||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,215 +5,215 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class ManifestContext : IContextObject
|
public class ManifestContext : IContextObject
|
||||||
{
|
{
|
||||||
internal PackageManifest Manifest;
|
internal PackageManifest Manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class TaskCreateManifest
|
public abstract class TaskCreateManifest
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||||
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void CreateManifestFile(BuildContext context)
|
protected void CreateManifestFile(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
manifest.PackageName = buildParameters.PackageName;
|
manifest.PackageName = buildParameters.PackageName;
|
||||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
||||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
// 处理资源包的依赖列表
|
// 处理资源包的依赖列表
|
||||||
ProcessBundleDepends(context, manifest);
|
ProcessBundleDepends(context, manifest);
|
||||||
|
|
||||||
// 处理资源包的标签集合
|
// 处理资源包的标签集合
|
||||||
ProcessBundleTags(manifest);
|
ProcessBundleTags(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单文本文件
|
// 创建补丁清单文本文件
|
||||||
{
|
{
|
||||||
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($"Create package manifest file: {filePath}");
|
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单二进制文件
|
// 创建补丁清单二进制文件
|
||||||
string packageHash;
|
string packageHash;
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
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($"Create package manifest file: {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);
|
||||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||||
context.SetContextObject(manifestContext);
|
context.SetContextObject(manifestContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建补丁清单哈希文件
|
||||||
{
|
{
|
||||||
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($"Create package manifest hash file: {filePath}");
|
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单版本文件
|
// 创建补丁清单版本文件
|
||||||
{
|
{
|
||||||
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($"Create package manifest version file: {filePath}");
|
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的依赖集合
|
/// 获取资源包的依赖集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取主资源对象列表
|
/// 获取主资源对象列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
||||||
foreach (var assetInfo in assetInfos)
|
foreach (var assetInfo in assetInfos)
|
||||||
{
|
{
|
||||||
PackageAsset packageAsset = new PackageAsset();
|
PackageAsset packageAsset = new PackageAsset();
|
||||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetPath;
|
||||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包列表
|
/// 获取资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
var packageBundle = bundleInfo.CreatePackageBundle();
|
var packageBundle = bundleInfo.CreatePackageBundle();
|
||||||
result.Add(packageBundle);
|
result.Add(packageBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:缓存资源包索引
|
// 注意:缓存资源包索引
|
||||||
for (int index = 0; index < result.Count; index++)
|
for (int index = 0; index < result.Count; index++)
|
||||||
{
|
{
|
||||||
string bundleName = result[index].BundleName;
|
string bundleName = result[index].BundleName;
|
||||||
_cachedBundleID.Add(bundleName, index);
|
_cachedBundleID.Add(bundleName, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理资源包的依赖集合
|
/// 处理资源包的依赖集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ProcessBundleDepends(BuildContext context, PackageManifest manifest)
|
private void ProcessBundleDepends(BuildContext context, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
||||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||||
List<int> dependIDs = new List<int>(depends.Length);
|
List<int> dependIDs = new List<int>(depends.Length);
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependBundleName in depends)
|
||||||
{
|
{
|
||||||
int bundleID = GetCachedBundleID(dependBundleName);
|
int bundleID = GetCachedBundleID(dependBundleName);
|
||||||
if (bundleID != mainBundleID)
|
if (bundleID != mainBundleID)
|
||||||
dependIDs.Add(bundleID);
|
dependIDs.Add(bundleID);
|
||||||
}
|
}
|
||||||
packageBundle.DependIDs = dependIDs.ToArray();
|
packageBundle.DependIDs = dependIDs.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理资源包的标签集合
|
/// 处理资源包的标签集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ProcessBundleTags(PackageManifest manifest)
|
private void ProcessBundleTags(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||||
foreach (var packageAsset in manifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
var assetTags = packageAsset.AssetTags;
|
var assetTags = packageAsset.AssetTags;
|
||||||
int bundleID = packageAsset.BundleID;
|
int bundleID = packageAsset.BundleID;
|
||||||
CacheBundleTags(bundleID, assetTags);
|
CacheBundleTags(bundleID, assetTags);
|
||||||
|
|
||||||
var packageBundle = manifest.BundleList[bundleID];
|
var packageBundle = manifest.BundleList[bundleID];
|
||||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||||
{
|
{
|
||||||
CacheBundleTags(dependBundleID, assetTags);
|
CacheBundleTags(dependBundleID, assetTags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
{
|
{
|
||||||
var packageBundle = manifest.BundleList[index];
|
var packageBundle = manifest.BundleList[index];
|
||||||
if (_cacheBundleTags.ContainsKey(index))
|
if (_cacheBundleTags.ContainsKey(index))
|
||||||
{
|
{
|
||||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CacheBundleTags(int bundleID, string[] assetTags)
|
private void CacheBundleTags(int bundleID, string[] assetTags)
|
||||||
{
|
{
|
||||||
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
||||||
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||||
|
|
||||||
foreach (var assetTag in assetTags)
|
foreach (var assetTag in assetTags)
|
||||||
{
|
{
|
||||||
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||||
_cacheBundleTags[bundleID].Add(assetTag);
|
_cacheBundleTags[bundleID].Add(assetTag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的索引ID
|
/// 获取资源包的索引ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int GetCachedBundleID(string bundleName)
|
private int GetCachedBundleID(string bundleName)
|
||||||
{
|
{
|
||||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||||
{
|
{
|
||||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,205 +6,205 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateReport
|
public class TaskCreateReport
|
||||||
{
|
{
|
||||||
protected void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
protected void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
||||||
{
|
{
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
PackageManifest manifest = manifestContext.Manifest;
|
PackageManifest manifest = manifestContext.Manifest;
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
|
|
||||||
// 概述信息
|
// 概述信息
|
||||||
{
|
{
|
||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||||
if (packageInfo != null)
|
if (packageInfo != null)
|
||||||
buildReport.Summary.YooVersion = packageInfo.version;
|
buildReport.Summary.YooVersion = packageInfo.version;
|
||||||
#endif
|
#endif
|
||||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||||
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.BuildPackageName = buildParameters.PackageName;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
||||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||||
{
|
{
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||||
}
|
}
|
||||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||||
{
|
{
|
||||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||||
buildReport.Summary.DisableWriteTypeTree = false;
|
buildReport.Summary.DisableWriteTypeTree = false;
|
||||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
||||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
||||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
||||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
||||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源对象列表
|
// 资源对象列表
|
||||||
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
||||||
foreach (var packageAsset in manifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
||||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||||
reportAssetInfo.Address = packageAsset.Address;
|
reportAssetInfo.Address = packageAsset.Address;
|
||||||
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
||||||
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
||||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||||
reportBundleInfo.BundleName = packageBundle.BundleName;
|
reportBundleInfo.BundleName = packageBundle.BundleName;
|
||||||
reportBundleInfo.FileName = packageBundle.FileName;
|
reportBundleInfo.FileName = packageBundle.FileName;
|
||||||
reportBundleInfo.FileHash = packageBundle.FileHash;
|
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||||
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||||
reportBundleInfo.Tags = packageBundle.Tags;
|
reportBundleInfo.Tags = packageBundle.Tags;
|
||||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 冗余资源列表
|
// 冗余资源列表
|
||||||
buildReport.RedundancyInfos = new List<ReportRedundancyInfo>(buildMapContext.RedundancyInfos);
|
buildReport.RedundancyInfos = new List<ReportRedundancyInfo>(buildMapContext.RedundancyInfos);
|
||||||
|
|
||||||
// 序列化文件
|
// 序列化文件
|
||||||
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($"Create build report file: {filePath}");
|
BuildLogger.Log($"Create build report file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源对象依赖的所有资源包
|
/// 获取资源对象依赖的所有资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||||
{
|
{
|
||||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||||
foreach (int index in packageBundle.DependIDs)
|
foreach (int index in packageBundle.DependIDs)
|
||||||
{
|
{
|
||||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
dependBundles.Add(dependBundleName);
|
dependBundles.Add(dependBundleName);
|
||||||
}
|
}
|
||||||
return dependBundles;
|
return dependBundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源对象依赖的其它所有资源
|
/// 获取资源对象依赖的其它所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
{
|
{
|
||||||
BuildAssetInfo findAssetInfo = null;
|
BuildAssetInfo findAssetInfo = null;
|
||||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||||
{
|
{
|
||||||
if (assetInfo.AssetPath == assetPath)
|
if (assetInfo.AssetPath == assetPath)
|
||||||
{
|
{
|
||||||
findAssetInfo = assetInfo;
|
findAssetInfo = assetInfo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (findAssetInfo == null)
|
if (findAssetInfo == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"Should never get here ! 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)
|
||||||
{
|
{
|
||||||
result.Add(dependAssetInfo.AssetPath);
|
result.Add(dependAssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取该资源包内的所有资源
|
/// 获取该资源包内的所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||||
{
|
{
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
return bundleInfo.GetAllBuiltinAssetPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetMainAssetCount(PackageManifest manifest)
|
private int GetMainAssetCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
return manifest.AssetList.Count;
|
return manifest.AssetList.Count;
|
||||||
}
|
}
|
||||||
private int GetAllBundleCount(PackageManifest manifest)
|
private int GetAllBundleCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
return manifest.BundleList.Count;
|
return manifest.BundleList.Count;
|
||||||
}
|
}
|
||||||
private long GetAllBundleSize(PackageManifest manifest)
|
private long GetAllBundleSize(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
fileBytes += packageBundle.FileSize;
|
fileBytes += packageBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
private int GetEncryptedBundleCount(PackageManifest manifest)
|
private int GetEncryptedBundleCount(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
int fileCount = 0;
|
int fileCount = 0;
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (packageBundle.Encrypted)
|
if (packageBundle.Encrypted)
|
||||||
fileCount++;
|
fileCount++;
|
||||||
}
|
}
|
||||||
return fileCount;
|
return fileCount;
|
||||||
}
|
}
|
||||||
private long GetEncryptedBundleSize(PackageManifest manifest)
|
private long GetEncryptedBundleSize(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
long fileBytes = 0;
|
long fileBytes = 0;
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
if (packageBundle.Encrypted)
|
if (packageBundle.Encrypted)
|
||||||
fileBytes += packageBundle.FileSize;
|
fileBytes += packageBundle.FileSize;
|
||||||
}
|
}
|
||||||
return fileBytes;
|
return fileBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,45 +6,45 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption
|
public class TaskEncryption
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密文件
|
/// 加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
public void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||||
if (encryptionServices == null)
|
if (encryptionServices == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||||
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 file encryption complete: {filePath}");
|
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bundleInfo.Encrypted = false;
|
bundleInfo.Encrypted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进度条
|
// 进度条
|
||||||
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,184 +7,184 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskGetBuildMap
|
public class TaskGetBuildMap
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成资源构建上下文
|
/// 生成资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||||
{
|
{
|
||||||
var buildMode = buildParameters.BuildMode;
|
var buildMode = buildParameters.BuildMode;
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
|
|
||||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
||||||
|
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
if (collectAssetInfo.AssetTags.Count > 0)
|
if (collectAssetInfo.AssetTags.Count > 0)
|
||||||
{
|
{
|
||||||
collectAssetInfo.AssetTags.Clear();
|
collectAssetInfo.AssetTags.Clear();
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {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);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"Should never get here !");
|
throw new Exception($"Should never get here !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 录入所有收集资源依赖的其它资源
|
// 4. 录入所有收集资源依赖的其它资源
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
string bundleName = collectAssetInfo.BundleName;
|
string bundleName = collectAssetInfo.BundleName;
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.ContainsKey(dependAssetPath))
|
if (allBuildAssetInfos.ContainsKey(dependAssetPath))
|
||||||
{
|
{
|
||||||
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||||
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 填充所有收集资源的依赖列表
|
// 5. 填充所有收集资源的依赖列表
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
||||||
dependAssetInfos.Add(value);
|
dependAssetInfos.Add(value);
|
||||||
else
|
else
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
}
|
}
|
||||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 自动收集所有依赖的着色器
|
// 6. 自动收集所有依赖的着色器
|
||||||
if (collectResult.Command.AutoCollectShaders)
|
if (collectResult.Command.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
{
|
{
|
||||||
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 记录关键信息
|
// 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;
|
||||||
|
|
||||||
// 8. 记录冗余资源
|
// 8. 记录冗余资源
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
if (buildAssetInfo.IsRedundancyAsset())
|
||||||
{
|
{
|
||||||
var redundancyInfo = new ReportRedundancyInfo();
|
var redundancyInfo = new ReportRedundancyInfo();
|
||||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
||||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
||||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
||||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
||||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
||||||
context.RedundancyInfos.Add(redundancyInfo);
|
context.RedundancyInfos.Add(redundancyInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 移除不参与构建的资源
|
// 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)
|
||||||
{
|
{
|
||||||
if (buildAssetInfo.HasBundleName() == false)
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
removeBuildList.Add(buildAssetInfo);
|
removeBuildList.Add(buildAssetInfo);
|
||||||
}
|
}
|
||||||
foreach (var removeValue in removeBuildList)
|
foreach (var removeValue in removeBuildList)
|
||||||
{
|
{
|
||||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10. 构建资源列表
|
// 10. 构建资源列表
|
||||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||||
if (allPackAssets.Count == 0)
|
if (allPackAssets.Count == 0)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
foreach (var assetInfo in allPackAssets)
|
foreach (var assetInfo in allPackAssets)
|
||||||
{
|
{
|
||||||
context.PackAsset(assetInfo);
|
context.PackAsset(assetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
// 1. 检测是否任何存在依赖资源
|
// 1. 检测是否任何存在依赖资源
|
||||||
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. 获取所有主资源的依赖资源集合
|
// 2. 获取所有主资源的依赖资源集合
|
||||||
HashSet<string> allDependAsset = new HashSet<string>();
|
HashSet<string> allDependAsset = new HashSet<string>();
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||||
{
|
{
|
||||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(dependAsset) == false)
|
if (allDependAsset.Contains(dependAsset) == false)
|
||||||
allDependAsset.Add(dependAsset);
|
allDependAsset.Add(dependAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 找出所有零引用的依赖资源集合
|
// 3. 找出所有零引用的依赖资源集合
|
||||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||||
{
|
{
|
||||||
var collectorType = collectAssetInfo.CollectorType;
|
var collectorType = collectAssetInfo.CollectorType;
|
||||||
if (collectorType == ECollectorType.DependAssetCollector)
|
if (collectorType == ECollectorType.DependAssetCollector)
|
||||||
{
|
{
|
||||||
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
||||||
removeList.Add(collectAssetInfo);
|
removeList.Add(collectAssetInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 移除所有零引用的依赖资源
|
// 4. 移除所有零引用的依赖资源
|
||||||
foreach (var removeValue in removeList)
|
foreach (var removeValue in removeList)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
allCollectAssetInfos.Remove(removeValue);
|
allCollectAssetInfos.Remove(removeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,90 +7,90 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public abstract class TaskUpdateBundleInfo
|
public abstract class TaskUpdateBundleInfo
|
||||||
{
|
{
|
||||||
public void UpdateBundleInfo(BuildContext context)
|
public void UpdateBundleInfo(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
int outputNameStyle = (int)buildParametersContext.Parameters.FileNameStyle;
|
int outputNameStyle = (int)buildParametersContext.Parameters.FileNameStyle;
|
||||||
|
|
||||||
// 1.检测文件名长度
|
// 1.检测文件名长度
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
// NOTE:检测文件名长度不要超过260字符。
|
// NOTE:检测文件名长度不要超过260字符。
|
||||||
string fileName = bundleInfo.BundleName;
|
string fileName = bundleInfo.BundleName;
|
||||||
if (fileName.Length >= 260)
|
if (fileName.Length >= 260)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2.更新构建输出的文件路径
|
// 2.更新构建输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
bundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
bundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
if (bundleInfo.Encrypted)
|
if (bundleInfo.Encrypted)
|
||||||
bundleInfo.PackageSourceFilePath = bundleInfo.EncryptedFilePath;
|
bundleInfo.PackageSourceFilePath = bundleInfo.EncryptedFilePath;
|
||||||
else
|
else
|
||||||
bundleInfo.PackageSourceFilePath = bundleInfo.BuildOutputFilePath;
|
bundleInfo.PackageSourceFilePath = bundleInfo.BuildOutputFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3.更新文件其它信息
|
// 3.更新文件其它信息
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4.更新补丁包输出的文件路径
|
// 4.更新补丁包输出的文件路径
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string bundleName = bundleInfo.BundleName;
|
string bundleName = bundleInfo.BundleName;
|
||||||
string fileHash = bundleInfo.PackageFileHash;
|
string fileHash = bundleInfo.PackageFileHash;
|
||||||
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||||
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||||
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||||
|
|
||||||
protected string GetFilePathTempHash(string filePath)
|
protected string GetFilePathTempHash(string filePath)
|
||||||
{
|
{
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||||
return HashUtility.BytesMD5(bytes);
|
return HashUtility.BytesMD5(bytes);
|
||||||
|
|
||||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||||
}
|
}
|
||||||
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
long tempSize = 0;
|
long tempSize = 0;
|
||||||
|
|
||||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||||
foreach (var assetPath in assetPaths)
|
foreach (var assetPath in assetPaths)
|
||||||
{
|
{
|
||||||
long size = FileUtility.GetFileSize(assetPath);
|
long size = FileUtility.GetFileSize(assetPath);
|
||||||
tempSize += size;
|
tempSize += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempSize == 0)
|
if (tempSize == 0)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
return tempSize;
|
return tempSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,48 +7,48 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskBuilding_BBP : IBuildTask
|
public class TaskBuilding_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
{
|
{
|
||||||
public AssetBundleManifest UnityManifest;
|
public AssetBundleManifest UnityManifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
// 模拟构建模式下跳过引擎构建
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 开始构建
|
// 开始构建
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||||
if (unityManifest == null)
|
if (unityManifest == null)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||||
throw new Exception(message);
|
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)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("UnityEngine build success !");
|
BuildLogger.Log("UnityEngine build success !");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.UnityManifest = unityManifest;
|
buildResultContext.UnityManifest = unityManifest;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,21 +6,21 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,21 +5,21 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
{
|
{
|
||||||
if (_buildResultContext == null)
|
if (_buildResultContext == null)
|
||||||
_buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
_buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||||
|
|
||||||
return _buildResultContext.UnityManifest.GetAllDependencies(bundleName);
|
return _buildResultContext.UnityManifest.GetAllDependencies(bundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,51 +3,51 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreatePackage_BBP : IBuildTask
|
public class TaskCreatePackage_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePackageCatalog(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($"Start making patch package: {packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝UnityManifest序列化文件
|
// 拷贝UnityManifest序列化文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest文本文件
|
// 拷贝UnityManifest文本文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
int fileTotalCount = buildMapContext.Collection.Count;
|
int fileTotalCount = buildMapContext.Collection.Count;
|
||||||
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("Copy patch file", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,18 +6,18 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||||
{
|
{
|
||||||
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 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)
|
||||||
{
|
{
|
||||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,13 +7,13 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,18 +6,18 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskPrepare_BBP : IBuildTask
|
public class TaskPrepare_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测Unity版本
|
// 检测Unity版本
|
||||||
#if UNITY_2021_3_OR_NEWER
|
#if UNITY_2021_3_OR_NEWER
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
|
@ -25,6 +25,6 @@ namespace YooAsset.Editor
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,86 +6,86 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
UpdateBundleInfo(context);
|
UpdateBundleInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var parameters = buildParametersContext.Parameters;
|
||||||
var buildMode = parameters.BuildMode;
|
var buildMode = parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
return "00000000000000000000000000000000"; //32位
|
return "00000000000000000000000000000000"; //32位
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var parameters = buildParametersContext.Parameters;
|
||||||
var buildMode = parameters.BuildMode;
|
var buildMode = parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetBundleTempSize(bundleInfo);
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,66 +8,66 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
// 模拟构建模式下跳过验证
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParameters.VerifyBuildingResult)
|
if (buildParameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||||
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("Build results verify success!");
|
BuildLogger.Log("Build results verify success!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,57 +5,57 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuiltinBuildParameters : BuildParameters
|
public class BuiltinBuildParameters : BuildParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 压缩选项
|
/// 压缩选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool DisableWriteTypeTree = false;
|
public bool DisableWriteTypeTree = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略类型树变化
|
/// 忽略类型树变化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置构建管线的构建选项
|
/// 获取内置构建管线的构建选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildAssetBundleOptions GetBundleBuildOptions()
|
public BuildAssetBundleOptions GetBundleBuildOptions()
|
||||||
{
|
{
|
||||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||||
|
|
||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.DryRunBuild)
|
if (BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CompressOption == ECompressOption.Uncompressed)
|
if (CompressOption == ECompressOption.Uncompressed)
|
||||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||||
else if (CompressOption == ECompressOption.LZ4)
|
else if (CompressOption == ECompressOption.LZ4)
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
if (BuildMode == EBuildMode.ForceRebuild)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
if (IgnoreTypeTreeChanges)
|
if (IgnoreTypeTreeChanges)
|
||||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||||
|
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||||
|
|
||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,33 +4,33 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuiltinBuildPipeline : IBuildPipeline
|
public class BuiltinBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
{
|
{
|
||||||
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 TaskEncryption_BBP(),
|
new TaskEncryption_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,35 +5,35 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskBuilding_RFBP : IBuildTask
|
public class TaskBuilding_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
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)
|
||||||
{
|
{
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝原生文件
|
/// 拷贝原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||||
{
|
{
|
||||||
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,21 +6,21 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,16 +5,16 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
{
|
{
|
||||||
return new string[] { };
|
return new string[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,36 +3,36 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreatePackage_RFBP : IBuildTask
|
public class TaskCreatePackage_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
int fileTotalCount = buildMapContext.Collection.Count;
|
int fileTotalCount = buildMapContext.Collection.Count;
|
||||||
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("Copy patch file", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,32 +7,32 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
CheckBuildMapContent(buildMapContext);
|
CheckBuildMapContent(buildMapContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测资源构建上下文
|
/// 检测资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
// 注意:原生文件资源包只能包含一个原生文件
|
// 注意:原生文件资源包只能包含一个原生文件
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
{
|
{
|
||||||
if (bundleInfo.MainAssets.Count != 1)
|
if (bundleInfo.MainAssets.Count != 1)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"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);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,27 +6,27 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskPrepare_RFBP : IBuildTask
|
public class TaskPrepare_RFBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测不被支持的构建模式
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} 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);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} 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);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,58 +6,58 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
UpdateBundleInfo(context);
|
UpdateBundleInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var parameters = buildParametersContext.Parameters;
|
||||||
var buildMode = parameters.BuildMode;
|
var buildMode = parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
return "00000000000000000000000000000000"; //32位
|
return "00000000000000000000000000000000"; //32位
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetBundleTempSize(bundleInfo);
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class RawFileBuildParameters : BuildParameters
|
public class RawFileBuildParameters : BuildParameters
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,31 +7,31 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class RawFileBuildPipeline : IBuildPipeline
|
public class RawFileBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
{
|
{
|
||||||
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,51 +8,51 @@ using UnityEditor.Build.Pipeline.Tasks;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskBuilding_SBP : IBuildTask
|
public class TaskBuilding_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
{
|
{
|
||||||
public IBundleBuildResults Results;
|
public IBundleBuildResults Results;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
// 模拟构建模式下跳过引擎构建
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 构建内容
|
// 构建内容
|
||||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||||
|
|
||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
||||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建着色器信息
|
// 创建着色器信息
|
||||||
// 说明:解决因为着色器资源包导致验证失败。
|
// 说明:解决因为着色器资源包导致验证失败。
|
||||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||||
{
|
{
|
||||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("UnityEngine build success!");
|
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,21 +6,21 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
{
|
{
|
||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,26 +7,26 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
||||||
{
|
{
|
||||||
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
{
|
{
|
||||||
if (_buildResultContext == null)
|
if (_buildResultContext == null)
|
||||||
_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)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,53 +3,53 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreatePackage_SBP : IBuildTask
|
public class TaskCreatePackage_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CreatePackageCatalog(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($"Start making patch package: {packageOutputDirectory}");
|
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||||
|
|
||||||
// 拷贝构建日志
|
// 拷贝构建日志
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/buildlogtep.json";
|
string sourcePath = $"{pipelineOutputDirectory}/buildlogtep.json";
|
||||||
string destPath = $"{packageOutputDirectory}/buildlogtep.json";
|
string destPath = $"{packageOutputDirectory}/buildlogtep.json";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝代码防裁剪配置
|
// 拷贝代码防裁剪配置
|
||||||
if (scriptableBuildParameters.WriteLinkXML)
|
if (scriptableBuildParameters.WriteLinkXML)
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/link.xml";
|
string sourcePath = $"{pipelineOutputDirectory}/link.xml";
|
||||||
string destPath = $"{packageOutputDirectory}/link.xml";
|
string destPath = $"{packageOutputDirectory}/link.xml";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
int fileTotalCount = buildMapContext.Collection.Count;
|
int fileTotalCount = buildMapContext.Collection.Count;
|
||||||
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("Copy patch file", ++progressValue, fileTotalCount);
|
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
||||||
{
|
{
|
||||||
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 buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
if (buildMode != EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,18 +6,18 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||||
{
|
{
|
||||||
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 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)
|
||||||
{
|
{
|
||||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,13 +7,13 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,27 +6,27 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskPrepare_SBP : IBuildTask
|
public class TaskPrepare_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测不被支持的构建模式
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{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);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{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);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,86 +6,86 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
UpdateBundleInfo(context);
|
UpdateBundleInfo(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var parameters = buildParametersContext.Parameters;
|
||||||
var buildMode = parameters.BuildMode;
|
var buildMode = parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
return "00000000000000000000000000000000"; //32位
|
return "00000000000000000000000000000000"; //32位
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:当资源包的依赖列表发生变化的时候,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
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var parameters = buildParametersContext.Parameters;
|
var parameters = buildParametersContext.Parameters;
|
||||||
var buildMode = parameters.BuildMode;
|
var buildMode = parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetFilePathTempHash(filePath);
|
return GetFilePathTempHash(filePath);
|
||||||
else
|
else
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return "00000000"; //8位
|
return "00000000"; //8位
|
||||||
else
|
else
|
||||||
return HashUtility.FileCRC32(filePath);
|
return HashUtility.FileCRC32(filePath);
|
||||||
}
|
}
|
||||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
if (buildMode == EBuildMode.SimulateBuild)
|
||||||
return GetBundleTempSize(bundleInfo);
|
return GetBundleTempSize(bundleInfo);
|
||||||
else
|
else
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,66 +9,66 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
// 模拟构建模式下跳过验证
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParameters.VerifyBuildingResult)
|
if (buildParameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
VerifyingBuildingResult(context, buildResultContext.Results);
|
VerifyingBuildingResult(context, buildResultContext.Results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 过滤掉原生Bundle
|
||||||
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证Bundle
|
||||||
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList1)
|
foreach (var exceptBundle in exceptBundleList1)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
// 3. 验证Bundle
|
||||||
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var exceptBundle in exceptBundleList2)
|
foreach (var exceptBundle in exceptBundleList2)
|
||||||
{
|
{
|
||||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||||
BuildLogger.Warning(warning);
|
BuildLogger.Warning(warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
throw new Exception(exception);
|
throw new Exception(exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildLogger.Log("Build results verify success!");
|
BuildLogger.Log("Build results verify success!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,46 +7,46 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace UnityEditor.Build.Pipeline.Tasks
|
namespace UnityEditor.Build.Pipeline.Tasks
|
||||||
{
|
{
|
||||||
public static class SBPBuildTasks
|
public static class SBPBuildTasks
|
||||||
{
|
{
|
||||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
||||||
{
|
{
|
||||||
var buildTasks = new List<IBuildTask>();
|
var buildTasks = new List<IBuildTask>();
|
||||||
|
|
||||||
// Setup
|
|
||||||
buildTasks.Add(new SwitchToBuildPlatform());
|
|
||||||
buildTasks.Add(new RebuildSpriteAtlasCache());
|
|
||||||
|
|
||||||
// Player Scripts
|
// Setup
|
||||||
buildTasks.Add(new BuildPlayerScripts());
|
buildTasks.Add(new SwitchToBuildPlatform());
|
||||||
buildTasks.Add(new PostScriptsCallback());
|
buildTasks.Add(new RebuildSpriteAtlasCache());
|
||||||
|
|
||||||
// Dependency
|
// Player Scripts
|
||||||
buildTasks.Add(new CalculateSceneDependencyData());
|
buildTasks.Add(new BuildPlayerScripts());
|
||||||
|
buildTasks.Add(new PostScriptsCallback());
|
||||||
|
|
||||||
|
// Dependency
|
||||||
|
buildTasks.Add(new CalculateSceneDependencyData());
|
||||||
#if UNITY_2019_3_OR_NEWER
|
#if UNITY_2019_3_OR_NEWER
|
||||||
buildTasks.Add(new CalculateCustomDependencyData());
|
buildTasks.Add(new CalculateCustomDependencyData());
|
||||||
#endif
|
#endif
|
||||||
buildTasks.Add(new CalculateAssetDependencyData());
|
buildTasks.Add(new CalculateAssetDependencyData());
|
||||||
buildTasks.Add(new StripUnusedSpriteSources());
|
buildTasks.Add(new StripUnusedSpriteSources());
|
||||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||||
buildTasks.Add(new PostDependencyCallback());
|
buildTasks.Add(new PostDependencyCallback());
|
||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
buildTasks.Add(new GenerateBundlePacking());
|
buildTasks.Add(new GenerateBundlePacking());
|
||||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||||
buildTasks.Add(new GenerateBundleCommands());
|
buildTasks.Add(new GenerateBundleCommands());
|
||||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||||
buildTasks.Add(new GenerateBundleMaps());
|
buildTasks.Add(new GenerateBundleMaps());
|
||||||
buildTasks.Add(new PostPackingCallback());
|
buildTasks.Add(new PostPackingCallback());
|
||||||
|
|
||||||
// Writing
|
// Writing
|
||||||
buildTasks.Add(new WriteSerializedFiles());
|
buildTasks.Add(new WriteSerializedFiles());
|
||||||
buildTasks.Add(new ArchiveAndCompressBundles());
|
buildTasks.Add(new ArchiveAndCompressBundles());
|
||||||
buildTasks.Add(new AppendBundleHash());
|
buildTasks.Add(new AppendBundleHash());
|
||||||
buildTasks.Add(new GenerateLinkXml());
|
buildTasks.Add(new GenerateLinkXml());
|
||||||
buildTasks.Add(new PostWritingCallback());
|
buildTasks.Add(new PostWritingCallback());
|
||||||
|
|
||||||
return buildTasks;
|
return buildTasks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,67 +7,67 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class ScriptableBuildParameters : BuildParameters
|
public class ScriptableBuildParameters : BuildParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 压缩选项
|
/// 压缩选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool DisableWriteTypeTree = false;
|
public bool DisableWriteTypeTree = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略类型树变化
|
/// 忽略类型树变化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreTypeTreeChanges = true;
|
public bool IgnoreTypeTreeChanges = true;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成代码防裁剪配置
|
/// 生成代码防裁剪配置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool WriteLinkXML = true;
|
public bool WriteLinkXML = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存服务器地址
|
/// 缓存服务器地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CacheServerHost;
|
public string CacheServerHost;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 缓存服务器端口
|
/// 缓存服务器端口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CacheServerPort;
|
public int CacheServerPort;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取可编程构建管线的构建参数
|
/// 获取可编程构建管线的构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BundleBuildParameters GetBundleBuildParameters()
|
public BundleBuildParameters GetBundleBuildParameters()
|
||||||
{
|
{
|
||||||
var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(BuildTarget);
|
var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(BuildTarget);
|
||||||
var pipelineOutputDirectory = GetPipelineOutputDirectory();
|
var pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||||
var buildParams = new BundleBuildParameters(BuildTarget, targetGroup, pipelineOutputDirectory);
|
var buildParams = new BundleBuildParameters(BuildTarget, targetGroup, pipelineOutputDirectory);
|
||||||
|
|
||||||
if (CompressOption == ECompressOption.Uncompressed)
|
if (CompressOption == ECompressOption.Uncompressed)
|
||||||
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||||
else if (CompressOption == ECompressOption.LZMA)
|
else if (CompressOption == ECompressOption.LZMA)
|
||||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
||||||
else if (CompressOption == ECompressOption.LZ4)
|
else if (CompressOption == ECompressOption.LZ4)
|
||||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
||||||
else
|
else
|
||||||
throw new System.NotImplementedException(CompressOption.ToString());
|
throw new System.NotImplementedException(CompressOption.ToString());
|
||||||
|
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||||
|
|
||||||
buildParams.UseCache = true;
|
buildParams.UseCache = true;
|
||||||
buildParams.CacheServerHost = CacheServerHost;
|
buildParams.CacheServerHost = CacheServerHost;
|
||||||
buildParams.CacheServerPort = CacheServerPort;
|
buildParams.CacheServerPort = CacheServerPort;
|
||||||
buildParams.WriteLinkXML = WriteLinkXML;
|
buildParams.WriteLinkXML = WriteLinkXML;
|
||||||
|
|
||||||
return buildParams;
|
return buildParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,33 +4,33 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class ScriptableBuildPipeline : IBuildPipeline
|
public class ScriptableBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
{
|
{
|
||||||
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 TaskEncryption_SBP(),
|
new TaskEncryption_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,47 +4,47 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildContext
|
public class BuildContext
|
||||||
{
|
{
|
||||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有情景对象
|
/// 清空所有情景对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearAllContext()
|
public void ClearAllContext()
|
||||||
{
|
{
|
||||||
_contextObjects.Clear();
|
_contextObjects.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置情景对象
|
/// 设置情景对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetContextObject(IContextObject contextObject)
|
public void SetContextObject(IContextObject contextObject)
|
||||||
{
|
{
|
||||||
if (contextObject == null)
|
if (contextObject == null)
|
||||||
throw new ArgumentNullException("contextObject");
|
throw new ArgumentNullException("contextObject");
|
||||||
|
|
||||||
var type = contextObject.GetType();
|
var type = contextObject.GetType();
|
||||||
if (_contextObjects.ContainsKey(type))
|
if (_contextObjects.ContainsKey(type))
|
||||||
throw new Exception($"Context object {type} is already existed.");
|
throw new Exception($"Context object {type} is already existed.");
|
||||||
|
|
||||||
_contextObjects.Add(type, contextObject);
|
_contextObjects.Add(type, contextObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取情景对象
|
/// 获取情景对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T GetContextObject<T>() where T : IContextObject
|
public T GetContextObject<T>() where T : IContextObject
|
||||||
{
|
{
|
||||||
var type = typeof(T);
|
var type = typeof(T);
|
||||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||||
{
|
{
|
||||||
return (T)contextObject;
|
return (T)contextObject;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found context object : {type}");
|
throw new Exception($"Not found context object : {type}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,34 +5,34 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal static class BuildLogger
|
internal static class BuildLogger
|
||||||
{
|
{
|
||||||
private static bool _enableLog = true;
|
private static bool _enableLog = true;
|
||||||
|
|
||||||
public static void InitLogger(bool enableLog)
|
public static void InitLogger(bool enableLog)
|
||||||
{
|
{
|
||||||
_enableLog = enableLog;
|
_enableLog = enableLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Log(string message)
|
public static void Log(string message)
|
||||||
{
|
{
|
||||||
if (_enableLog)
|
if (_enableLog)
|
||||||
{
|
{
|
||||||
Debug.Log(message);
|
Debug.Log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Warning(string message)
|
public static void Warning(string message)
|
||||||
{
|
{
|
||||||
Debug.LogWarning(message);
|
Debug.LogWarning(message);
|
||||||
}
|
}
|
||||||
public static void Error(string message)
|
public static void Error(string message)
|
||||||
{
|
{
|
||||||
Debug.LogError(message);
|
Debug.LogError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetErrorMessage(ErrorCode code, string message)
|
public static string GetErrorMessage(ErrorCode code, string message)
|
||||||
{
|
{
|
||||||
return $"[ErrorCode{(int)code}] {message}";
|
return $"[ErrorCode{(int)code}] {message}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,64 +7,64 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class BuildRunner
|
public class BuildRunner
|
||||||
{
|
{
|
||||||
private static Stopwatch _buildWatch;
|
private static Stopwatch _buildWatch;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 总耗时
|
/// 总耗时
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int TotalSeconds = 0;
|
public static int TotalSeconds = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行构建流程
|
/// 执行构建流程
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>如果成功返回TRUE,否则返回FALSE</returns>
|
/// <returns>如果成功返回TRUE,否则返回FALSE</returns>
|
||||||
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
|
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
|
||||||
{
|
{
|
||||||
if (pipeline == null)
|
if (pipeline == null)
|
||||||
throw new ArgumentNullException("pipeline");
|
throw new ArgumentNullException("pipeline");
|
||||||
if (context == null)
|
if (context == null)
|
||||||
throw new ArgumentNullException("context");
|
throw new ArgumentNullException("context");
|
||||||
|
|
||||||
BuildResult buildResult = new BuildResult();
|
BuildResult buildResult = new BuildResult();
|
||||||
buildResult.Success = true;
|
buildResult.Success = true;
|
||||||
TotalSeconds = 0;
|
TotalSeconds = 0;
|
||||||
for (int i = 0; i < pipeline.Count; i++)
|
for (int i = 0; i < pipeline.Count; i++)
|
||||||
{
|
{
|
||||||
IBuildTask task = pipeline[i];
|
IBuildTask task = pipeline[i];
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_buildWatch = Stopwatch.StartNew();
|
_buildWatch = Stopwatch.StartNew();
|
||||||
string taskName = task.GetType().Name.Split('_')[0];
|
string taskName = task.GetType().Name.Split('_')[0];
|
||||||
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
||||||
task.Run(context);
|
task.Run(context);
|
||||||
_buildWatch.Stop();
|
_buildWatch.Stop();
|
||||||
|
|
||||||
// 统计耗时
|
// 统计耗时
|
||||||
int seconds = GetBuildSeconds();
|
int seconds = GetBuildSeconds();
|
||||||
TotalSeconds += seconds;
|
TotalSeconds += seconds;
|
||||||
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
buildResult.FailedTask = task.GetType().Name;
|
buildResult.FailedTask = task.GetType().Name;
|
||||||
buildResult.ErrorInfo = e.ToString();
|
buildResult.ErrorInfo = e.ToString();
|
||||||
buildResult.Success = false;
|
buildResult.Success = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回运行结果
|
// 返回运行结果
|
||||||
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetBuildSeconds()
|
private static int GetBuildSeconds()
|
||||||
{
|
{
|
||||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||||
return (int)seconds;
|
return (int)seconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,42 +1,42 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal enum ErrorCode
|
internal enum ErrorCode
|
||||||
{
|
{
|
||||||
// TaskPrepare
|
// TaskPrepare
|
||||||
ThePipelineIsBuiding = 100,
|
ThePipelineIsBuiding = 100,
|
||||||
FoundUnsavedScene = 101,
|
FoundUnsavedScene = 101,
|
||||||
NoBuildTarget = 110,
|
NoBuildTarget = 110,
|
||||||
PackageNameIsNullOrEmpty = 111,
|
PackageNameIsNullOrEmpty = 111,
|
||||||
PackageVersionIsNullOrEmpty = 112,
|
PackageVersionIsNullOrEmpty = 112,
|
||||||
BuildOutputRootIsNullOrEmpty = 113,
|
BuildOutputRootIsNullOrEmpty = 113,
|
||||||
BuildinFileRootIsNullOrEmpty = 114,
|
BuildinFileRootIsNullOrEmpty = 114,
|
||||||
PackageOutputDirectoryExists = 115,
|
PackageOutputDirectoryExists = 115,
|
||||||
RecommendScriptBuildPipeline = 130,
|
RecommendScriptBuildPipeline = 130,
|
||||||
BuildPipelineNotSupportBuildMode = 140,
|
BuildPipelineNotSupportBuildMode = 140,
|
||||||
|
|
||||||
// TaskGetBuildMap
|
// TaskGetBuildMap
|
||||||
RemoveInvalidTags = 200,
|
RemoveInvalidTags = 200,
|
||||||
FoundUndependedAsset = 201,
|
FoundUndependedAsset = 201,
|
||||||
PackAssetListIsEmpty = 202,
|
PackAssetListIsEmpty = 202,
|
||||||
NotSupportMultipleRawAsset = 210,
|
NotSupportMultipleRawAsset = 210,
|
||||||
|
|
||||||
// TaskBuilding
|
// TaskBuilding
|
||||||
UnityEngineBuildFailed = 300,
|
UnityEngineBuildFailed = 300,
|
||||||
UnityEngineBuildFatal = 301,
|
UnityEngineBuildFatal = 301,
|
||||||
|
|
||||||
// TaskUpdateBundleInfo
|
// TaskUpdateBundleInfo
|
||||||
CharactersOverTheLimit = 400,
|
CharactersOverTheLimit = 400,
|
||||||
NotFoundUnityBundleHash = 401,
|
NotFoundUnityBundleHash = 401,
|
||||||
NotFoundUnityBundleCRC = 402,
|
NotFoundUnityBundleCRC = 402,
|
||||||
BundleTempSizeIsZero = 403,
|
BundleTempSizeIsZero = 403,
|
||||||
|
|
||||||
// TaskVerifyBuildResult
|
|
||||||
UnintendedBuildBundle = 500,
|
|
||||||
UnintendedBuildResult = 501,
|
|
||||||
|
|
||||||
// TaskCreateManifest
|
// TaskVerifyBuildResult
|
||||||
NotFoundUnityBundleInBuildResult = 600,
|
UnintendedBuildBundle = 500,
|
||||||
FoundStrayBundle = 601,
|
UnintendedBuildResult = 501,
|
||||||
}
|
|
||||||
|
// TaskCreateManifest
|
||||||
|
NotFoundUnityBundleInBuildResult = 600,
|
||||||
|
FoundStrayBundle = 601,
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public interface IContextObject
|
public interface IContextObject
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class EncryptionNone : IEncryptionServices
|
public class EncryptionNone : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,29 +1,29 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包流水线的构建模式
|
/// 资源包流水线的构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EBuildMode
|
public enum EBuildMode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 强制重建模式
|
/// 强制重建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ForceRebuild,
|
ForceRebuild,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 增量构建模式
|
/// 增量构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IncrementalBuild,
|
IncrementalBuild,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 演练构建模式
|
/// 演练构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DryRunBuild,
|
DryRunBuild,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模拟构建模式
|
/// 模拟构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SimulateBuild,
|
SimulateBuild,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,24 +1,24 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建管线类型
|
/// 构建管线类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EBuildPipeline
|
public enum EBuildPipeline
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传统内置构建管线 (BBP)
|
/// 传统内置构建管线 (BBP)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BuiltinBuildPipeline,
|
BuiltinBuildPipeline,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 可编程构建管线 (SBP)
|
|
||||||
/// </summary>
|
|
||||||
ScriptableBuildPipeline,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原生文件构建管线 (RFBP)
|
/// 可编程构建管线 (SBP)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
RawFileBuildPipeline,
|
ScriptableBuildPipeline,
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件构建管线 (RFBP)
|
||||||
|
/// </summary>
|
||||||
|
RawFileBuildPipeline,
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,34 +1,34 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 首包资源文件的拷贝方式
|
/// 首包资源文件的拷贝方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EBuildinFileCopyOption
|
public enum EBuildinFileCopyOption
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不拷贝任何文件
|
/// 不拷贝任何文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 先清空已有文件,然后拷贝所有文件
|
/// 先清空已有文件,然后拷贝所有文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearAndCopyAll,
|
ClearAndCopyAll,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 先清空已有文件,然后按照资源标签拷贝文件
|
/// 先清空已有文件,然后按照资源标签拷贝文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearAndCopyByTags,
|
ClearAndCopyByTags,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不清空已有文件,直接拷贝所有文件
|
/// 不清空已有文件,直接拷贝所有文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OnlyCopyAll,
|
OnlyCopyAll,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 不清空已有文件,直接按照资源标签拷贝文件
|
/// 不清空已有文件,直接按照资源标签拷贝文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OnlyCopyByTags,
|
OnlyCopyByTags,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AssetBundle压缩选项
|
/// AssetBundle压缩选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum ECompressOption
|
public enum ECompressOption
|
||||||
{
|
{
|
||||||
Uncompressed = 0,
|
Uncompressed = 0,
|
||||||
LZMA,
|
LZMA,
|
||||||
LZ4,
|
LZ4,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,24 +1,24 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 补丁包内的文件样式
|
/// 补丁包内的文件样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EFileNameStyle
|
public enum EFileNameStyle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 哈希值名称
|
/// 哈希值名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
HashName = 0,
|
HashName = 0,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称(不推荐)
|
/// 资源包名称(不推荐)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleName = 1,
|
BundleName = 1,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称 + 哈希值名称
|
/// 资源包名称 + 哈希值名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleName_HashName = 2,
|
BundleName_HashName = 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public interface IBuildPipeline
|
public interface IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,201 +10,201 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal abstract class BuildPipelineViewerBase
|
internal abstract class BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
private const int StyleWidth = 400;
|
private const int StyleWidth = 400;
|
||||||
|
|
||||||
protected readonly string PackageName;
|
protected readonly string PackageName;
|
||||||
protected readonly BuildTarget BuildTarget;
|
protected readonly BuildTarget BuildTarget;
|
||||||
protected readonly EBuildPipeline BuildPipeline;
|
protected readonly EBuildPipeline BuildPipeline;
|
||||||
protected TemplateContainer Root;
|
protected TemplateContainer Root;
|
||||||
|
|
||||||
private TextField _buildOutputField;
|
private TextField _buildOutputField;
|
||||||
private TextField _buildVersionField;
|
private TextField _buildVersionField;
|
||||||
private PopupField<Enum> _buildModeField;
|
private PopupField<Enum> _buildModeField;
|
||||||
private PopupField<Type> _encryptionField;
|
private PopupField<Type> _encryptionField;
|
||||||
private EnumField _compressionField;
|
private EnumField _compressionField;
|
||||||
private EnumField _outputNameStyleField;
|
private EnumField _outputNameStyleField;
|
||||||
private EnumField _copyBuildinFileOptionField;
|
private EnumField _copyBuildinFileOptionField;
|
||||||
private TextField _copyBuildinFileTagsField;
|
private TextField _copyBuildinFileTagsField;
|
||||||
|
|
||||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
BuildTarget = buildTarget;
|
BuildTarget = buildTarget;
|
||||||
BuildPipeline = buildPipeline;
|
BuildPipeline = buildPipeline;
|
||||||
|
|
||||||
CreateView(parent);
|
CreateView(parent);
|
||||||
RefreshView();
|
RefreshView();
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
Root = visualAsset.CloneTree();
|
Root = visualAsset.CloneTree();
|
||||||
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 = "Build Mode";
|
_buildModeField.label = "Build Mode";
|
||||||
_buildModeField.style.width = StyleWidth;
|
_buildModeField.style.width = StyleWidth;
|
||||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSetting.SetPackageBuildMode(PackageName, BuildPipeline, (EBuildMode)_buildModeField.value);
|
AssetBundleBuilderSetting.SetPackageBuildMode(PackageName, BuildPipeline, (EBuildMode)_buildModeField.value);
|
||||||
});
|
});
|
||||||
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));
|
||||||
if (encryptionClassTypes.Count > 0)
|
if (encryptionClassTypes.Count > 0)
|
||||||
{
|
{
|
||||||
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 = "Encryption";
|
||||||
_encryptionField.style.width = StyleWidth;
|
_encryptionField.style.width = StyleWidth;
|
||||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSetting.SetPackageEncyptionClassName(PackageName, BuildPipeline, _encryptionField.value.FullName);
|
AssetBundleBuilderSetting.SetPackageEncyptionClassName(PackageName, BuildPipeline, _encryptionField.value.FullName);
|
||||||
});
|
});
|
||||||
encryptionContainer.Add(_encryptionField);
|
encryptionContainer.Add(_encryptionField);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_encryptionField = new PopupField<Type>();
|
_encryptionField = new PopupField<Type>();
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "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);
|
||||||
_compressionField.SetValueWithoutNotify(compressOption);
|
_compressionField.SetValueWithoutNotify(compressOption);
|
||||||
_compressionField.style.width = StyleWidth;
|
_compressionField.style.width = StyleWidth;
|
||||||
_compressionField.RegisterValueChangedCallback(evt =>
|
_compressionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
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);
|
||||||
_outputNameStyleField.SetValueWithoutNotify(fileNameStyle);
|
_outputNameStyleField.SetValueWithoutNotify(fileNameStyle);
|
||||||
_outputNameStyleField.style.width = StyleWidth;
|
_outputNameStyleField.style.width = StyleWidth;
|
||||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
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);
|
||||||
_copyBuildinFileOptionField.SetValueWithoutNotify(buildinFileCopyOption);
|
_copyBuildinFileOptionField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||||
_copyBuildinFileOptionField.style.width = StyleWidth;
|
_copyBuildinFileOptionField.style.width = StyleWidth;
|
||||||
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, BuildPipeline, (EBuildinFileCopyOption)_copyBuildinFileOptionField.value);
|
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, BuildPipeline, (EBuildinFileCopyOption)_copyBuildinFileOptionField.value);
|
||||||
RefreshView();
|
RefreshView();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 首包文件拷贝参数
|
// 首包文件拷贝参数
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
private void RefreshView()
|
private void RefreshView()
|
||||||
{
|
{
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
bool tagsFiledVisible = buildinFileCopyOption == EBuildinFileCopyOption.ClearAndCopyByTags || buildinFileCopyOption == EBuildinFileCopyOption.OnlyCopyByTags;
|
bool tagsFiledVisible = buildinFileCopyOption == EBuildinFileCopyOption.ClearAndCopyByTags || buildinFileCopyOption == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||||
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
||||||
}
|
}
|
||||||
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()
|
||||||
{
|
{
|
||||||
return _buildVersionField.value;
|
return _buildVersionField.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建加密类实例
|
/// 创建加密类实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IEncryptionServices CreateEncryptionInstance()
|
protected IEncryptionServices CreateEncryptionInstance()
|
||||||
{
|
{
|
||||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||||
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
||||||
if (classType != null)
|
if (classType != null)
|
||||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDefaultPackageVersion()
|
private string GetDefaultPackageVersion()
|
||||||
{
|
{
|
||||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -10,54 +10,54 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||||
: base(packageName, EBuildPipeline.BuiltinBuildPipeline, buildTarget, parent)
|
: base(packageName, EBuildPipeline.BuiltinBuildPipeline, buildTarget, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ö´Ğй¹½¨
|
/// Ö´Ğй¹½¨
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
|
|
||||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildMode = buildMode;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
|
|
||||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
protected override List<Enum> GetSupportBuildModes()
|
||||||
{
|
{
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
List<Enum> buildModeList = new List<Enum>();
|
||||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||||
buildModeList.Add(EBuildMode.DryRunBuild);
|
buildModeList.Add(EBuildMode.DryRunBuild);
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||||
return buildModeList;
|
return buildModeList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -10,52 +10,52 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||||
{
|
{
|
||||||
var compressionField = Root.Q<EnumField>("Compression");
|
var compressionField = Root.Q<EnumField>("Compression");
|
||||||
UIElementsTools.SetElementVisible(compressionField, false);
|
UIElementsTools.SetElementVisible(compressionField, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ö´Ğй¹½¨
|
/// Ö´Ğй¹½¨
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
|
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildMode = buildMode;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
protected override List<Enum> GetSupportBuildModes()
|
||||||
{
|
{
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
List<Enum> buildModeList = new List<Enum>();
|
||||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||||
return buildModeList;
|
return buildModeList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -10,52 +10,52 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
public ScriptableBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
public ScriptableBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||||
: base(packageName, EBuildPipeline.ScriptableBuildPipeline, buildTarget, parent)
|
: base(packageName, EBuildPipeline.ScriptableBuildPipeline, buildTarget, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行构建
|
/// 执行构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
buildParameters.BuildMode = buildMode;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
protected override List<Enum> GetSupportBuildModes()
|
||||||
{
|
{
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
List<Enum> buildModeList = new List<Enum>();
|
||||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||||
return buildModeList;
|
return buildModeList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -6,316 +6,316 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AssetBundleCollector
|
public class AssetBundleCollector
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集路径
|
/// 收集路径
|
||||||
/// 注意:支持文件夹或单个资源文件
|
/// 注意:支持文件夹或单个资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CollectPath = string.Empty;
|
public string CollectPath = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器的GUID
|
/// 收集器的GUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CollectorGUID = string.Empty;
|
public string CollectorGUID = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器类型
|
/// 收集器类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 寻址规则类名
|
/// 寻址规则类名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AddressRuleName = nameof(AddressByFileName);
|
public string AddressRuleName = nameof(AddressByFileName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打包规则类名
|
/// 打包规则类名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackRuleName = nameof(PackDirectory);
|
public string PackRuleName = nameof(PackDirectory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 过滤规则类名
|
/// 过滤规则类名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FilterRuleName = nameof(CollectAll);
|
public string FilterRuleName = nameof(CollectAll);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户自定义数据
|
/// 用户自定义数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string UserData = string.Empty;
|
public string UserData = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器是否有效
|
/// 收集器是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsValid()
|
public bool IsValid()
|
||||||
{
|
{
|
||||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测配置错误
|
/// 检测配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||||
if (string.IsNullOrEmpty(assetGUID))
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
throw new Exception($"Invalid collect path : {CollectPath}");
|
throw new Exception($"Invalid collect path : {CollectPath}");
|
||||||
|
|
||||||
if (CollectorType == ECollectorType.None)
|
if (CollectorType == ECollectorType.None)
|
||||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||||
|
|
||||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修复配置错误
|
/// 修复配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FixConfigError()
|
public bool FixConfigError()
|
||||||
{
|
{
|
||||||
bool isFixed = false;
|
bool isFixed = false;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
||||||
{
|
{
|
||||||
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
||||||
if (string.IsNullOrEmpty(convertAssetPath))
|
if (string.IsNullOrEmpty(convertAssetPath))
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
||||||
CollectorGUID = string.Empty;
|
CollectorGUID = string.Empty;
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CollectPath != convertAssetPath)
|
if (CollectPath != convertAssetPath)
|
||||||
{
|
{
|
||||||
CollectPath = convertAssetPath;
|
CollectPath = convertAssetPath;
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||||
if(string.IsNullOrEmpty(convertGUID) == false)
|
if(string.IsNullOrEmpty(convertGUID) == false)
|
||||||
{
|
{
|
||||||
CollectorGUID = convertGUID;
|
CollectorGUID = convertGUID;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return isFixed;
|
return isFixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
// 注意:模拟构建模式下只收集主资源
|
// 注意:模拟构建模式下只收集主资源
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||||
{
|
{
|
||||||
string collectDirectory = CollectPath;
|
string collectDirectory = CollectPath;
|
||||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||||
foreach (string assetPath in findAssets)
|
foreach (string assetPath in findAssets)
|
||||||
{
|
{
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||||
{
|
{
|
||||||
if (result.ContainsKey(assetPath) == false)
|
if (result.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
|
throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string assetPath = CollectPath;
|
string assetPath = CollectPath;
|
||||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||||
{
|
{
|
||||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
var addressTemper = new Dictionary<string, string>();
|
var addressTemper = new Dictionary<string, string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
||||||
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
||||||
|
|
||||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||||
addressTemper.Add(address, assetPath);
|
addressTemper.Add(address, assetPath);
|
||||||
else
|
else
|
||||||
throw new Exception($"The address is existed : {address} in collector : {CollectPath} \nAssetPath:\n {existed}\n {assetPath}");
|
throw new Exception($"The address is existed : {address} in collector : {CollectPath} \nAssetPath:\n {existed}\n {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回列表
|
// 返回列表
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
string address = GetAddress(command, group, assetPath);
|
string address = GetAddress(command, group, assetPath);
|
||||||
string bundleName = GetBundleName(command, group, assetPath);
|
string bundleName = GetBundleName(command, group, assetPath);
|
||||||
List<string> assetTags = GetAssetTags(group);
|
List<string> assetTags = GetAssetTags(group);
|
||||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
|
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
|
||||||
|
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
collectAssetInfo.DependAssets = new List<string>();
|
||||||
else
|
else
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
||||||
|
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
}
|
}
|
||||||
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
||||||
{
|
{
|
||||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 忽略文件夹
|
// 忽略文件夹
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
if (AssetDatabase.IsValidFolder(assetPath))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略编辑器下的类型资源
|
// 忽略编辑器下的类型资源
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(LightingDataAsset))
|
if (assetType == typeof(LightingDataAsset))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// 忽略Unity引擎无法识别的文件
|
// 忽略Unity引擎无法识别的文件
|
||||||
if (command.IgnoreDefaultType)
|
if (command.IgnoreDefaultType)
|
||||||
{
|
{
|
||||||
if (assetType == typeof(UnityEditor.DefaultAsset))
|
if (assetType == typeof(UnityEditor.DefaultAsset))
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
||||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
}
|
}
|
||||||
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
if (command.EnableAddressable == false)
|
if (command.EnableAddressable == false)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
return adressValue;
|
return adressValue;
|
||||||
}
|
}
|
||||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||||
{
|
{
|
||||||
if (command.AutoCollectShaders)
|
if (command.AutoCollectShaders)
|
||||||
{
|
{
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||||
{
|
{
|
||||||
// 获取着色器打包规则结果
|
// 获取着色器打包规则结果
|
||||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取其它资源打包规则结果
|
// 获取其它资源打包规则结果
|
||||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||||
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||||
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
||||||
tags.AddRange(temper);
|
tags.AddRange(temper);
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||||
{
|
{
|
||||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||||
List<string> result = new List<string>(depends.Length);
|
List<string> result = new List<string>(depends.Length);
|
||||||
foreach (string assetPath in depends)
|
foreach (string assetPath in depends)
|
||||||
{
|
{
|
||||||
// 注意:排除主资源对象
|
// 注意:排除主资源对象
|
||||||
if (assetPath == mainAssetPath)
|
if (assetPath == mainAssetPath)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (IsValidateAsset(command, assetPath))
|
if (IsValidateAsset(command, assetPath))
|
||||||
result.Add(assetPath);
|
result.Add(assetPath);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,257 +8,257 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "v2.0.0";
|
public const string ConfigVersion = "v2.0.0";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
|
|
||||||
public const string XmlShowPackageView = "ShowPackageView";
|
public const string XmlShowPackageView = "ShowPackageView";
|
||||||
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
||||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||||
|
|
||||||
public const string XmlPackage = "Package";
|
public const string XmlPackage = "Package";
|
||||||
public const string XmlPackageName = "PackageName";
|
public const string XmlPackageName = "PackageName";
|
||||||
public const string XmlPackageDesc = "PackageDesc";
|
public const string XmlPackageDesc = "PackageDesc";
|
||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
public const string XmlLocationToLower = "LocationToLower";
|
public const string XmlLocationToLower = "LocationToLower";
|
||||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
||||||
|
|
||||||
public const string XmlGroup = "Group";
|
public const string XmlGroup = "Group";
|
||||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||||
public const string XmlGroupName = "GroupName";
|
public const string XmlGroupName = "GroupName";
|
||||||
public const string XmlGroupDesc = "GroupDesc";
|
public const string XmlGroupDesc = "GroupDesc";
|
||||||
|
|
||||||
public const string XmlCollector = "Collector";
|
public const string XmlCollector = "Collector";
|
||||||
public const string XmlCollectPath = "CollectPath";
|
public const string XmlCollectPath = "CollectPath";
|
||||||
public const string XmlCollectorGUID = "CollectGUID";
|
public const string XmlCollectorGUID = "CollectGUID";
|
||||||
public const string XmlCollectorType = "CollectType";
|
public const string XmlCollectorType = "CollectType";
|
||||||
public const string XmlAddressRule = "AddressRule";
|
public const string XmlAddressRule = "AddressRule";
|
||||||
public const string XmlPackRule = "PackRule";
|
public const string XmlPackRule = "PackRule";
|
||||||
public const string XmlFilterRule = "FilterRule";
|
public const string XmlFilterRule = "FilterRule";
|
||||||
public const string XmlUserData = "UserData";
|
public const string XmlUserData = "UserData";
|
||||||
public const string XmlAssetTags = "AssetTags";
|
public const string XmlAssetTags = "AssetTags";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导入XML配置表
|
/// 导入XML配置表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ImportXmlConfig(string filePath)
|
public static void ImportXmlConfig(string filePath)
|
||||||
{
|
{
|
||||||
if (File.Exists(filePath) == false)
|
if (File.Exists(filePath) == false)
|
||||||
throw new FileNotFoundException(filePath);
|
throw new FileNotFoundException(filePath);
|
||||||
|
|
||||||
if (Path.GetExtension(filePath) != ".xml")
|
if (Path.GetExtension(filePath) != ".xml")
|
||||||
throw new Exception($"Only support xml : {filePath}");
|
throw new Exception($"Only support xml : {filePath}");
|
||||||
|
|
||||||
// 加载配置文件
|
// 加载配置文件
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
xmlDoc.Load(filePath);
|
xmlDoc.Load(filePath);
|
||||||
XmlElement root = xmlDoc.DocumentElement;
|
XmlElement root = xmlDoc.DocumentElement;
|
||||||
|
|
||||||
// 读取配置版本
|
// 读取配置版本
|
||||||
string configVersion = root.GetAttribute(XmlVersion);
|
string configVersion = root.GetAttribute(XmlVersion);
|
||||||
if (configVersion != ConfigVersion)
|
if (configVersion != ConfigVersion)
|
||||||
{
|
{
|
||||||
if (UpdateXmlConfig(xmlDoc) == false)
|
if (UpdateXmlConfig(xmlDoc) == false)
|
||||||
throw new Exception($"The config version update failed : {configVersion} -> {ConfigVersion}");
|
throw new Exception($"The config version update failed : {configVersion} -> {ConfigVersion}");
|
||||||
else
|
else
|
||||||
Debug.Log($"The config version update succeed : {configVersion} -> {ConfigVersion}");
|
Debug.Log($"The config version update succeed : {configVersion} -> {ConfigVersion}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取公共配置
|
// 读取公共配置
|
||||||
bool uniqueBundleName = false;
|
bool uniqueBundleName = false;
|
||||||
bool showPackageView = false;
|
bool showPackageView = false;
|
||||||
bool showEditorAlias = false;
|
bool showEditorAlias = false;
|
||||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||||
if (commonNodeList.Count > 0)
|
if (commonNodeList.Count > 0)
|
||||||
{
|
{
|
||||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||||
if (commonElement.HasAttribute(XmlShowPackageView))
|
if (commonElement.HasAttribute(XmlShowPackageView))
|
||||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||||
if (commonElement.HasAttribute(XmlShowEditorAlias))
|
if (commonElement.HasAttribute(XmlShowEditorAlias))
|
||||||
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
||||||
if (commonElement.HasAttribute(XmlUniqueBundleName))
|
if (commonElement.HasAttribute(XmlUniqueBundleName))
|
||||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 读取包裹配置
|
// 读取包裹配置
|
||||||
List<AssetBundleCollectorPackage> packages = new List<AssetBundleCollectorPackage>();
|
List<AssetBundleCollectorPackage> packages = new List<AssetBundleCollectorPackage>();
|
||||||
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||||
foreach (var packageNode in packageNodeList)
|
foreach (var packageNode in packageNodeList)
|
||||||
{
|
{
|
||||||
XmlElement packageElement = packageNode as XmlElement;
|
XmlElement packageElement = packageNode as XmlElement;
|
||||||
if (packageElement.HasAttribute(XmlPackageName) == false)
|
if (packageElement.HasAttribute(XmlPackageName) == false)
|
||||||
throw new Exception($"Not found attribute {XmlPackageName} in {XmlPackage}");
|
throw new Exception($"Not found attribute {XmlPackageName} in {XmlPackage}");
|
||||||
if (packageElement.HasAttribute(XmlPackageDesc) == false)
|
if (packageElement.HasAttribute(XmlPackageDesc) == false)
|
||||||
throw new Exception($"Not found attribute {XmlPackageDesc} in {XmlPackage}");
|
throw new Exception($"Not found attribute {XmlPackageDesc} in {XmlPackage}");
|
||||||
|
|
||||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||||
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
||||||
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
||||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||||
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
||||||
packages.Add(package);
|
packages.Add(package);
|
||||||
|
|
||||||
// 读取分组配置
|
// 读取分组配置
|
||||||
var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
|
var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
|
||||||
foreach (var groupNode in groupNodeList)
|
foreach (var groupNode in groupNodeList)
|
||||||
{
|
{
|
||||||
XmlElement groupElement = groupNode as XmlElement;
|
XmlElement groupElement = groupNode as XmlElement;
|
||||||
if (groupElement.HasAttribute(XmlGroupActiveRule) == false)
|
if (groupElement.HasAttribute(XmlGroupActiveRule) == false)
|
||||||
throw new Exception($"Not found attribute {XmlGroupActiveRule} in {XmlGroup}");
|
throw new Exception($"Not found attribute {XmlGroupActiveRule} in {XmlGroup}");
|
||||||
if (groupElement.HasAttribute(XmlGroupName) == false)
|
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||||
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||||
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||||
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||||
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||||
|
|
||||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||||
group.ActiveRuleName = groupElement.GetAttribute(XmlGroupActiveRule);
|
group.ActiveRuleName = groupElement.GetAttribute(XmlGroupActiveRule);
|
||||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||||
package.Groups.Add(group);
|
package.Groups.Add(group);
|
||||||
|
|
||||||
// 读取收集器配置
|
// 读取收集器配置
|
||||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||||
foreach (var collectorNode in collectorNodeList)
|
foreach (var collectorNode in collectorNodeList)
|
||||||
{
|
{
|
||||||
XmlElement collectorElement = collectorNode as XmlElement;
|
XmlElement collectorElement = collectorNode as XmlElement;
|
||||||
if (collectorElement.HasAttribute(XmlCollectPath) == false)
|
if (collectorElement.HasAttribute(XmlCollectPath) == false)
|
||||||
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
|
if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
|
||||||
throw new Exception($"Not found attribute {XmlCollectorGUID} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlCollectorGUID} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlCollectorType) == false)
|
if (collectorElement.HasAttribute(XmlCollectorType) == false)
|
||||||
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlAddressRule) == false)
|
if (collectorElement.HasAttribute(XmlAddressRule) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlPackRule) == false)
|
if (collectorElement.HasAttribute(XmlPackRule) == false)
|
||||||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlUserData) == false)
|
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||||
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
||||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||||
|
|
||||||
AssetBundleCollector collector = new AssetBundleCollector();
|
AssetBundleCollector collector = new AssetBundleCollector();
|
||||||
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
||||||
collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
||||||
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
||||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||||
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
||||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||||
group.Collectors.Add(collector);
|
group.Collectors.Add(collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测配置错误
|
// 检测配置错误
|
||||||
foreach (var package in packages)
|
foreach (var package in packages)
|
||||||
{
|
{
|
||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存配置数据
|
// 保存配置数据
|
||||||
AssetBundleCollectorSettingData.ClearAll();
|
AssetBundleCollectorSettingData.ClearAll();
|
||||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||||
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
||||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||||
AssetBundleCollectorSettingData.SaveFile();
|
AssetBundleCollectorSettingData.SaveFile();
|
||||||
Debug.Log($"Asset bundle collector config import complete!");
|
Debug.Log($"Asset bundle collector config import complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 导出XML配置表
|
/// 导出XML配置表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ExportXmlConfig(string savePath)
|
public static void ExportXmlConfig(string savePath)
|
||||||
{
|
{
|
||||||
if (File.Exists(savePath))
|
if (File.Exists(savePath))
|
||||||
File.Delete(savePath);
|
File.Delete(savePath);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
sb.AppendLine("<root>");
|
sb.AppendLine("<root>");
|
||||||
sb.AppendLine("</root>");
|
sb.AppendLine("</root>");
|
||||||
|
|
||||||
XmlDocument xmlDoc = new XmlDocument();
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
xmlDoc.LoadXml(sb.ToString());
|
xmlDoc.LoadXml(sb.ToString());
|
||||||
XmlElement root = xmlDoc.DocumentElement;
|
XmlElement root = xmlDoc.DocumentElement;
|
||||||
|
|
||||||
// 设置配置版本
|
// 设置配置版本
|
||||||
root.SetAttribute(XmlVersion, ConfigVersion);
|
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||||
|
|
||||||
// 设置公共配置
|
// 设置公共配置
|
||||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||||
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
||||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||||
root.AppendChild(commonElement);
|
root.AppendChild(commonElement);
|
||||||
|
|
||||||
// 设置Package配置
|
// 设置Package配置
|
||||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||||
{
|
{
|
||||||
var packageElement = xmlDoc.CreateElement(XmlPackage);
|
var packageElement = xmlDoc.CreateElement(XmlPackage);
|
||||||
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
||||||
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
||||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
||||||
root.AppendChild(packageElement);
|
root.AppendChild(packageElement);
|
||||||
|
|
||||||
// 设置分组配置
|
// 设置分组配置
|
||||||
foreach (var group in package.Groups)
|
foreach (var group in package.Groups)
|
||||||
{
|
{
|
||||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||||
groupElement.SetAttribute(XmlGroupActiveRule, group.ActiveRuleName);
|
groupElement.SetAttribute(XmlGroupActiveRule, group.ActiveRuleName);
|
||||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||||
packageElement.AppendChild(groupElement);
|
packageElement.AppendChild(groupElement);
|
||||||
|
|
||||||
// 设置收集器配置
|
// 设置收集器配置
|
||||||
foreach (var collector in group.Collectors)
|
foreach (var collector in group.Collectors)
|
||||||
{
|
{
|
||||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||||
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
||||||
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
||||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||||
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
||||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||||
groupElement.AppendChild(collectorElement);
|
groupElement.AppendChild(collectorElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成配置文件
|
// 生成配置文件
|
||||||
xmlDoc.Save(savePath);
|
xmlDoc.Save(savePath);
|
||||||
Debug.Log($"Asset bundle collector config export complete!");
|
Debug.Log($"Asset bundle collector config export complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 升级XML配置表
|
/// 升级XML配置表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool UpdateXmlConfig(XmlDocument xmlDoc)
|
private static bool UpdateXmlConfig(XmlDocument xmlDoc)
|
||||||
{
|
{
|
||||||
XmlElement root = xmlDoc.DocumentElement;
|
XmlElement root = xmlDoc.DocumentElement;
|
||||||
string configVersion = root.GetAttribute(XmlVersion);
|
string configVersion = root.GetAttribute(XmlVersion);
|
||||||
if (configVersion == ConfigVersion)
|
if (configVersion == ConfigVersion)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,120 +7,120 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AssetBundleCollectorGroup
|
public class AssetBundleCollectorGroup
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组名称
|
/// 分组名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GroupName = string.Empty;
|
public string GroupName = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组描述
|
/// 分组描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GroupDesc = string.Empty;
|
public string GroupDesc = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组激活规则
|
/// 分组激活规则
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ActiveRuleName = nameof(EnableGroup);
|
public string ActiveRuleName = nameof(EnableGroup);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组的收集器列表
|
/// 分组的收集器列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AssetBundleCollector> Collectors = new List<AssetBundleCollector>();
|
public List<AssetBundleCollector> Collectors = new List<AssetBundleCollector>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测配置错误
|
/// 检测配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||||
|
|
||||||
// 检测分组是否激活
|
// 检测分组是否激活
|
||||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||||
if (activeRule.IsActiveGroup() == false)
|
if (activeRule.IsActiveGroup() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修复配置错误
|
/// 修复配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FixConfigError()
|
public bool FixConfigError()
|
||||||
{
|
{
|
||||||
bool isFixed = false;
|
bool isFixed = false;
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
if (collector.FixConfigError())
|
if (collector.FixConfigError())
|
||||||
{
|
{
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isFixed;
|
return isFixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
// 检测分组是否激活
|
// 检测分组是否激活
|
||||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||||
if (activeRule.IsActiveGroup() == false)
|
if (activeRule.IsActiveGroup() == false)
|
||||||
{
|
{
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收集打包资源
|
// 收集打包资源
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
var temper = collector.GetAllCollectAssets(command, 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)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(assetInfo.AssetPath, assetInfo);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
var addressTemper = new Dictionary<string, string>();
|
var addressTemper = new Dictionary<string, string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||||
addressTemper.Add(address, assetPath);
|
addressTemper.Add(address, assetPath);
|
||||||
else
|
else
|
||||||
throw new Exception($"The address is existed : {address} in group : {GroupName} \nAssetPath:\n {existed}\n {assetPath}");
|
throw new Exception($"The address is existed : {address} in group : {GroupName} \nAssetPath:\n {existed}\n {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回列表
|
// 返回列表
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,148 +7,148 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class AssetBundleCollectorPackage
|
public class AssetBundleCollectorPackage
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName = string.Empty;
|
public string PackageName = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹描述
|
/// 包裹描述
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageDesc = string.Empty;
|
public string PackageDesc = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable = false;
|
public bool EnableAddressable = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LocationToLower = false;
|
public bool LocationToLower = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包含资源GUID数据
|
/// 包含资源GUID数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID = false;
|
public bool IncludeAssetGUID = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略Unity引擎无法识别的文件
|
/// 忽略Unity引擎无法识别的文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreDefaultType = true;
|
public bool IgnoreDefaultType = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoCollectShaders = true;
|
public bool AutoCollectShaders = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测配置错误
|
/// 检测配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
group.CheckConfigError();
|
group.CheckConfigError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修复配置错误
|
/// 修复配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FixConfigError()
|
public bool FixConfigError()
|
||||||
{
|
{
|
||||||
bool isFixed = false;
|
bool isFixed = false;
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
if (group.FixConfigError())
|
if (group.FixConfigError())
|
||||||
{
|
{
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isFixed;
|
return isFixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取打包收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
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(command);
|
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)
|
||||||
result.Add(assetInfo.AssetPath, assetInfo);
|
result.Add(assetInfo.AssetPath, assetInfo);
|
||||||
else
|
else
|
||||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测可寻址地址是否重复
|
// 检测可寻址地址是否重复
|
||||||
if (command.EnableAddressable)
|
if (command.EnableAddressable)
|
||||||
{
|
{
|
||||||
var addressTemper = new Dictionary<string, string>();
|
var addressTemper = new Dictionary<string, string>();
|
||||||
foreach (var collectInfoPair in result)
|
foreach (var collectInfoPair in result)
|
||||||
{
|
{
|
||||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||||
{
|
{
|
||||||
string address = collectInfoPair.Value.Address;
|
string address = collectInfoPair.Value.Address;
|
||||||
string assetPath = collectInfoPair.Value.AssetPath;
|
string assetPath = collectInfoPair.Value.AssetPath;
|
||||||
if (string.IsNullOrEmpty(address))
|
if (string.IsNullOrEmpty(address))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||||
addressTemper.Add(address, assetPath);
|
addressTemper.Add(address, assetPath);
|
||||||
else
|
else
|
||||||
throw new Exception($"The address is existed : {address} \nAssetPath:\n {existed}\n {assetPath}");
|
throw new Exception($"The address is existed : {address} \nAssetPath:\n {existed}\n {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回列表
|
// 返回列表
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有的资源标签
|
/// 获取所有的资源标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GetAllTags()
|
public List<string> GetAllTags()
|
||||||
{
|
{
|
||||||
HashSet<string> result = new HashSet<string>();
|
HashSet<string> result = new HashSet<string>();
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
List<string> groupTags = EditorTools.StringToStringList(group.AssetTags, ';');
|
List<string> groupTags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||||
foreach (var tag in groupTags)
|
foreach (var tag in groupTags)
|
||||||
{
|
{
|
||||||
if (result.Contains(tag) == false)
|
if (result.Contains(tag) == false)
|
||||||
result.Add(tag);
|
result.Add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var collector in group.Collectors)
|
foreach (var collector in group.Collectors)
|
||||||
{
|
{
|
||||||
List<string> collectorTags = EditorTools.StringToStringList(collector.AssetTags, ';');
|
List<string> collectorTags = EditorTools.StringToStringList(collector.AssetTags, ';');
|
||||||
foreach (var tag in collectorTags)
|
foreach (var tag in collectorTags)
|
||||||
{
|
{
|
||||||
if (result.Contains(tag) == false)
|
if (result.Contains(tag) == false)
|
||||||
result.Add(tag);
|
result.Add(tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.ToList();
|
return result.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,125 +6,125 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[CreateAssetMenu(fileName = "AssetBundleCollectorSetting", menuName = "YooAsset/Create AssetBundle Collector Settings")]
|
[CreateAssetMenu(fileName = "AssetBundleCollectorSetting", menuName = "YooAsset/Create AssetBundle Collector Settings")]
|
||||||
public class AssetBundleCollectorSetting : ScriptableObject
|
public class AssetBundleCollectorSetting : ScriptableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 显示包裹列表视图
|
/// 显示包裹列表视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowPackageView = false;
|
public bool ShowPackageView = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否显示编辑器别名
|
/// 是否显示编辑器别名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShowEditorAlias = false;
|
public bool ShowEditorAlias = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName = false;
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<AssetBundleCollectorPackage> Packages = new List<AssetBundleCollectorPackage>();
|
public List<AssetBundleCollectorPackage> Packages = new List<AssetBundleCollectorPackage>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有数据
|
/// 清空所有数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearAll()
|
public void ClearAll()
|
||||||
{
|
{
|
||||||
ShowPackageView = false;
|
ShowPackageView = false;
|
||||||
UniqueBundleName = false;
|
UniqueBundleName = false;
|
||||||
ShowEditorAlias = false;
|
ShowEditorAlias = false;
|
||||||
Packages.Clear();
|
Packages.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测包裹配置错误
|
/// 检测包裹配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckPackageConfigError(string packageName)
|
public void CheckPackageConfigError(string packageName)
|
||||||
{
|
{
|
||||||
var package = GetPackage(packageName);
|
var package = GetPackage(packageName);
|
||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测所有配置错误
|
/// 检测所有配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckAllPackageConfigError()
|
public void CheckAllPackageConfigError()
|
||||||
{
|
{
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修复所有配置错误
|
/// 修复所有配置错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool FixAllPackageConfigError()
|
public bool FixAllPackageConfigError()
|
||||||
{
|
{
|
||||||
bool isFixed = false;
|
bool isFixed = false;
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
if (package.FixConfigError())
|
if (package.FixConfigError())
|
||||||
{
|
{
|
||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isFixed;
|
return isFixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有的资源标签
|
/// 获取所有的资源标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> GetPackageAllTags(string packageName)
|
public List<string> GetPackageAllTags(string packageName)
|
||||||
{
|
{
|
||||||
var package = GetPackage(packageName);
|
var package = GetPackage(packageName);
|
||||||
return package.GetAllTags();
|
return package.GetAllTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹收集的资源文件
|
/// 获取包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CollectResult 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 empty !");
|
throw new Exception("Build package name is null or empty !");
|
||||||
|
|
||||||
// 检测配置合法性
|
// 检测配置合法性
|
||||||
var package = GetPackage(packageName);
|
var package = GetPackage(packageName);
|
||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
|
|
||||||
// 创建资源收集命令
|
// 创建资源收集命令
|
||||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||||
package.EnableAddressable,
|
package.EnableAddressable,
|
||||||
package.LocationToLower,
|
package.LocationToLower,
|
||||||
package.IncludeAssetGUID,
|
package.IncludeAssetGUID,
|
||||||
package.IgnoreDefaultType,
|
package.IgnoreDefaultType,
|
||||||
package.AutoCollectShaders,
|
package.AutoCollectShaders,
|
||||||
UniqueBundleName);
|
UniqueBundleName);
|
||||||
|
|
||||||
// 获取收集的资源集合
|
// 获取收集的资源集合
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||||
return collectResult;
|
return collectResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹类
|
/// 获取包裹类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AssetBundleCollectorPackage GetPackage(string packageName)
|
public AssetBundleCollectorPackage GetPackage(string packageName)
|
||||||
{
|
{
|
||||||
foreach (var package in Packages)
|
foreach (var package in Packages)
|
||||||
{
|
{
|
||||||
if (package.PackageName == packageName)
|
if (package.PackageName == packageName)
|
||||||
return package;
|
return package;
|
||||||
}
|
}
|
||||||
throw new Exception($"Not found package : {packageName}");
|
throw new Exception($"Not found package : {packageName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,424 +7,424 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleCollectorSettingData
|
public class AssetBundleCollectorSettingData
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
|
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
|
||||||
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
|
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
|
||||||
|
|
||||||
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||||
|
|
||||||
private static readonly Dictionary<string, System.Type> _cachePackRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cachePackRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IPackRule> _cachePackRuleInstance = new Dictionary<string, IPackRule>();
|
private static readonly Dictionary<string, IPackRule> _cachePackRuleInstance = new Dictionary<string, IPackRule>();
|
||||||
|
|
||||||
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 配置数据是否被修改
|
/// 配置数据是否被修改
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsDirty { private set; get; } = false;
|
public static bool IsDirty { private set; get; } = false;
|
||||||
|
|
||||||
|
|
||||||
static AssetBundleCollectorSettingData()
|
static AssetBundleCollectorSettingData()
|
||||||
{
|
{
|
||||||
// IPackRule
|
// IPackRule
|
||||||
{
|
{
|
||||||
// 清空缓存集合
|
// 清空缓存集合
|
||||||
_cachePackRuleTypes.Clear();
|
_cachePackRuleTypes.Clear();
|
||||||
_cachePackRuleInstance.Clear();
|
_cachePackRuleInstance.Clear();
|
||||||
|
|
||||||
// 获取所有类型
|
// 获取所有类型
|
||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(PackSeparately),
|
typeof(PackSeparately),
|
||||||
typeof(PackDirectory),
|
typeof(PackDirectory),
|
||||||
typeof(PackTopDirectory),
|
typeof(PackTopDirectory),
|
||||||
typeof(PackCollector),
|
typeof(PackCollector),
|
||||||
typeof(PackGroup),
|
typeof(PackGroup),
|
||||||
typeof(PackRawFile),
|
typeof(PackRawFile),
|
||||||
typeof(PackShaderVariants)
|
typeof(PackShaderVariants)
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
Type type = types[i];
|
Type type = types[i];
|
||||||
if (_cachePackRuleTypes.ContainsKey(type.Name) == false)
|
if (_cachePackRuleTypes.ContainsKey(type.Name) == false)
|
||||||
_cachePackRuleTypes.Add(type.Name, type);
|
_cachePackRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IFilterRule
|
// IFilterRule
|
||||||
{
|
{
|
||||||
// 清空缓存集合
|
// 清空缓存集合
|
||||||
_cacheFilterRuleTypes.Clear();
|
_cacheFilterRuleTypes.Clear();
|
||||||
_cacheFilterRuleInstance.Clear();
|
_cacheFilterRuleInstance.Clear();
|
||||||
|
|
||||||
// 获取所有类型
|
// 获取所有类型
|
||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(CollectAll),
|
typeof(CollectAll),
|
||||||
typeof(CollectScene),
|
typeof(CollectScene),
|
||||||
typeof(CollectPrefab),
|
typeof(CollectPrefab),
|
||||||
typeof(CollectSprite)
|
typeof(CollectSprite)
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
Type type = types[i];
|
Type type = types[i];
|
||||||
if (_cacheFilterRuleTypes.ContainsKey(type.Name) == false)
|
if (_cacheFilterRuleTypes.ContainsKey(type.Name) == false)
|
||||||
_cacheFilterRuleTypes.Add(type.Name, type);
|
_cacheFilterRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IAddressRule
|
// IAddressRule
|
||||||
{
|
{
|
||||||
// 清空缓存集合
|
// 清空缓存集合
|
||||||
_cacheAddressRuleTypes.Clear();
|
_cacheAddressRuleTypes.Clear();
|
||||||
_cacheAddressRuleInstance.Clear();
|
_cacheAddressRuleInstance.Clear();
|
||||||
|
|
||||||
// 获取所有类型
|
// 获取所有类型
|
||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(AddressByFileName),
|
typeof(AddressByFileName),
|
||||||
typeof(AddressByFolderAndFileName),
|
typeof(AddressByFolderAndFileName),
|
||||||
typeof(AddressByGroupAndFileName),
|
typeof(AddressByGroupAndFileName),
|
||||||
typeof(AddressDisable)
|
typeof(AddressDisable)
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
Type type = types[i];
|
Type type = types[i];
|
||||||
if (_cacheAddressRuleTypes.ContainsKey(type.Name) == false)
|
if (_cacheAddressRuleTypes.ContainsKey(type.Name) == false)
|
||||||
_cacheAddressRuleTypes.Add(type.Name, type);
|
_cacheAddressRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IActiveRule
|
// IActiveRule
|
||||||
{
|
{
|
||||||
// 清空缓存集合
|
// 清空缓存集合
|
||||||
_cacheActiveRuleTypes.Clear();
|
_cacheActiveRuleTypes.Clear();
|
||||||
_cacheActiveRuleInstance.Clear();
|
_cacheActiveRuleInstance.Clear();
|
||||||
|
|
||||||
// 获取所有类型
|
// 获取所有类型
|
||||||
List<Type> types = new List<Type>(100)
|
List<Type> types = new List<Type>(100)
|
||||||
{
|
{
|
||||||
typeof(EnableGroup),
|
typeof(EnableGroup),
|
||||||
typeof(DisableGroup),
|
typeof(DisableGroup),
|
||||||
};
|
};
|
||||||
|
|
||||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
Type type = types[i];
|
Type type = types[i];
|
||||||
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
||||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AssetBundleCollectorSetting _setting = null;
|
private static AssetBundleCollectorSetting _setting = null;
|
||||||
public static AssetBundleCollectorSetting Setting
|
public static AssetBundleCollectorSetting Setting
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_setting == null)
|
if (_setting == null)
|
||||||
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
|
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
|
||||||
return _setting;
|
return _setting;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 存储配置文件
|
/// 存储配置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SaveFile()
|
public static void SaveFile()
|
||||||
{
|
{
|
||||||
if (Setting != null)
|
if (Setting != null)
|
||||||
{
|
{
|
||||||
IsDirty = false;
|
IsDirty = false;
|
||||||
EditorUtility.SetDirty(Setting);
|
EditorUtility.SetDirty(Setting);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修复配置文件
|
/// 修复配置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void FixFile()
|
public static void FixFile()
|
||||||
{
|
{
|
||||||
bool isFixed = Setting.FixAllPackageConfigError();
|
bool isFixed = Setting.FixAllPackageConfigError();
|
||||||
if (isFixed)
|
if (isFixed)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有数据
|
/// 清空所有数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ClearAll()
|
public static void ClearAll()
|
||||||
{
|
{
|
||||||
Setting.ClearAll();
|
Setting.ClearAll();
|
||||||
SaveFile();
|
SaveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<RuleDisplayName> GetActiveRuleNames()
|
public static List<RuleDisplayName> GetActiveRuleNames()
|
||||||
{
|
{
|
||||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
foreach (var pair in _cacheActiveRuleTypes)
|
foreach (var pair in _cacheActiveRuleTypes)
|
||||||
{
|
{
|
||||||
RuleDisplayName ruleName = new RuleDisplayName();
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
ruleName.ClassName = pair.Key;
|
ruleName.ClassName = pair.Key;
|
||||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
names.Add(ruleName);
|
names.Add(ruleName);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
public static List<RuleDisplayName> GetAddressRuleNames()
|
public static List<RuleDisplayName> GetAddressRuleNames()
|
||||||
{
|
{
|
||||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
foreach (var pair in _cacheAddressRuleTypes)
|
foreach (var pair in _cacheAddressRuleTypes)
|
||||||
{
|
{
|
||||||
RuleDisplayName ruleName = new RuleDisplayName();
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
ruleName.ClassName = pair.Key;
|
ruleName.ClassName = pair.Key;
|
||||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
names.Add(ruleName);
|
names.Add(ruleName);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
public static List<RuleDisplayName> GetPackRuleNames()
|
public static List<RuleDisplayName> GetPackRuleNames()
|
||||||
{
|
{
|
||||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
foreach (var pair in _cachePackRuleTypes)
|
foreach (var pair in _cachePackRuleTypes)
|
||||||
{
|
{
|
||||||
RuleDisplayName ruleName = new RuleDisplayName();
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
ruleName.ClassName = pair.Key;
|
ruleName.ClassName = pair.Key;
|
||||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
names.Add(ruleName);
|
names.Add(ruleName);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
public static List<RuleDisplayName> GetFilterRuleNames()
|
public static List<RuleDisplayName> GetFilterRuleNames()
|
||||||
{
|
{
|
||||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
foreach (var pair in _cacheFilterRuleTypes)
|
foreach (var pair in _cacheFilterRuleTypes)
|
||||||
{
|
{
|
||||||
RuleDisplayName ruleName = new RuleDisplayName();
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
ruleName.ClassName = pair.Key;
|
ruleName.ClassName = pair.Key;
|
||||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
names.Add(ruleName);
|
names.Add(ruleName);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
private static string GetRuleDisplayName(string name, Type type)
|
private static string GetRuleDisplayName(string name, Type type)
|
||||||
{
|
{
|
||||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||||
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||||
return attribute.DisplayName;
|
return attribute.DisplayName;
|
||||||
else
|
else
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool HasActiveRuleName(string ruleName)
|
public static bool HasActiveRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasAddressRuleName(string ruleName)
|
public static bool HasAddressRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasPackRuleName(string ruleName)
|
public static bool HasPackRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasFilterRuleName(string ruleName)
|
public static bool HasFilterRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
// 如果不存在创建类的实例
|
// 如果不存在创建类的实例
|
||||||
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
{
|
{
|
||||||
instance = (IActiveRule)Activator.CreateInstance(type);
|
instance = (IActiveRule)Activator.CreateInstance(type);
|
||||||
_cacheActiveRuleInstance.Add(ruleName, instance);
|
_cacheActiveRuleInstance.Add(ruleName, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"{nameof(IActiveRule)} is invalid:{ruleName}");
|
throw new Exception($"{nameof(IActiveRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
// 如果不存在创建类的实例
|
// 如果不存在创建类的实例
|
||||||
if (_cacheAddressRuleTypes.TryGetValue(ruleName, out Type type))
|
if (_cacheAddressRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
{
|
{
|
||||||
instance = (IAddressRule)Activator.CreateInstance(type);
|
instance = (IAddressRule)Activator.CreateInstance(type);
|
||||||
_cacheAddressRuleInstance.Add(ruleName, instance);
|
_cacheAddressRuleInstance.Add(ruleName, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"{nameof(IAddressRule)} is invalid:{ruleName}");
|
throw new Exception($"{nameof(IAddressRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static IPackRule GetPackRuleInstance(string ruleName)
|
public static IPackRule GetPackRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cachePackRuleInstance.TryGetValue(ruleName, out IPackRule instance))
|
if (_cachePackRuleInstance.TryGetValue(ruleName, out IPackRule instance))
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
// 如果不存在创建类的实例
|
// 如果不存在创建类的实例
|
||||||
if (_cachePackRuleTypes.TryGetValue(ruleName, out Type type))
|
if (_cachePackRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
{
|
{
|
||||||
instance = (IPackRule)Activator.CreateInstance(type);
|
instance = (IPackRule)Activator.CreateInstance(type);
|
||||||
_cachePackRuleInstance.Add(ruleName, instance);
|
_cachePackRuleInstance.Add(ruleName, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"{nameof(IPackRule)} is invalid:{ruleName}");
|
throw new Exception($"{nameof(IPackRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
||||||
{
|
{
|
||||||
if (_cacheFilterRuleInstance.TryGetValue(ruleName, out IFilterRule instance))
|
if (_cacheFilterRuleInstance.TryGetValue(ruleName, out IFilterRule instance))
|
||||||
return instance;
|
return instance;
|
||||||
|
|
||||||
// 如果不存在创建类的实例
|
// 如果不存在创建类的实例
|
||||||
if (_cacheFilterRuleTypes.TryGetValue(ruleName, out Type type))
|
if (_cacheFilterRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
{
|
{
|
||||||
instance = (IFilterRule)Activator.CreateInstance(type);
|
instance = (IFilterRule)Activator.CreateInstance(type);
|
||||||
_cacheFilterRuleInstance.Add(ruleName, instance);
|
_cacheFilterRuleInstance.Add(ruleName, instance);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公共参数编辑相关
|
// 公共参数编辑相关
|
||||||
public static void ModifyShowPackageView(bool showPackageView)
|
public static void ModifyShowPackageView(bool showPackageView)
|
||||||
{
|
{
|
||||||
Setting.ShowPackageView = showPackageView;
|
Setting.ShowPackageView = showPackageView;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
public static void ModifyShowEditorAlias(bool showAlias)
|
public static void ModifyShowEditorAlias(bool showAlias)
|
||||||
{
|
{
|
||||||
Setting.ShowEditorAlias = showAlias;
|
Setting.ShowEditorAlias = showAlias;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
Setting.UniqueBundleName = uniqueBundleName;
|
Setting.UniqueBundleName = uniqueBundleName;
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源包裹编辑相关
|
// 资源包裹编辑相关
|
||||||
public static AssetBundleCollectorPackage 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;
|
return package;
|
||||||
}
|
}
|
||||||
public static void RemovePackage(AssetBundleCollectorPackage package)
|
public static void RemovePackage(AssetBundleCollectorPackage package)
|
||||||
{
|
{
|
||||||
if (Setting.Packages.Remove(package))
|
if (Setting.Packages.Remove(package))
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Failed remove package : {package.PackageName}");
|
Debug.LogWarning($"Failed remove package : {package.PackageName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ModifyPackage(AssetBundleCollectorPackage package)
|
public static void ModifyPackage(AssetBundleCollectorPackage package)
|
||||||
{
|
{
|
||||||
if (package != null)
|
if (package != null)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源分组编辑相关
|
// 资源分组编辑相关
|
||||||
public static AssetBundleCollectorGroup 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;
|
return group;
|
||||||
}
|
}
|
||||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
if (package.Groups.Remove(group))
|
if (package.Groups.Remove(group))
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ModifyGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
public static void ModifyGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
if (package != null && group != null)
|
if (package != null && group != null)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源收集器编辑相关
|
// 资源收集器编辑相关
|
||||||
public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
group.Collectors.Add(collector);
|
group.Collectors.Add(collector);
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
if (group.Collectors.Remove(collector))
|
if (group.Collectors.Remove(collector))
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||||
{
|
{
|
||||||
if (group != null && collector != null)
|
if (group != null && collector != null)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取所有的资源标签
|
/// 获取所有的资源标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetPackageAllTags(string packageName)
|
public static string GetPackageAllTags(string packageName)
|
||||||
{
|
{
|
||||||
var allTags = Setting.GetPackageAllTags(packageName);
|
var allTags = Setting.GetPackageAllTags(packageName);
|
||||||
return string.Join(";", allTags);
|
return string.Join(";", allTags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -3,46 +3,46 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class CollectAssetInfo
|
public class CollectAssetInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集器类型
|
/// 收集器类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ECollectorType CollectorType { private set; get; }
|
public ECollectorType CollectorType { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { private set; get; }
|
public string BundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址
|
/// 可寻址地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Address { private set; get; }
|
public string Address { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { private set; get; }
|
public string AssetPath { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分类标签
|
/// 资源分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> AssetTags { private set; get; }
|
public List<string> AssetTags { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源列表
|
/// 依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public List<string> DependAssets = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
||||||
{
|
{
|
||||||
CollectorType = collectorType;
|
CollectorType = collectorType;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Address = address;
|
Address = address;
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
AssetTags = assetTags;
|
AssetTags = assetTags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,68 +1,68 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class CollectCommand
|
public class CollectCommand
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode { private set; get; }
|
public EBuildMode BuildMode { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略Unity引擎无法识别的文件
|
/// 忽略Unity引擎无法识别的文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreDefaultType { private set; get; }
|
public bool IgnoreDefaultType { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableAddressable { private set; get; }
|
public bool EnableAddressable { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源定位地址大小写不敏感
|
/// 资源定位地址大小写不敏感
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LocationToLower { private set; get; }
|
public bool LocationToLower { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包含资源GUID数据
|
/// 包含资源GUID数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID { private set; get; }
|
public bool IncludeAssetGUID { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动收集所有着色器
|
/// 自动收集所有着色器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoCollectShaders { private set; get; }
|
public bool AutoCollectShaders { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名唯一化
|
/// 资源包名唯一化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName { private set; get; }
|
public bool UniqueBundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 着色器统一全名称
|
/// 着色器统一全名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ShadersBundleName { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
BuildMode = buildMode;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
LocationToLower = locationToLower;
|
LocationToLower = locationToLower;
|
||||||
IncludeAssetGUID = includeAssetGUID;
|
IncludeAssetGUID = includeAssetGUID;
|
||||||
IgnoreDefaultType = ignoreDefaultType;
|
IgnoreDefaultType = ignoreDefaultType;
|
||||||
AutoCollectShaders = autoCollectShaders;
|
AutoCollectShaders = autoCollectShaders;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
|
||||||
// 着色器统一全名称
|
// 着色器统一全名称
|
||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,25 +3,25 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class CollectResult
|
public class CollectResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集命令
|
/// 收集命令
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CollectCommand Command { private set; get; }
|
public CollectCommand Command { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集的资源信息列表
|
/// 收集的资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
public CollectResult(CollectCommand command)
|
public CollectResult(CollectCommand command)
|
||||||
{
|
{
|
||||||
Command = command;
|
Command = command;
|
||||||
}
|
}
|
||||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||||
{
|
{
|
||||||
CollectAssets = collectAssets;
|
CollectAssets = collectAssets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分组激活规则接口
|
/// 资源分组激活规则接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IActiveRule
|
public interface IActiveRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否激活分组
|
/// 是否激活分组
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsActiveGroup();
|
bool IsActiveGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,27 +1,27 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public struct AddressRuleData
|
public struct AddressRuleData
|
||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
public string UserData;
|
public string UserData;
|
||||||
|
|
||||||
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
UserData = userData;
|
UserData = userData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 寻址规则接口
|
/// 寻址规则接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAddressRule
|
public interface IAddressRule
|
||||||
{
|
{
|
||||||
string GetAssetAddress(AddressRuleData data);
|
string GetAssetAddress(AddressRuleData data);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,31 +1,31 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public struct FilterRuleData
|
public struct FilterRuleData
|
||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
public string UserData;
|
public string UserData;
|
||||||
|
|
||||||
public FilterRuleData(string assetPath, string collectPath, string groupName, string userData)
|
public FilterRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
UserData = userData;
|
UserData = userData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源过滤规则接口
|
/// 资源过滤规则接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IFilterRule
|
public interface IFilterRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为收集资源
|
/// 是否为收集资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>如果收集该资源返回TRUE</returns>
|
/// <returns>如果收集该资源返回TRUE</returns>
|
||||||
bool IsCollectAsset(FilterRuleData data);
|
bool IsCollectAsset(FilterRuleData data);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,56 +1,56 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public struct PackRuleData
|
public struct PackRuleData
|
||||||
{
|
{
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
public string CollectPath;
|
public string CollectPath;
|
||||||
public string GroupName;
|
public string GroupName;
|
||||||
public string UserData;
|
public string UserData;
|
||||||
|
|
||||||
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
CollectPath = collectPath;
|
CollectPath = collectPath;
|
||||||
GroupName = groupName;
|
GroupName = groupName;
|
||||||
UserData = userData;
|
UserData = userData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct PackRuleResult
|
public struct PackRuleResult
|
||||||
{
|
{
|
||||||
private readonly string _bundleName;
|
private readonly string _bundleName;
|
||||||
private readonly string _bundleExtension;
|
private readonly string _bundleExtension;
|
||||||
|
|
||||||
public PackRuleResult(string bundleName, string bundleExtension)
|
public PackRuleResult(string bundleName, string bundleExtension)
|
||||||
{
|
{
|
||||||
_bundleName = bundleName;
|
_bundleName = bundleName;
|
||||||
_bundleExtension = bundleExtension;
|
_bundleExtension = bundleExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包全名称
|
/// 获取资源包全名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBundleName(string packageName, bool uniqueBundleName)
|
public string GetBundleName(string packageName, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
string fullName;
|
string fullName;
|
||||||
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||||
if (uniqueBundleName)
|
if (uniqueBundleName)
|
||||||
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
||||||
else
|
else
|
||||||
fullName = $"{bundleName}.{_bundleExtension}";
|
fullName = $"{bundleName}.{_bundleExtension}";
|
||||||
return fullName.ToLower();
|
return fullName.ToLower();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源打包规则接口
|
/// 资源打包规则接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IPackRule
|
public interface IPackRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包规则结果
|
/// 获取打包规则结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PackRuleResult GetPackRuleResult(PackRuleData data);
|
PackRuleResult GetPackRuleResult(PackRuleData data);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[DisplayName("启用分组")]
|
[DisplayName("启用分组")]
|
||||||
public class EnableGroup : IActiveRule
|
public class EnableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("禁用分组")]
|
[DisplayName("禁用分组")]
|
||||||
public class DisableGroup : IActiveRule
|
public class DisableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,42 +2,42 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[DisplayName("定位地址: 禁用")]
|
[DisplayName("定位地址: 禁用")]
|
||||||
public class AddressDisable : IAddressRule
|
public class AddressDisable : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("定位地址: 文件名")]
|
[DisplayName("定位地址: 文件名")]
|
||||||
public class AddressByFileName : IAddressRule
|
public class AddressByFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("定位地址: 分组名_文件名")]
|
[DisplayName("定位地址: 分组名_文件名")]
|
||||||
public class AddressByGroupAndFileName : IAddressRule
|
public class AddressByGroupAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
return $"{data.GroupName}_{fileName}";
|
return $"{data.GroupName}_{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("定位地址: 文件夹名_文件名")]
|
[DisplayName("定位地址: 文件夹名_文件名")]
|
||||||
public class AddressByFolderAndFileName : IAddressRule
|
public class AddressByFolderAndFileName : IAddressRule
|
||||||
{
|
{
|
||||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||||
FileInfo fileInfo = new FileInfo(data.AssetPath);
|
FileInfo fileInfo = new FileInfo(data.AssetPath);
|
||||||
return $"{fileInfo.Directory.Name}_{fileName}";
|
return $"{fileInfo.Directory.Name}_{fileName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,76 +6,76 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class DefaultFilterRule
|
public class DefaultFilterRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略的文件类型
|
/// 忽略的文件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询是否为忽略文件
|
/// 查询是否为忽略文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsIgnoreFile(string fileExtension)
|
public static bool IsIgnoreFile(string fileExtension)
|
||||||
{
|
{
|
||||||
return _ignoreFileExtensions.Contains(fileExtension);
|
return _ignoreFileExtensions.Contains(fileExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集所有资源")]
|
[DisplayName("收集所有资源")]
|
||||||
public class CollectAll : IFilterRule
|
public class CollectAll : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集场景")]
|
[DisplayName("收集场景")]
|
||||||
public class CollectScene : IFilterRule
|
public class CollectScene : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集预制体")]
|
[DisplayName("收集预制体")]
|
||||||
public class CollectPrefab : IFilterRule
|
public class CollectPrefab : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集精灵类型的纹理")]
|
[DisplayName("收集精灵类型的纹理")]
|
||||||
public class CollectSprite : IFilterRule
|
public class CollectSprite : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||||
if (mainAssetType == typeof(Texture2D))
|
if (mainAssetType == typeof(Texture2D))
|
||||||
{
|
{
|
||||||
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
||||||
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DisplayName("收集着色器变种集合")]
|
[DisplayName("收集着色器变种集合")]
|
||||||
public class CollectShaderVariants : IFilterRule
|
public class CollectShaderVariants : IFilterRule
|
||||||
{
|
{
|
||||||
public bool IsCollectAsset(FilterRuleData data)
|
public bool IsCollectAsset(FilterRuleData data)
|
||||||
{
|
{
|
||||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,158 +4,158 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class DefaultPackRule
|
public class DefaultPackRule
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AssetBundle文件的后缀名
|
/// AssetBundle文件的后缀名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AssetBundleFileExtension = "bundle";
|
public const string AssetBundleFileExtension = "bundle";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 原生文件的后缀名
|
/// 原生文件的后缀名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string RawFileExtension = "rawfile";
|
public const string RawFileExtension = "rawfile";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unity着色器资源包名称
|
/// Unity着色器资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ShadersBundleName = "unityshaders";
|
public const string ShadersBundleName = "unityshaders";
|
||||||
|
|
||||||
|
|
||||||
public static PackRuleResult CreateShadersPackRuleResult()
|
public static PackRuleResult CreateShadersPackRuleResult()
|
||||||
{
|
{
|
||||||
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以文件路径作为资源包名
|
/// 以文件路径作为资源包名
|
||||||
/// 注意:每个文件独自打资源包
|
/// 注意:每个文件独自打资源包
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("资源包名: 文件路径")]
|
[DisplayName("资源包名: 文件路径")]
|
||||||
public class PackSeparately : IPackRule
|
public class PackSeparately : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName = PathUtility.RemoveExtension(data.AssetPath);
|
string bundleName = PathUtility.RemoveExtension(data.AssetPath);
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以父类文件夹路径作为资源包名
|
/// 以父类文件夹路径作为资源包名
|
||||||
/// 注意:文件夹下所有文件打进一个资源包
|
/// 注意:文件夹下所有文件打进一个资源包
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("资源包名: 父类文件夹路径")]
|
[DisplayName("资源包名: 父类文件夹路径")]
|
||||||
public class PackDirectory : IPackRule
|
public class PackDirectory : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以收集器路径下顶级文件夹为资源包名
|
/// 以收集器路径下顶级文件夹为资源包名
|
||||||
/// 注意:文件夹下所有文件打进一个资源包
|
/// 注意:文件夹下所有文件打进一个资源包
|
||||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
||||||
public class PackTopDirectory : IPackRule
|
public class PackTopDirectory : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||||
assetPath = assetPath.TrimStart('/');
|
assetPath = assetPath.TrimStart('/');
|
||||||
string[] splits = assetPath.Split('/');
|
string[] splits = assetPath.Split('/');
|
||||||
if (splits.Length > 0)
|
if (splits.Length > 0)
|
||||||
{
|
{
|
||||||
if (Path.HasExtension(splits[0]))
|
if (Path.HasExtension(splits[0]))
|
||||||
throw new Exception($"Not found root directory : {assetPath}");
|
throw new Exception($"Not found root directory : {assetPath}");
|
||||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"Not found root directory : {assetPath}");
|
throw new Exception($"Not found root directory : {assetPath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以收集器路径作为资源包名
|
/// 以收集器路径作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("资源包名: 收集器路径")]
|
[DisplayName("资源包名: 收集器路径")]
|
||||||
public class PackCollector : IPackRule
|
public class PackCollector : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName;
|
string bundleName;
|
||||||
string collectPath = data.CollectPath;
|
string collectPath = data.CollectPath;
|
||||||
if (AssetDatabase.IsValidFolder(collectPath))
|
if (AssetDatabase.IsValidFolder(collectPath))
|
||||||
{
|
{
|
||||||
bundleName = collectPath;
|
bundleName = collectPath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bundleName = PathUtility.RemoveExtension(collectPath);
|
bundleName = PathUtility.RemoveExtension(collectPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以分组名称作为资源包名
|
/// 以分组名称作为资源包名
|
||||||
/// 注意:收集的所有文件打进一个资源包
|
/// 注意:收集的所有文件打进一个资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("资源包名: 分组名称")]
|
[DisplayName("资源包名: 分组名称")]
|
||||||
public class PackGroup : IPackRule
|
public class PackGroup : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName = data.GroupName;
|
string bundleName = data.GroupName;
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打包原生文件
|
/// 打包原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("打包原生文件")]
|
[DisplayName("打包原生文件")]
|
||||||
public class PackRawFile : IPackRule
|
public class PackRawFile : IPackRule
|
||||||
{
|
{
|
||||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
string bundleName = data.AssetPath;
|
string bundleName = data.AssetPath;
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 打包着色器变种集合
|
/// 打包着色器变种集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisplayName("打包着色器变种集合文件")]
|
[DisplayName("打包着色器变种集合文件")]
|
||||||
public class PackShaderVariants : IPackRule
|
public class PackShaderVariants : IPackRule
|
||||||
{
|
{
|
||||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||||
{
|
{
|
||||||
return DefaultPackRule.CreateShadersPackRuleResult();
|
return DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,34 +3,34 @@ using System.Reflection;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器显示名字
|
/// 编辑器显示名字
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DisplayNameAttribute : Attribute
|
public class DisplayNameAttribute : Attribute
|
||||||
{
|
{
|
||||||
public string DisplayName;
|
public string DisplayName;
|
||||||
|
|
||||||
public DisplayNameAttribute(string name)
|
public DisplayNameAttribute(string name)
|
||||||
{
|
{
|
||||||
this.DisplayName = name;
|
this.DisplayName = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DisplayNameAttributeHelper
|
public static class DisplayNameAttributeHelper
|
||||||
{
|
{
|
||||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||||
{
|
{
|
||||||
return (T)type.GetCustomAttribute(typeof(T), false);
|
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||||
{
|
{
|
||||||
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||||
{
|
{
|
||||||
return (T)field.GetCustomAttribute(typeof(T), false);
|
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,28 +2,28 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public enum ECollectorType
|
public enum ECollectorType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
MainAssetCollector,
|
MainAssetCollector,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
StaticAssetCollector,
|
StaticAssetCollector,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||||
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DependAssetCollector,
|
DependAssetCollector,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 该收集器类型不能被设置
|
/// 该收集器类型不能被设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class RuleDisplayName
|
public class RuleDisplayName
|
||||||
{
|
{
|
||||||
public string ClassName;
|
public string ClassName;
|
||||||
public string DisplayName;
|
public string DisplayName;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,319 +10,319 @@ using UnityEngine.Networking.PlayerConnection;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleDebuggerWindow : EditorWindow
|
public class AssetBundleDebuggerWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||||
public static void OpenWindow()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
|
||||||
wnd.minSize = new Vector2(800, 600);
|
wnd.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 视图模式
|
/// 视图模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private enum EViewMode
|
private enum EViewMode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内存视图
|
/// 内存视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
MemoryView,
|
MemoryView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象视图
|
/// 资源对象视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AssetView,
|
AssetView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包视图
|
/// 资源包视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleView,
|
BundleView,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||||
|
|
||||||
private Label _playerName;
|
private Label _playerName;
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
private SliderInt _frameSlider;
|
private SliderInt _frameSlider;
|
||||||
private DebuggerAssetListViewer _assetListViewer;
|
private DebuggerAssetListViewer _assetListViewer;
|
||||||
private DebuggerBundleListViewer _bundleListViewer;
|
private DebuggerBundleListViewer _bundleListViewer;
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private string _searchKeyWord;
|
private string _searchKeyWord;
|
||||||
private DebugReport _currentReport;
|
private DebugReport _currentReport;
|
||||||
private RemotePlayerSession _currentPlayerSession;
|
private RemotePlayerSession _currentPlayerSession;
|
||||||
private int _rangeIndex = 0;
|
private int _rangeIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VisualElement root = rootVisualElement;
|
VisualElement root = rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
// 采样按钮
|
// 采样按钮
|
||||||
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");
|
var exportBtn = root.Q<Button>("ExportButton");
|
||||||
exportBtn.clicked += ExportBtn_clicked;
|
exportBtn.clicked += ExportBtn_clicked;
|
||||||
|
|
||||||
// 用户列表菜单
|
// 用户列表菜单
|
||||||
_playerName = root.Q<Label>("PlayerName");
|
_playerName = root.Q<Label>("PlayerName");
|
||||||
_playerName.text = "Editor player";
|
_playerName.text = "Editor player";
|
||||||
|
|
||||||
// 视口模式菜单
|
// 视口模式菜单
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
|
||||||
// 搜索栏
|
// 搜索栏
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
// 帧数相关
|
// 帧数相关
|
||||||
{
|
{
|
||||||
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
||||||
_frameSlider.label = "Frame:";
|
_frameSlider.label = "Frame:";
|
||||||
_frameSlider.highValue = 0;
|
_frameSlider.highValue = 0;
|
||||||
_frameSlider.lowValue = 0;
|
_frameSlider.lowValue = 0;
|
||||||
_frameSlider.value = 0;
|
_frameSlider.value = 0;
|
||||||
_frameSlider.RegisterValueChangedCallback(evt =>
|
_frameSlider.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
OnFrameSliderChange(evt.newValue);
|
OnFrameSliderChange(evt.newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
||||||
frameLast.clicked += OnFrameLast_clicked;
|
frameLast.clicked += OnFrameLast_clicked;
|
||||||
|
|
||||||
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
||||||
frameNext.clicked += OnFrameNext_clicked;
|
frameNext.clicked += OnFrameNext_clicked;
|
||||||
|
|
||||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||||
frameClear.clicked += OnFrameClear_clicked;
|
frameClear.clicked += OnFrameClear_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_assetListViewer = new DebuggerAssetListViewer();
|
_assetListViewer = new DebuggerAssetListViewer();
|
||||||
_assetListViewer.InitViewer();
|
_assetListViewer.InitViewer();
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_bundleListViewer = new DebuggerBundleListViewer();
|
_bundleListViewer = new DebuggerBundleListViewer();
|
||||||
_bundleListViewer.InitViewer();
|
_bundleListViewer.InitViewer();
|
||||||
|
|
||||||
// 显示视图
|
// 显示视图
|
||||||
_viewMode = EViewMode.AssetView;
|
_viewMode = EViewMode.AssetView;
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
|
|
||||||
// 远程调试
|
// 远程调试
|
||||||
EditorConnection.instance.Initialize();
|
EditorConnection.instance.Initialize();
|
||||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError(e.ToString());
|
Debug.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
// 远程调试
|
// 远程调试
|
||||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||||
_playerSessions.Clear();
|
_playerSessions.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHandleConnectionEvent(int playerId)
|
private void OnHandleConnectionEvent(int playerId)
|
||||||
{
|
{
|
||||||
Debug.Log($"Game player connection : {playerId}");
|
Debug.Log($"Game player connection : {playerId}");
|
||||||
_playerName.text = $"Connected player : {playerId}";
|
_playerName.text = $"Connected player : {playerId}";
|
||||||
}
|
}
|
||||||
private void OnHandleDisconnectionEvent(int playerId)
|
private void OnHandleDisconnectionEvent(int playerId)
|
||||||
{
|
{
|
||||||
Debug.Log($"Game player disconnection : {playerId}");
|
Debug.Log($"Game player disconnection : {playerId}");
|
||||||
_playerName.text = $"Disconneced player : {playerId}";
|
_playerName.text = $"Disconneced player : {playerId}";
|
||||||
}
|
}
|
||||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||||
{
|
{
|
||||||
var debugReport = DebugReport.Deserialize(args.data);
|
var debugReport = DebugReport.Deserialize(args.data);
|
||||||
OnHandleDebugReport(args.playerId, debugReport);
|
OnHandleDebugReport(args.playerId, debugReport);
|
||||||
}
|
}
|
||||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||||
{
|
{
|
||||||
Debug.Log($"Handle player {playerId} debug report !");
|
Debug.Log($"Handle player {playerId} debug report !");
|
||||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||||
_currentPlayerSession.AddDebugReport(debugReport);
|
_currentPlayerSession.AddDebugReport(debugReport);
|
||||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||||
UpdateFrameView(_currentPlayerSession);
|
UpdateFrameView(_currentPlayerSession);
|
||||||
}
|
}
|
||||||
private void OnFrameSliderChange(int sliderValue)
|
private void OnFrameSliderChange(int sliderValue)
|
||||||
{
|
{
|
||||||
if (_currentPlayerSession != null)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameLast_clicked()
|
private void OnFrameLast_clicked()
|
||||||
{
|
{
|
||||||
if (_currentPlayerSession != null)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||||
_frameSlider.value = _rangeIndex;
|
_frameSlider.value = _rangeIndex;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameNext_clicked()
|
private void OnFrameNext_clicked()
|
||||||
{
|
{
|
||||||
if (_currentPlayerSession != null)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||||
_frameSlider.value = _rangeIndex;
|
_frameSlider.value = _rangeIndex;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameClear_clicked()
|
private void OnFrameClear_clicked()
|
||||||
{
|
{
|
||||||
if (_currentPlayerSession != null)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_frameSlider.label = $"Frame:";
|
_frameSlider.label = $"Frame:";
|
||||||
_frameSlider.value = 0;
|
_frameSlider.value = 0;
|
||||||
_frameSlider.lowValue = 0;
|
_frameSlider.lowValue = 0;
|
||||||
_frameSlider.highValue = 0;
|
_frameSlider.highValue = 0;
|
||||||
_currentPlayerSession.ClearDebugReport();
|
_currentPlayerSession.ClearDebugReport();
|
||||||
_assetListViewer.ClearView();
|
_assetListViewer.ClearView();
|
||||||
_bundleListViewer.ClearView();
|
_bundleListViewer.ClearView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||||
{
|
{
|
||||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||||
{
|
{
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||||
_playerSessions.Add(playerId, newSession);
|
_playerSessions.Add(playerId, newSession);
|
||||||
return newSession;
|
return newSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void UpdateFrameView(RemotePlayerSession playerSession)
|
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||||
{
|
{
|
||||||
if (playerSession != null)
|
if (playerSession != null)
|
||||||
{
|
{
|
||||||
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||||
{
|
{
|
||||||
if (playerSession == null)
|
if (playerSession == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||||
if (debugReport != null)
|
if (debugReport != null)
|
||||||
{
|
{
|
||||||
_currentReport = debugReport;
|
_currentReport = debugReport;
|
||||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SampleBtn_onClick()
|
private void SampleBtn_onClick()
|
||||||
{
|
{
|
||||||
// 发送采集数据的命令
|
// 发送采集数据的命令
|
||||||
RemoteCommand command = new RemoteCommand();
|
RemoteCommand command = new RemoteCommand();
|
||||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||||
command.CommandParam = string.Empty;
|
command.CommandParam = string.Empty;
|
||||||
byte[] data = RemoteCommand.Serialize(command);
|
byte[] data = RemoteCommand.Serialize(command);
|
||||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||||
}
|
}
|
||||||
private void ExportBtn_clicked()
|
private void ExportBtn_clicked()
|
||||||
{
|
{
|
||||||
if (_currentReport == null)
|
if (_currentReport == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("Debug report is null.");
|
Debug.LogWarning("Debug report is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||||
if (resultPath != null)
|
if (resultPath != null)
|
||||||
{
|
{
|
||||||
// 注意:排序保证生成配置的稳定性
|
// 注意:排序保证生成配置的稳定性
|
||||||
foreach (var packageData in _currentReport.PackageDatas)
|
foreach (var packageData in _currentReport.PackageDatas)
|
||||||
{
|
{
|
||||||
packageData.ProviderInfos.Sort();
|
packageData.ProviderInfos.Sort();
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
providerInfo.DependBundleInfos.Sort();
|
providerInfo.DependBundleInfos.Sort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||||
FileUtility.WriteAllText(filePath, fileContent);
|
FileUtility.WriteAllText(filePath, fileContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
if (_currentReport != null)
|
if (_currentReport != null)
|
||||||
{
|
{
|
||||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var viewMode = (EViewMode)action.userData;
|
var viewMode = (EViewMode)action.userData;
|
||||||
if (_viewMode != viewMode)
|
if (_viewMode != viewMode)
|
||||||
{
|
{
|
||||||
_viewMode = viewMode;
|
_viewMode = viewMode;
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
_viewModeMenu.text = viewMode.ToString();
|
_viewModeMenu.text = viewMode.ToString();
|
||||||
|
|
||||||
if (viewMode == EViewMode.AssetView)
|
if (viewMode == EViewMode.AssetView)
|
||||||
{
|
{
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
_bundleListViewer.DetachParent();
|
_bundleListViewer.DetachParent();
|
||||||
}
|
}
|
||||||
else if (viewMode == EViewMode.BundleView)
|
else if (viewMode == EViewMode.BundleView)
|
||||||
{
|
{
|
||||||
_assetListViewer.DetachParent();
|
_assetListViewer.DetachParent();
|
||||||
_bundleListViewer.AttachParent(root);
|
_bundleListViewer.AttachParent(root);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotImplementedException(viewMode.ToString());
|
throw new NotImplementedException(viewMode.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var viewMode = (EViewMode)action.userData;
|
var viewMode = (EViewMode)action.userData;
|
||||||
if (_viewMode == viewMode)
|
if (_viewMode == viewMode)
|
||||||
return DropdownMenuAction.Status.Checked;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -4,90 +4,90 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class RemotePlayerSession
|
internal class RemotePlayerSession
|
||||||
{
|
{
|
||||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户ID
|
/// 用户ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int PlayerId { private set; get; }
|
public int PlayerId { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存的报告最大数量
|
/// 保存的报告最大数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxReportCount { private set; get; }
|
public int MaxReportCount { private set; get; }
|
||||||
|
|
||||||
public int MinRangeValue
|
public int MinRangeValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int MaxRangeValue
|
public int MaxRangeValue
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int index = _reportList.Count - 1;
|
int index = _reportList.Count - 1;
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||||
{
|
{
|
||||||
PlayerId = playerId;
|
PlayerId = playerId;
|
||||||
MaxReportCount = maxReportCount;
|
MaxReportCount = maxReportCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存数据
|
/// 清理缓存数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearDebugReport()
|
public void ClearDebugReport()
|
||||||
{
|
{
|
||||||
_reportList.Clear();
|
_reportList.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个调试报告
|
/// 添加一个调试报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddDebugReport(DebugReport report)
|
public void AddDebugReport(DebugReport report)
|
||||||
{
|
{
|
||||||
if (report == null)
|
if (report == null)
|
||||||
Debug.LogWarning("Invalid debug report data !");
|
Debug.LogWarning("Invalid debug report data !");
|
||||||
|
|
||||||
if (_reportList.Count >= MaxReportCount)
|
if (_reportList.Count >= MaxReportCount)
|
||||||
_reportList.RemoveAt(0);
|
_reportList.RemoveAt(0);
|
||||||
_reportList.Add(report);
|
_reportList.Add(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取调试报告
|
/// 获取调试报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DebugReport GetDebugReport(int rangeIndex)
|
public DebugReport GetDebugReport(int rangeIndex)
|
||||||
{
|
{
|
||||||
if (_reportList.Count == 0)
|
if (_reportList.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||||
return null;
|
return null;
|
||||||
return _reportList[rangeIndex];
|
return _reportList[rangeIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 规范索引值
|
/// 规范索引值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ClampRangeIndex(int rangeIndex)
|
public int ClampRangeIndex(int rangeIndex)
|
||||||
{
|
{
|
||||||
if (rangeIndex < 0)
|
if (rangeIndex < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (rangeIndex > MaxRangeValue)
|
if (rangeIndex > MaxRangeValue)
|
||||||
return MaxRangeValue;
|
return MaxRangeValue;
|
||||||
|
|
||||||
return rangeIndex;
|
return rangeIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,300 +9,300 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class DebuggerAssetListViewer
|
internal class DebuggerAssetListViewer
|
||||||
{
|
{
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ListView _assetListView;
|
private ListView _assetListView;
|
||||||
private ListView _dependListView;
|
private ListView _dependListView;
|
||||||
private DebugReport _debugReport;
|
private DebugReport _debugReport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerAssetListViewer>();
|
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||||
if (_visualAsset == null)
|
if (_visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源列表
|
// 资源列表
|
||||||
_assetListView = _root.Q<ListView>("TopListView");
|
_assetListView = _root.Q<ListView>("TopListView");
|
||||||
_assetListView.makeItem = MakeAssetListViewItem;
|
_assetListView.makeItem = MakeAssetListViewItem;
|
||||||
_assetListView.bindItem = BindAssetListViewItem;
|
_assetListView.bindItem = BindAssetListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
#if UNITY_2020_1_OR_NEWER
|
||||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 依赖列表
|
// 依赖列表
|
||||||
_dependListView = _root.Q<ListView>("BottomListView");
|
_dependListView = _root.Q<ListView>("BottomListView");
|
||||||
_dependListView.makeItem = MakeDependListViewItem;
|
_dependListView.makeItem = MakeDependListViewItem;
|
||||||
_dependListView.bindItem = BindDependListViewItem;
|
_dependListView.bindItem = BindDependListViewItem;
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#if UNITY_2020_3_OR_NEWER
|
||||||
SplitView.Adjuster(_root);
|
SplitView.Adjuster(_root);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空页面
|
/// 清空页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
_debugReport = null;
|
||||||
_assetListView.Clear();
|
_assetListView.Clear();
|
||||||
_assetListView.ClearSelection();
|
_assetListView.ClearSelection();
|
||||||
_assetListView.itemsSource.Clear();
|
_assetListView.itemsSource.Clear();
|
||||||
_assetListView.Rebuild();
|
_assetListView.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
_debugReport = debugReport;
|
||||||
_assetListView.Clear();
|
_assetListView.Clear();
|
||||||
_assetListView.ClearSelection();
|
_assetListView.ClearSelection();
|
||||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||||
_assetListView.Rebuild();
|
_assetListView.Rebuild();
|
||||||
}
|
}
|
||||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||||
foreach (var packageData in debugReport.PackageDatas)
|
foreach (var packageData in debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
{
|
{
|
||||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
providerInfo.PackageName = packageData.PackageName;
|
providerInfo.PackageName = packageData.PackageName;
|
||||||
tempList.Add(providerInfo);
|
tempList.Add(providerInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
tempList.Sort();
|
tempList.Sort();
|
||||||
result.AddRange(tempList);
|
result.AddRange(tempList);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 挂接到父类页面上
|
/// 挂接到父类页面上
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AttachParent(VisualElement parent)
|
public void AttachParent(VisualElement parent)
|
||||||
{
|
{
|
||||||
parent.Add(_root);
|
parent.Add(_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从父类页面脱离开
|
/// 从父类页面脱离开
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DetachParent()
|
public void DetachParent()
|
||||||
{
|
{
|
||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 顶部列表相关
|
// 顶部列表相关
|
||||||
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();
|
var label = new Label();
|
||||||
label.name = "Label0";
|
label.name = "Label0";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
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 = 280;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label2";
|
label.name = "Label2";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label4";
|
label.name = "Label4";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
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.flexGrow = 1f;
|
||||||
label.style.width = 100;
|
label.style.width = 100;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label6";
|
label.name = "Label6";
|
||||||
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 = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindAssetListViewItem(VisualElement element, int index)
|
private void BindAssetListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||||
var providerInfo = sourceData[index];
|
var providerInfo = sourceData[index];
|
||||||
|
|
||||||
// Package Name
|
// Package Name
|
||||||
var label0 = element.Q<Label>("Label0");
|
var label0 = element.Q<Label>("Label0");
|
||||||
label0.text = providerInfo.PackageName;
|
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;
|
||||||
|
|
||||||
// Spawn Scene
|
// Spawn Scene
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = providerInfo.SpawnScene;
|
label2.text = providerInfo.SpawnScene;
|
||||||
|
|
||||||
// Spawn Time
|
// Spawn Time
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = providerInfo.SpawnTime;
|
label3.text = providerInfo.SpawnTime;
|
||||||
|
|
||||||
// Loading Time
|
// Loading Time
|
||||||
var label4 = element.Q<Label>("Label4");
|
var label4 = element.Q<Label>("Label4");
|
||||||
label4.text = providerInfo.LoadingTime.ToString();
|
label4.text = providerInfo.LoadingTime.ToString();
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label5 = element.Q<Label>("Label5");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label5.text = providerInfo.RefCount.ToString();
|
label5.text = providerInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
var label6 = element.Q<Label>("Label6");
|
var label6 = element.Q<Label>("Label6");
|
||||||
label6.text = providerInfo.Status.ToString();
|
label6.text = providerInfo.Status.ToString();
|
||||||
label6.style.color = textColor;
|
label6.style.color = textColor;
|
||||||
}
|
}
|
||||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
foreach (var item in objs)
|
foreach (var item in objs)
|
||||||
{
|
{
|
||||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||||
FillDependListView(providerInfo);
|
FillDependListView(providerInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部列表相关
|
// 底部列表相关
|
||||||
private VisualElement MakeDependListViewItem()
|
private VisualElement MakeDependListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
element.style.flexDirection = FlexDirection.Row;
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
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 = 280;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
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 = 100;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label4";
|
label.name = "Label4";
|
||||||
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 = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindDependListViewItem(VisualElement element, int index)
|
private void BindDependListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||||
DebugBundleInfo bundleInfo = bundles[index];
|
DebugBundleInfo bundleInfo = bundles[index];
|
||||||
|
|
||||||
// Bundle Name
|
// Bundle Name
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = bundleInfo.BundleName;
|
label1.text = bundleInfo.BundleName;
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.RefCount.ToString();
|
label3.text = bundleInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
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 selectedProviderInfo)
|
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||||
{
|
{
|
||||||
_dependListView.Clear();
|
_dependListView.Clear();
|
||||||
_dependListView.ClearSelection();
|
_dependListView.ClearSelection();
|
||||||
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||||
_dependListView.Rebuild();
|
_dependListView.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -9,312 +9,312 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class DebuggerBundleListViewer
|
internal class DebuggerBundleListViewer
|
||||||
{
|
{
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ListView _bundleListView;
|
private ListView _bundleListView;
|
||||||
private ListView _usingListView;
|
private ListView _usingListView;
|
||||||
private DebugReport _debugReport;
|
private DebugReport _debugReport;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitViewer()
|
public void InitViewer()
|
||||||
{
|
{
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerBundleListViewer>();
|
_visualAsset = UxmlLoader.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 = MakeBundleListViewItem;
|
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||||
_bundleListView.bindItem = BindBundleListViewItem;
|
_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
|
||||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 使用列表
|
// 使用列表
|
||||||
_usingListView = _root.Q<ListView>("BottomListView");
|
_usingListView = _root.Q<ListView>("BottomListView");
|
||||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||||
_usingListView.bindItem = BindIncludeListViewItem;
|
_usingListView.bindItem = BindIncludeListViewItem;
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#if UNITY_2020_3_OR_NEWER
|
||||||
SplitView.Adjuster(_root);
|
SplitView.Adjuster(_root);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空页面
|
/// 清空页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
_debugReport = null;
|
||||||
_bundleListView.Clear();
|
_bundleListView.Clear();
|
||||||
_bundleListView.ClearSelection();
|
_bundleListView.ClearSelection();
|
||||||
_bundleListView.itemsSource.Clear();
|
_bundleListView.itemsSource.Clear();
|
||||||
_bundleListView.Rebuild();
|
_bundleListView.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
_debugReport = debugReport;
|
||||||
_bundleListView.Clear();
|
_bundleListView.Clear();
|
||||||
_bundleListView.ClearSelection();
|
_bundleListView.ClearSelection();
|
||||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||||
_bundleListView.Rebuild();
|
_bundleListView.Rebuild();
|
||||||
}
|
}
|
||||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||||
foreach (var pakcageData in debugReport.PackageDatas)
|
foreach (var pakcageData in debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||||
foreach (var providerInfo in pakcageData.ProviderInfos)
|
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||||
{
|
{
|
||||||
bundleInfo.PackageName = pakcageData.PackageName;
|
bundleInfo.PackageName = pakcageData.PackageName;
|
||||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tempList = tempDic.Values.ToList();
|
var tempList = tempDic.Values.ToList();
|
||||||
tempList.Sort();
|
tempList.Sort();
|
||||||
result.AddRange(tempList);
|
result.AddRange(tempList);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 挂接到父类页面上
|
/// 挂接到父类页面上
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AttachParent(VisualElement parent)
|
public void AttachParent(VisualElement parent)
|
||||||
{
|
{
|
||||||
parent.Add(_root);
|
parent.Add(_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从父类页面脱离开
|
/// 从父类页面脱离开
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DetachParent()
|
public void DetachParent()
|
||||||
{
|
{
|
||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 顶部列表相关
|
// 顶部列表相关
|
||||||
private VisualElement MakeBundleListViewItem()
|
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();
|
var label = new Label();
|
||||||
label.name = "Label0";
|
label.name = "Label0";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
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 = 280;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
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 = 100;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label4";
|
label.name = "Label4";
|
||||||
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 = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindBundleListViewItem(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
|
// Package Name
|
||||||
var label0 = element.Q<Label>("Label0");
|
var label0 = element.Q<Label>("Label0");
|
||||||
label0.text = bundleInfo.PackageName;
|
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;
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.RefCount.ToString();
|
label3.text = bundleInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
var label4 = element.Q<Label>("Label4");
|
var label4 = element.Q<Label>("Label4");
|
||||||
label4.text = bundleInfo.Status.ToString();
|
label4.text = bundleInfo.Status.ToString();
|
||||||
label4.style.color = textColor;
|
label4.style.color = textColor;
|
||||||
}
|
}
|
||||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
foreach (var item in objs)
|
foreach (var item in objs)
|
||||||
{
|
{
|
||||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||||
FillUsingListView(bundleInfo);
|
FillUsingListView(bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 底部列表相关
|
// 底部列表相关
|
||||||
private VisualElement MakeIncludeListViewItem()
|
private VisualElement MakeIncludeListViewItem()
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
VisualElement element = new VisualElement();
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
element.style.flexDirection = FlexDirection.Row;
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label1";
|
label.name = "Label1";
|
||||||
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 = 280;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label2";
|
label.name = "Label2";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
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 = 150;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label4";
|
label.name = "Label4";
|
||||||
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 = 100;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
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.flexGrow = 1f;
|
||||||
label.style.width = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||||
DebugProviderInfo providerInfo = providers[index];
|
DebugProviderInfo providerInfo = providers[index];
|
||||||
|
|
||||||
// Asset Path
|
// Asset Path
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = providerInfo.AssetPath;
|
label1.text = providerInfo.AssetPath;
|
||||||
|
|
||||||
// Spawn Scene
|
// Spawn Scene
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = providerInfo.SpawnScene;
|
label2.text = providerInfo.SpawnScene;
|
||||||
|
|
||||||
// Spawn Time
|
// Spawn Time
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = providerInfo.SpawnTime;
|
label3.text = providerInfo.SpawnTime;
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label4 = element.Q<Label>("Label4");
|
var label4 = element.Q<Label>("Label4");
|
||||||
label4.text = providerInfo.RefCount.ToString();
|
label4.text = providerInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
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(DebugBundleInfo selectedBundleInfo)
|
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||||
{
|
{
|
||||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||||
foreach (var packageData in _debugReport.PackageDatas)
|
foreach (var packageData in _debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||||
{
|
{
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||||
{
|
{
|
||||||
source.Add(providerInfo);
|
source.Add(providerInfo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_usingListView.Clear();
|
_usingListView.Clear();
|
||||||
_usingListView.ClearSelection();
|
_usingListView.ClearSelection();
|
||||||
_usingListView.itemsSource = source;
|
_usingListView.itemsSource = source;
|
||||||
_usingListView.Rebuild();
|
_usingListView.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -4,43 +4,43 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleInspector
|
public class AssetBundleInspector
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(AssetBundle))]
|
[CustomEditor(typeof(AssetBundle))]
|
||||||
internal class AssetBundleEditor : UnityEditor.Editor
|
internal class AssetBundleEditor : UnityEditor.Editor
|
||||||
{
|
{
|
||||||
internal bool pathFoldout = false;
|
internal bool pathFoldout = false;
|
||||||
internal bool advancedFoldout = false;
|
internal bool advancedFoldout = false;
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI()
|
||||||
{
|
{
|
||||||
AssetBundle bundle = target as AssetBundle;
|
AssetBundle bundle = target as AssetBundle;
|
||||||
|
|
||||||
using (new EditorGUI.DisabledScope(true))
|
using (new EditorGUI.DisabledScope(true))
|
||||||
{
|
{
|
||||||
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
||||||
leftStyle.alignment = TextAnchor.UpperLeft;
|
leftStyle.alignment = TextAnchor.UpperLeft;
|
||||||
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
||||||
|
|
||||||
var assetNames = bundle.GetAllAssetNames();
|
var assetNames = bundle.GetAllAssetNames();
|
||||||
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
||||||
if (pathFoldout)
|
if (pathFoldout)
|
||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
foreach (var asset in assetNames)
|
foreach (var asset in assetNames)
|
||||||
EditorGUILayout.LabelField(asset);
|
EditorGUILayout.LabelField(asset);
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
|
|
||||||
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advancedFoldout)
|
if (advancedFoldout)
|
||||||
{
|
{
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
base.OnInspectorGUI();
|
base.OnInspectorGUI();
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,61 +5,61 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public static class AssetBundleRecorder
|
public static class AssetBundleRecorder
|
||||||
{
|
{
|
||||||
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AssetBundle GetAssetBundle(string filePath)
|
public static AssetBundle GetAssetBundle(string filePath)
|
||||||
{
|
{
|
||||||
// 如果文件不存在
|
// 如果文件不存在
|
||||||
if (File.Exists(filePath) == false)
|
if (File.Exists(filePath) == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证文件有效性(可能文件被加密)
|
// 验证文件有效性(可能文件被加密)
|
||||||
byte[] fileData = File.ReadAllBytes(filePath);
|
byte[] fileData = File.ReadAllBytes(filePath);
|
||||||
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
||||||
{
|
{
|
||||||
return bundle;
|
return bundle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||||
if(newBundle != null)
|
if (newBundle != null)
|
||||||
{
|
{
|
||||||
string[] assetNames = newBundle.GetAllAssetNames();
|
string[] assetNames = newBundle.GetAllAssetNames();
|
||||||
foreach (string name in assetNames)
|
foreach (string name in assetNames)
|
||||||
{
|
{
|
||||||
newBundle.LoadAsset(name);
|
newBundle.LoadAsset(name);
|
||||||
}
|
}
|
||||||
_loadedAssetBundles.Add(filePath, newBundle);
|
_loadedAssetBundles.Add(filePath, newBundle);
|
||||||
}
|
}
|
||||||
return newBundle;
|
return newBundle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 卸载所有已经加载的AssetBundle文件
|
/// 卸载所有已经加载的AssetBundle文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UnloadAll()
|
public static void UnloadAll()
|
||||||
{
|
{
|
||||||
foreach(var valuePair in _loadedAssetBundles)
|
foreach (var valuePair in _loadedAssetBundles)
|
||||||
{
|
{
|
||||||
if (valuePair.Value != null)
|
if (valuePair.Value != null)
|
||||||
valuePair.Value.Unload(true);
|
valuePair.Value.Unload(true);
|
||||||
}
|
}
|
||||||
_loadedAssetBundles.Clear();
|
_loadedAssetBundles.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,215 +7,215 @@ using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class AssetBundleReporterWindow : EditorWindow
|
public class AssetBundleReporterWindow : EditorWindow
|
||||||
{
|
{
|
||||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||||
public static void OpenWindow()
|
public static void OpenWindow()
|
||||||
{
|
{
|
||||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
|
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||||
window.minSize = new Vector2(800, 600);
|
window.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 视图模式
|
/// 视图模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private enum EViewMode
|
private enum EViewMode
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 概览视图
|
/// 概览视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Summary,
|
Summary,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象视图
|
/// 资源对象视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AssetView,
|
AssetView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包视图
|
/// 资源包视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleView,
|
BundleView,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余资源试图
|
/// 冗余资源试图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Redundancy,
|
Redundancy,
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
private ReporterSummaryViewer _summaryViewer;
|
private ReporterSummaryViewer _summaryViewer;
|
||||||
private ReporterAssetListViewer _assetListViewer;
|
private ReporterAssetListViewer _assetListViewer;
|
||||||
private ReporterBundleListViewer _bundleListViewer;
|
private ReporterBundleListViewer _bundleListViewer;
|
||||||
private ReporterRedundancyListViewer _redundancyListViewer;
|
private ReporterRedundancyListViewer _redundancyListViewer;
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
private string _reportFilePath;
|
private string _reportFilePath;
|
||||||
private string _searchKeyWord;
|
private string _searchKeyWord;
|
||||||
|
|
||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
// 加载布局文件
|
// 加载布局文件
|
||||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
|
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||||
if (visualAsset == null)
|
if (visualAsset == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
|
||||||
|
|
||||||
// 导入按钮
|
visualAsset.CloneTree(root);
|
||||||
var importBtn = root.Q<Button>("ImportButton");
|
|
||||||
importBtn.clicked += ImportBtn_onClick;
|
|
||||||
|
|
||||||
// 视图模式菜单
|
// 导入按钮
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
var importBtn = root.Q<Button>("ImportButton");
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
importBtn.clicked += ImportBtn_onClick;
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.Redundancy.ToString(), ViewModeMenuAction3, ViewModeMenuFun3);
|
|
||||||
|
|
||||||
// 搜索栏
|
// 视图模式菜单
|
||||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
|
||||||
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
|
||||||
|
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
|
||||||
|
_viewModeMenu.menu.AppendAction(EViewMode.Redundancy.ToString(), ViewModeMenuAction3, ViewModeMenuFun3);
|
||||||
|
|
||||||
// 加载视图
|
// 搜索栏
|
||||||
_summaryViewer = new ReporterSummaryViewer();
|
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||||
_summaryViewer.InitViewer();
|
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_assetListViewer = new ReporterAssetListViewer();
|
_summaryViewer = new ReporterSummaryViewer();
|
||||||
_assetListViewer.InitViewer();
|
_summaryViewer.InitViewer();
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
_bundleListViewer = new ReporterBundleListViewer();
|
_assetListViewer = new ReporterAssetListViewer();
|
||||||
_bundleListViewer.InitViewer();
|
_assetListViewer.InitViewer();
|
||||||
|
|
||||||
// 加载试图
|
// 加载视图
|
||||||
_redundancyListViewer = new ReporterRedundancyListViewer();
|
_bundleListViewer = new ReporterBundleListViewer();
|
||||||
_redundancyListViewer.InitViewer();
|
_bundleListViewer.InitViewer();
|
||||||
|
|
||||||
// 显示视图
|
// 加载试图
|
||||||
_viewMode = EViewMode.Summary;
|
_redundancyListViewer = new ReporterRedundancyListViewer();
|
||||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
_redundancyListViewer.InitViewer();
|
||||||
_summaryViewer.AttachParent(root);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.LogError(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void OnDestroy()
|
|
||||||
{
|
|
||||||
AssetBundleRecorder.UnloadAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ImportBtn_onClick()
|
// 显示视图
|
||||||
{
|
_viewMode = EViewMode.Summary;
|
||||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||||
if (string.IsNullOrEmpty(selectFilePath))
|
_summaryViewer.AttachParent(root);
|
||||||
return;
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError(e.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
AssetBundleRecorder.UnloadAll();
|
||||||
|
}
|
||||||
|
|
||||||
_reportFilePath = selectFilePath;
|
private void ImportBtn_onClick()
|
||||||
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
{
|
||||||
_buildReport = BuildReport.Deserialize(jsonData);
|
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
||||||
_summaryViewer.FillViewData(_buildReport);
|
if (string.IsNullOrEmpty(selectFilePath))
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
return;
|
||||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
|
||||||
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_reportFilePath = selectFilePath;
|
||||||
}
|
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
_buildReport = BuildReport.Deserialize(jsonData);
|
||||||
{
|
_summaryViewer.FillViewData(_buildReport);
|
||||||
_searchKeyWord = e.newValue;
|
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
if (_buildReport != null)
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||||
{
|
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
}
|
||||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
}
|
{
|
||||||
}
|
_searchKeyWord = e.newValue;
|
||||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
if (_buildReport != null)
|
||||||
{
|
{
|
||||||
if (_viewMode != EViewMode.Summary)
|
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||||
{
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||||
_viewMode = EViewMode.Summary;
|
}
|
||||||
VisualElement root = this.rootVisualElement;
|
}
|
||||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||||
_summaryViewer.AttachParent(root);
|
{
|
||||||
_assetListViewer.DetachParent();
|
if (_viewMode != EViewMode.Summary)
|
||||||
_bundleListViewer.DetachParent();
|
{
|
||||||
_redundancyListViewer.DetachParent();
|
_viewMode = EViewMode.Summary;
|
||||||
}
|
VisualElement root = this.rootVisualElement;
|
||||||
}
|
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
_summaryViewer.AttachParent(root);
|
||||||
{
|
_assetListViewer.DetachParent();
|
||||||
if (_viewMode != EViewMode.AssetView)
|
_bundleListViewer.DetachParent();
|
||||||
{
|
_redundancyListViewer.DetachParent();
|
||||||
_viewMode = EViewMode.AssetView;
|
}
|
||||||
VisualElement root = this.rootVisualElement;
|
}
|
||||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||||
_summaryViewer.DetachParent();
|
{
|
||||||
_assetListViewer.AttachParent(root);
|
if (_viewMode != EViewMode.AssetView)
|
||||||
_bundleListViewer.DetachParent();
|
{
|
||||||
_redundancyListViewer.DetachParent();
|
_viewMode = EViewMode.AssetView;
|
||||||
}
|
VisualElement root = this.rootVisualElement;
|
||||||
}
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
_summaryViewer.DetachParent();
|
||||||
{
|
_assetListViewer.AttachParent(root);
|
||||||
if (_viewMode != EViewMode.BundleView)
|
_bundleListViewer.DetachParent();
|
||||||
{
|
_redundancyListViewer.DetachParent();
|
||||||
_viewMode = EViewMode.BundleView;
|
}
|
||||||
VisualElement root = this.rootVisualElement;
|
}
|
||||||
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||||
_summaryViewer.DetachParent();
|
{
|
||||||
_assetListViewer.DetachParent();
|
if (_viewMode != EViewMode.BundleView)
|
||||||
_bundleListViewer.AttachParent(root);
|
{
|
||||||
_redundancyListViewer.DetachParent();
|
_viewMode = EViewMode.BundleView;
|
||||||
}
|
VisualElement root = this.rootVisualElement;
|
||||||
}
|
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
||||||
private void ViewModeMenuAction3(DropdownMenuAction action)
|
_summaryViewer.DetachParent();
|
||||||
{
|
_assetListViewer.DetachParent();
|
||||||
if (_viewMode != EViewMode.Redundancy)
|
_bundleListViewer.AttachParent(root);
|
||||||
{
|
_redundancyListViewer.DetachParent();
|
||||||
_viewMode = EViewMode.Redundancy;
|
}
|
||||||
VisualElement root = this.rootVisualElement;
|
}
|
||||||
_viewModeMenu.text = EViewMode.Redundancy.ToString();
|
private void ViewModeMenuAction3(DropdownMenuAction action)
|
||||||
_summaryViewer.DetachParent();
|
{
|
||||||
_assetListViewer.DetachParent();
|
if (_viewMode != EViewMode.Redundancy)
|
||||||
_bundleListViewer.DetachParent();
|
{
|
||||||
_redundancyListViewer.AttachParent(root);
|
_viewMode = EViewMode.Redundancy;
|
||||||
}
|
VisualElement root = this.rootVisualElement;
|
||||||
}
|
_viewModeMenu.text = EViewMode.Redundancy.ToString();
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
_summaryViewer.DetachParent();
|
||||||
{
|
_assetListViewer.DetachParent();
|
||||||
if (_viewMode == EViewMode.Summary)
|
_bundleListViewer.DetachParent();
|
||||||
return DropdownMenuAction.Status.Checked;
|
_redundancyListViewer.AttachParent(root);
|
||||||
else
|
}
|
||||||
return DropdownMenuAction.Status.Normal;
|
}
|
||||||
}
|
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
{
|
||||||
{
|
if (_viewMode == EViewMode.Summary)
|
||||||
if (_viewMode == EViewMode.AssetView)
|
return DropdownMenuAction.Status.Checked;
|
||||||
return DropdownMenuAction.Status.Checked;
|
else
|
||||||
else
|
return DropdownMenuAction.Status.Normal;
|
||||||
return DropdownMenuAction.Status.Normal;
|
}
|
||||||
}
|
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
{
|
||||||
{
|
if (_viewMode == EViewMode.AssetView)
|
||||||
if (_viewMode == EViewMode.BundleView)
|
return DropdownMenuAction.Status.Checked;
|
||||||
return DropdownMenuAction.Status.Checked;
|
else
|
||||||
else
|
return DropdownMenuAction.Status.Normal;
|
||||||
return DropdownMenuAction.Status.Normal;
|
}
|
||||||
}
|
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
||||||
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
|
{
|
||||||
{
|
if (_viewMode == EViewMode.BundleView)
|
||||||
if (_viewMode == EViewMode.Redundancy)
|
return DropdownMenuAction.Status.Checked;
|
||||||
return DropdownMenuAction.Status.Checked;
|
else
|
||||||
else
|
return DropdownMenuAction.Status.Normal;
|
||||||
return DropdownMenuAction.Status.Normal;
|
}
|
||||||
}
|
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
|
||||||
}
|
{
|
||||||
|
if (_viewMode == EViewMode.Redundancy)
|
||||||
|
return DropdownMenuAction.Status.Checked;
|
||||||
|
else
|
||||||
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
|
@ -6,72 +6,72 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建报告
|
/// 构建报告
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BuildReport
|
public class BuildReport
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 汇总信息
|
/// 汇总信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReportSummary Summary = new ReportSummary();
|
public ReportSummary Summary = new ReportSummary();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源对象列表
|
/// 资源对象列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
|
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包列表
|
/// 资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源列表
|
/// 冗余的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
|
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源包信息类
|
|
||||||
/// </summary>
|
|
||||||
public ReportBundleInfo GetBundleInfo(string bundleName)
|
|
||||||
{
|
|
||||||
foreach (var bundleInfo in BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.BundleName == bundleName)
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
throw new Exception($"Not found bundle : {bundleName}");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取资源信息类
|
|
||||||
/// </summary>
|
|
||||||
public ReportAssetInfo GetAssetInfo(string assetPath)
|
|
||||||
{
|
|
||||||
foreach (var assetInfo in AssetInfos)
|
|
||||||
{
|
|
||||||
if (assetInfo.AssetPath == assetPath)
|
|
||||||
return assetInfo;
|
|
||||||
}
|
|
||||||
throw new Exception($"Not found asset : {assetPath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void Serialize(string savePath, BuildReport buildReport)
|
/// <summary>
|
||||||
{
|
/// 获取资源包信息类
|
||||||
if (File.Exists(savePath))
|
/// </summary>
|
||||||
File.Delete(savePath);
|
public ReportBundleInfo GetBundleInfo(string bundleName)
|
||||||
|
{
|
||||||
|
foreach (var bundleInfo in BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.BundleName == bundleName)
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
throw new Exception($"Not found bundle : {bundleName}");
|
||||||
|
}
|
||||||
|
|
||||||
string json = JsonUtility.ToJson(buildReport, true);
|
/// <summary>
|
||||||
FileUtility.WriteAllText(savePath, json);
|
/// 获取资源信息类
|
||||||
}
|
/// </summary>
|
||||||
public static BuildReport Deserialize(string jsonData)
|
public ReportAssetInfo GetAssetInfo(string assetPath)
|
||||||
{
|
{
|
||||||
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
foreach (var assetInfo in AssetInfos)
|
||||||
return report;
|
{
|
||||||
}
|
if (assetInfo.AssetPath == assetPath)
|
||||||
}
|
return assetInfo;
|
||||||
|
}
|
||||||
|
throw new Exception($"Not found asset : {assetPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void Serialize(string savePath, BuildReport buildReport)
|
||||||
|
{
|
||||||
|
if (File.Exists(savePath))
|
||||||
|
File.Delete(savePath);
|
||||||
|
|
||||||
|
string json = JsonUtility.ToJson(buildReport, true);
|
||||||
|
FileUtility.WriteAllText(savePath, json);
|
||||||
|
}
|
||||||
|
public static BuildReport Deserialize(string jsonData)
|
||||||
|
{
|
||||||
|
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
||||||
|
return report;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,43 +4,43 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportAssetInfo
|
public class ReportAssetInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 可寻址地址
|
/// 可寻址地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Address;
|
public string Address;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源GUID
|
/// 资源GUID
|
||||||
/// 说明:Meta文件记录的GUID
|
/// 说明:Meta文件记录的GUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetGUID;
|
public string AssetGUID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源的分类标签
|
/// 资源的分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] AssetTags;
|
public string[] AssetTags;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 所属资源包名称
|
|
||||||
/// </summary>
|
|
||||||
public string MainBundleName;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属资源包的大小
|
/// 所属资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long MainBundleSize;
|
public string MainBundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源路径列表
|
/// 所属资源包的大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependAssets = new List<string>();
|
public long MainBundleSize;
|
||||||
}
|
|
||||||
|
/// <summary>
|
||||||
|
/// 依赖的资源路径列表
|
||||||
|
/// </summary>
|
||||||
|
public List<string> DependAssets = new List<string>();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,63 +5,63 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportBundleInfo
|
public class ReportBundleInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName;
|
public string BundleName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件名称
|
/// 文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileName;
|
public string FileName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件哈希值
|
/// 文件哈希值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileHash;
|
public string FileHash;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件校验码
|
/// 文件校验码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FileCRC;
|
public string FileCRC;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件大小(字节数)
|
/// 文件大小(字节数)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long FileSize;
|
public long FileSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加密文件
|
/// 加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Encrypted;
|
public bool Encrypted;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包标签集合
|
/// 资源包标签集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
public string[] Tags;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包的依赖集合
|
/// 资源包的依赖集合
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> DependBundles;
|
public List<string> DependBundles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 该资源包内包含的所有资源
|
/// 该资源包内包含的所有资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<string> AllBuiltinAssets = new List<string>();
|
public List<string> AllBuiltinAssets = new List<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源分类标签的字符串
|
/// 获取资源分类标签的字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetTagsString()
|
public string GetTagsString()
|
||||||
{
|
{
|
||||||
if (Tags != null)
|
if (Tags != null)
|
||||||
return String.Join(";", Tags);
|
return String.Join(";", Tags);
|
||||||
else
|
else
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,33 +4,33 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportRedundancyInfo
|
public class ReportRedundancyInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源路径
|
/// 资源路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath;
|
public string AssetPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源类型
|
/// 资源类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetType;
|
public string AssetType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源GUID
|
/// 资源GUID
|
||||||
/// 说明:Meta文件记录的GUID
|
/// 说明:Meta文件记录的GUID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetGUID;
|
public string AssetGUID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件大小
|
/// 资源文件大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long FileSize;
|
public long FileSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 冗余的资源包数量
|
/// 冗余的资源包数量
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Number;
|
public int Number;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,75 +5,75 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ReportSummary
|
public class ReportSummary
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// YooAsset版本
|
/// YooAsset版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string YooVersion;
|
public string YooVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引擎版本
|
/// 引擎版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string UnityVersion;
|
public string UnityVersion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建时间
|
/// 构建时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildDate;
|
public string BuildDate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建耗时(单位:秒)
|
/// 构建耗时(单位:秒)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int BuildSeconds;
|
public int BuildSeconds;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建平台
|
/// 构建平台
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode;
|
public EBuildMode BuildMode;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建管线
|
/// 构建管线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPipeline;
|
public string BuildPipeline;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建包裹名称
|
/// 构建包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPackageName;
|
public string BuildPackageName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建包裹版本
|
/// 构建包裹版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPackageVersion;
|
public string BuildPackageVersion;
|
||||||
|
|
||||||
// 收集器配置
|
// 收集器配置
|
||||||
public bool UniqueBundleName;
|
public bool UniqueBundleName;
|
||||||
public bool EnableAddressable;
|
public bool EnableAddressable;
|
||||||
public bool LocationToLower;
|
public bool LocationToLower;
|
||||||
public bool IncludeAssetGUID;
|
public bool IncludeAssetGUID;
|
||||||
public bool IgnoreDefaultType;
|
public bool IgnoreDefaultType;
|
||||||
public bool AutoCollectShaders;
|
public bool AutoCollectShaders;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
public string EncryptionClassName;
|
public string EncryptionClassName;
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle;
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
public bool DisableWriteTypeTree;
|
public bool DisableWriteTypeTree;
|
||||||
public bool IgnoreTypeTreeChanges;
|
public bool IgnoreTypeTreeChanges;
|
||||||
|
|
||||||
// 构建结果
|
// 构建结果
|
||||||
public int AssetFileTotalCount;
|
public int AssetFileTotalCount;
|
||||||
public int MainAssetTotalCount;
|
public int MainAssetTotalCount;
|
||||||
public int AllBundleTotalCount;
|
public int AllBundleTotalCount;
|
||||||
public long AllBundleTotalSize;
|
public long AllBundleTotalSize;
|
||||||
public int EncryptedBundleTotalCount;
|
public int EncryptedBundleTotalCount;
|
||||||
public long EncryptedBundleTotalSize;
|
public long EncryptedBundleTotalSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue