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
|
||||
{
|
||||
public class AssetBundleBuilder
|
||||
{
|
||||
private readonly BuildContext _buildContext = new BuildContext();
|
||||
public class AssetBundleBuilder
|
||||
{
|
||||
private readonly BuildContext _buildContext = new BuildContext();
|
||||
|
||||
/// <summary>
|
||||
/// 构建资源包
|
||||
/// </summary>
|
||||
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline, bool enableLog)
|
||||
{
|
||||
// 检测构建参数是否为空
|
||||
if (buildParameters == null)
|
||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||
/// <summary>
|
||||
/// 构建资源包
|
||||
/// </summary>
|
||||
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline, bool enableLog)
|
||||
{
|
||||
// 检测构建参数是否为空
|
||||
if (buildParameters == null)
|
||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||
|
||||
// 检测构建参数是否为空
|
||||
if (buildPipeline.Count == 0)
|
||||
throw new Exception($"Build pipeline is empty !");
|
||||
// 检测构建参数是否为空
|
||||
if (buildPipeline.Count == 0)
|
||||
throw new Exception($"Build pipeline is empty !");
|
||||
|
||||
// 清空旧数据
|
||||
_buildContext.ClearAllContext();
|
||||
// 清空旧数据
|
||||
_buildContext.ClearAllContext();
|
||||
|
||||
// 构建参数
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
// 构建参数
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
|
||||
// 初始化日志
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
// 初始化日志
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
|
||||
// 执行构建流程
|
||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log("Resource pipeline build success");
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
// 执行构建流程
|
||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log("Resource pipeline build success");
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,23 +6,23 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的输出根路录
|
||||
/// </summary>
|
||||
public static string GetDefaultBuildOutputRoot()
|
||||
{
|
||||
string projectPath = EditorTools.GetProjectPath();
|
||||
return $"{projectPath}/Bundles";
|
||||
}
|
||||
public static class AssetBundleBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的输出根路录
|
||||
/// </summary>
|
||||
public static string GetDefaultBuildOutputRoot()
|
||||
{
|
||||
string projectPath = EditorTools.GetProjectPath();
|
||||
return $"{projectPath}/Bundles";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取流文件夹路径
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取流文件夹路径
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,90 +4,90 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderSetting
|
||||
{
|
||||
// EBuildPipeline
|
||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||
}
|
||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||
}
|
||||
public static class AssetBundleBuilderSetting
|
||||
{
|
||||
// EBuildPipeline
|
||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||
}
|
||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||
}
|
||||
|
||||
// EBuildMode
|
||||
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
||||
}
|
||||
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||
EditorPrefs.SetInt(key, (int)buildMode);
|
||||
}
|
||||
// EBuildMode
|
||||
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
||||
}
|
||||
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
||||
EditorPrefs.SetInt(key, (int)buildMode);
|
||||
}
|
||||
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||
}
|
||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
EditorPrefs.SetInt(key, (int)compressOption);
|
||||
}
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||
}
|
||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
EditorPrefs.SetInt(key, (int)compressOption);
|
||||
}
|
||||
|
||||
// EFileNameStyle
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||
}
|
||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
// EFileNameStyle
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||
}
|
||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionClassName
|
||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
}
|
||||
// EncyptionClassName
|
||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,153 +9,153 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilderWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
public class AssetBundleBuilderWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private string _buildPackage;
|
||||
private EBuildPipeline _buildPipeline;
|
||||
private string _buildPackage;
|
||||
private EBuildPipeline _buildPipeline;
|
||||
|
||||
private Toolbar _toolbar;
|
||||
private ToolbarMenu _packageMenu;
|
||||
private ToolbarMenu _pipelineMenu;
|
||||
private VisualElement _container;
|
||||
private Toolbar _toolbar;
|
||||
private ToolbarMenu _packageMenu;
|
||||
private ToolbarMenu _pipelineMenu;
|
||||
private VisualElement _container;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
_toolbar = root.Q<Toolbar>("Toolbar");
|
||||
_container = root.Q("Container");
|
||||
visualAsset.CloneTree(root);
|
||||
_toolbar = root.Q<Toolbar>("Toolbar");
|
||||
_container = root.Q("Container");
|
||||
|
||||
// 检测构建包裹
|
||||
var packageNames = GetBuildPackageNames();
|
||||
if (packageNames.Count == 0)
|
||||
{
|
||||
var label = new Label();
|
||||
label.text = "Not found any package";
|
||||
label.style.width = 100;
|
||||
_toolbar.Add(label);
|
||||
return;
|
||||
}
|
||||
// 检测构建包裹
|
||||
var packageNames = GetBuildPackageNames();
|
||||
if (packageNames.Count == 0)
|
||||
{
|
||||
var label = new Label();
|
||||
label.text = "Not found any package";
|
||||
label.style.width = 100;
|
||||
_toolbar.Add(label);
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建包裹
|
||||
{
|
||||
_buildPackage = packageNames[0];
|
||||
_packageMenu = new ToolbarMenu();
|
||||
_packageMenu.style.width = 200;
|
||||
foreach (var packageName in packageNames)
|
||||
{
|
||||
_packageMenu.menu.AppendAction(packageName, PackageMenuAction, PackageMenuFun, packageName);
|
||||
}
|
||||
_toolbar.Add(_packageMenu);
|
||||
}
|
||||
// 构建包裹
|
||||
{
|
||||
_buildPackage = packageNames[0];
|
||||
_packageMenu = new ToolbarMenu();
|
||||
_packageMenu.style.width = 200;
|
||||
foreach (var packageName in packageNames)
|
||||
{
|
||||
_packageMenu.menu.AppendAction(packageName, PackageMenuAction, PackageMenuFun, packageName);
|
||||
}
|
||||
_toolbar.Add(_packageMenu);
|
||||
}
|
||||
|
||||
// 构建管线
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_pipelineMenu.style.width = 200;
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||
_toolbar.Add(_pipelineMenu);
|
||||
}
|
||||
// 构建管线
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_pipelineMenu.style.width = 200;
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||
_toolbar.Add(_pipelineMenu);
|
||||
}
|
||||
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshBuildPipelineView()
|
||||
{
|
||||
// 清空扩展区域
|
||||
_container.Clear();
|
||||
private void RefreshBuildPipelineView()
|
||||
{
|
||||
// 清空扩展区域
|
||||
_container.Clear();
|
||||
|
||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||
_packageMenu.text = _buildPackage;
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||
_packageMenu.text = _buildPackage;
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||
{
|
||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||
}
|
||||
}
|
||||
private List<string> GetBuildPackageNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
result.Add(package.PackageName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||
{
|
||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||
}
|
||||
}
|
||||
private List<string> GetBuildPackageNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
result.Add(package.PackageName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void PackageMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage != packageName)
|
||||
{
|
||||
_buildPackage = packageName;
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PackageMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage == packageName)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private void PackageMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage != packageName)
|
||||
{
|
||||
_buildPackage = packageName;
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PackageMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage == packageName)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
|
||||
private void PipelineMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline != pipelineType)
|
||||
{
|
||||
_buildPipeline = pipelineType;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline == pipelineType)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
private void PipelineMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline != pipelineType)
|
||||
{
|
||||
_buildPipeline = pipelineType;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline == pipelineType)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -3,98 +3,98 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleSimulateBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||
{
|
||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
||||
{
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
public static class AssetBundleSimulateBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||
{
|
||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
||||
{
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, false);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
||||
{
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, false);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
||||
{
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
{
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
{
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(buildPipelineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(buildPipelineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,155 +5,155 @@ using System.Linq;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildAssetInfo
|
||||
{
|
||||
private bool _isAddAssetTags = false;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
public class BuildAssetInfo
|
||||
{
|
||||
private bool _isAddAssetTags = false;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包完整名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源包完整名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// </summary>
|
||||
public string AssetGUID { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// </summary>
|
||||
public string AssetGUID { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public System.Type AssetType { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public System.Type AssetType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> AssetTags = new List<string>();
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> AssetTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||
|
||||
|
||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
}
|
||||
public BuildAssetInfo(string assetPath)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
BundleName = string.Empty;
|
||||
Address = string.Empty;
|
||||
AssetPath = assetPath;
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
}
|
||||
public BuildAssetInfo(string assetPath)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
BundleName = string.Empty;
|
||||
Address = string.Empty;
|
||||
AssetPath = assetPath;
|
||||
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
}
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置所有依赖的资源
|
||||
/// </summary>
|
||||
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||
{
|
||||
if (AllDependAssetInfos != null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
/// <summary>
|
||||
/// 设置所有依赖的资源
|
||||
/// </summary>
|
||||
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||
{
|
||||
if (AllDependAssetInfos != null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置为统一的着色器包名
|
||||
/// </summary>
|
||||
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置为统一的着色器包名
|
||||
/// </summary>
|
||||
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
/// </summary>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new Exception("Should never get here !");
|
||||
_isAddAssetTags = true;
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
/// </summary>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new Exception("Should never get here !");
|
||||
_isAddAssetTags = true;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag) == false)
|
||||
{
|
||||
AssetTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag) == false)
|
||||
{
|
||||
AssetTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加关联的资源包名称
|
||||
/// </summary>
|
||||
public void AddReferenceBundleName(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
/// <summary>
|
||||
/// 添加关联的资源包名称
|
||||
/// </summary>
|
||||
public void AddReferenceBundleName(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||
_referenceBundleNames.Add(bundleName);
|
||||
}
|
||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||
_referenceBundleNames.Add(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名是否存在
|
||||
/// </summary>
|
||||
public bool HasBundleName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BundleName))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源包名是否存在
|
||||
/// </summary>
|
||||
public bool HasBundleName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BundleName))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为冗余资源
|
||||
/// </summary>
|
||||
public bool IsRedundancyAsset()
|
||||
{
|
||||
if (HasBundleName())
|
||||
return false;
|
||||
/// <summary>
|
||||
/// 判断是否为冗余资源
|
||||
/// </summary>
|
||||
public bool IsRedundancyAsset()
|
||||
{
|
||||
if (HasBundleName())
|
||||
return false;
|
||||
|
||||
return _referenceBundleNames.Count > 1;
|
||||
}
|
||||
return _referenceBundleNames.Count > 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取关联资源包的数量
|
||||
/// </summary>
|
||||
public int GetReferenceBundleCount()
|
||||
{
|
||||
return _referenceBundleNames.Count;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取关联资源包的数量
|
||||
/// </summary>
|
||||
public int GetReferenceBundleCount()
|
||||
{
|
||||
return _referenceBundleNames.Count;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,171 +6,171 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildBundleInfo
|
||||
{
|
||||
#region 补丁文件的关键信息
|
||||
/// <summary>
|
||||
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
||||
/// </summary>
|
||||
public string PackageUnityHash { set; get; }
|
||||
public class BuildBundleInfo
|
||||
{
|
||||
#region 补丁文件的关键信息
|
||||
/// <summary>
|
||||
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
||||
/// </summary>
|
||||
public string PackageUnityHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Unity引擎生成的CRC
|
||||
/// </summary>
|
||||
public uint PackageUnityCRC { set; get; }
|
||||
/// <summary>
|
||||
/// Unity引擎生成的CRC
|
||||
/// </summary>
|
||||
public uint PackageUnityCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileHash { set; get; }
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileCRC { set; get; }
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public long PackageFileSize { set; get; }
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public long PackageFileSize { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建输出的文件路径
|
||||
/// </summary>
|
||||
public string BuildOutputFilePath { set; get; }
|
||||
/// <summary>
|
||||
/// 构建输出的文件路径
|
||||
/// </summary>
|
||||
public string BuildOutputFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的源文件路径
|
||||
/// </summary>
|
||||
public string PackageSourceFilePath { set; get; }
|
||||
/// <summary>
|
||||
/// 补丁包的源文件路径
|
||||
/// </summary>
|
||||
public string PackageSourceFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的目标文件路径
|
||||
/// </summary>
|
||||
public string PackageDestFilePath { set; get; }
|
||||
/// <summary>
|
||||
/// 补丁包的目标文件路径
|
||||
/// </summary>
|
||||
public string PackageDestFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密生成文件的路径
|
||||
/// 注意:如果未加密该路径为空
|
||||
/// </summary>
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 加密生成文件的路径
|
||||
/// 注意:如果未加密该路径为空
|
||||
/// </summary>
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public bool Encrypted { set; get; }
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public bool Encrypted { set; get; }
|
||||
|
||||
|
||||
public BuildBundleInfo(string bundleName)
|
||||
{
|
||||
BundleName = bundleName;
|
||||
}
|
||||
public BuildBundleInfo(string bundleName)
|
||||
{
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
if (IsContainsAsset(assetInfo.AssetPath))
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
if (IsContainsAsset(assetInfo.AssetPath))
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetInfo.AssetPath}");
|
||||
|
||||
MainAssets.Add(assetInfo);
|
||||
}
|
||||
MainAssets.Add(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
{
|
||||
foreach (var assetInfo in MainAssets)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
{
|
||||
foreach (var assetInfo in MainAssets)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetAllMainAssetPaths()
|
||||
{
|
||||
return MainAssets.Select(t => t.AssetPath).ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetAllMainAssetPaths()
|
||||
{
|
||||
return MainAssets.Select(t => t.AssetPath).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||
/// </summary>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(packAssets);
|
||||
foreach (var assetInfo in MainAssets)
|
||||
{
|
||||
if (assetInfo.AllDependAssetInfos == null)
|
||||
continue;
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||
/// </summary>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(packAssets);
|
||||
foreach (var assetInfo in MainAssets)
|
||||
{
|
||||
if (assetInfo.AllDependAssetInfos == null)
|
||||
continue;
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
if (result.Contains(dependAssetInfo.AssetPath) == false)
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
{
|
||||
// 注意:我们不在支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllMainAssetPaths();
|
||||
return build;
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
{
|
||||
// 注意:我们不在支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllMainAssetPaths();
|
||||
return build;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有写入补丁清单的资源
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有写入补丁清单的资源
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建PackageBundle类
|
||||
/// </summary>
|
||||
internal PackageBundle CreatePackageBundle()
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCRC = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.Encrypted = Encrypted;
|
||||
return packageBundle;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建PackageBundle类
|
||||
/// </summary>
|
||||
internal PackageBundle CreatePackageBundle()
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCRC = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.Encrypted = Encrypted;
|
||||
return packageBundle;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,106 +6,106 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildMapContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包集合
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||
public class BuildMapContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包集合
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 冗余的资源列表
|
||||
/// </summary>
|
||||
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
||||
/// <summary>
|
||||
/// 冗余的资源列表
|
||||
/// </summary>
|
||||
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
|
||||
/// <summary>
|
||||
/// 资源收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { set; get; }
|
||||
/// <summary>
|
||||
/// 资源收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包信息列表
|
||||
/// </summary>
|
||||
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bundleInfoDic.Values;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源包信息列表
|
||||
/// </summary>
|
||||
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bundleInfoDic.Values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
string bundleName = assetInfo.BundleName;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
string bundleName = assetInfo.BundleName;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
bundleInfo.PackAsset(assetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
}
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
bundleInfo.PackAsset(assetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源包
|
||||
/// </summary>
|
||||
public bool IsContainsBundle(string bundleName)
|
||||
{
|
||||
return _bundleInfoDic.ContainsKey(bundleName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否包含资源包
|
||||
/// </summary>
|
||||
public bool IsContainsBundle(string bundleName)
|
||||
{
|
||||
return _bundleInfoDic.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包信息,如果没找到返回NULL
|
||||
/// </summary>
|
||||
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||
{
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源包信息,如果没找到返回NULL
|
||||
/// </summary>
|
||||
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||
{
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建着色器信息类
|
||||
/// </summary>
|
||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||
{
|
||||
if (IsContainsBundle(shadersBundleName) == false)
|
||||
{
|
||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建着色器信息类
|
||||
/// </summary>
|
||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||
{
|
||||
if (IsContainsBundle(shadersBundleName) == false)
|
||||
{
|
||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,204 +6,204 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public abstract class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建输出的根目录
|
||||
/// </summary>
|
||||
public string BuildOutputRoot;
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public abstract class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建输出的根目录
|
||||
/// </summary>
|
||||
public string BuildOutputRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的根目录
|
||||
/// </summary>
|
||||
public string BuildinFileRoot;
|
||||
/// <summary>
|
||||
/// 内置文件的根目录
|
||||
/// </summary>
|
||||
public string BuildinFileRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
/// <summary>
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion;
|
||||
/// <summary>
|
||||
/// 构建的包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称样式
|
||||
/// </summary>
|
||||
public EFileNameStyle FileNameStyle;
|
||||
/// <summary>
|
||||
/// 资源包名称样式
|
||||
/// </summary>
|
||||
public EFileNameStyle FileNameStyle;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
/// </summary>
|
||||
public string BuildinFileCopyParams;
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
/// </summary>
|
||||
public string BuildinFileCopyParams;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包加密服务类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
/// <summary>
|
||||
/// 资源包加密服务类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _packageRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = string.Empty;
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _packageRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public virtual void CheckBuildParameters()
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public virtual void CheckBuildParameters()
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 检测是否有未保存场景
|
||||
if (BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
// 检测是否有未保存场景
|
||||
if (BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 强制构建删除包裹目录
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
string packageRootDirectory = GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
// 强制构建删除包裹目录
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
string packageRootDirectory = GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测包裹输出目录是否存在
|
||||
if (BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
// 检测包裹输出目录是否存在
|
||||
if (BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string GetPipelineOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||
{
|
||||
_pipelineOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
return _pipelineOutputDirectory;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string GetPipelineOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||
{
|
||||
_pipelineOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
return _pipelineOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||
{
|
||||
_packageOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
||||
}
|
||||
return _packageOutputDirectory;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||
{
|
||||
_packageOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
||||
}
|
||||
return _packageOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||
{
|
||||
_packageRootDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
||||
}
|
||||
return _packageRootDirectory;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||
{
|
||||
_packageRootDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
||||
}
|
||||
return _packageRootDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public virtual string GetBuildinRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||
{
|
||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||
}
|
||||
return _buildinRootDirectory;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public virtual string GetBuildinRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||
{
|
||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||
}
|
||||
return _buildinRootDirectory;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,58 +6,58 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildParametersContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
public class BuildParametersContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
}
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public void CheckBuildParameters()
|
||||
{
|
||||
Parameters.CheckBuildParameters();
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public void CheckBuildParameters()
|
||||
{
|
||||
Parameters.CheckBuildParameters();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPipelineOutputDirectory();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPipelineOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPackageOutputDirectory();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPackageOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public string GetPackageRootDirectory()
|
||||
{
|
||||
return Parameters.GetPackageRootDirectory();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public string GetPackageRootDirectory()
|
||||
{
|
||||
return Parameters.GetPackageRootDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public string GetBuildinRootDirectory()
|
||||
{
|
||||
return Parameters.GetBuildinRootDirectory();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public string GetBuildinRootDirectory()
|
||||
{
|
||||
return Parameters.GetBuildinRootDirectory();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,77 +6,77 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
{
|
||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
public class TaskCopyBuildinFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
{
|
||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
|
||||
// 清空内置文件的目录
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||
{
|
||||
EditorTools.ClearFolder(buildinRootDirectory);
|
||||
}
|
||||
// 清空内置文件的目录
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||
{
|
||||
EditorTools.ClearFolder(buildinRootDirectory);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
}
|
||||
}
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,215 +5,215 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ManifestContext : IContextObject
|
||||
{
|
||||
internal PackageManifest Manifest;
|
||||
}
|
||||
public class ManifestContext : IContextObject
|
||||
{
|
||||
internal PackageManifest Manifest;
|
||||
}
|
||||
|
||||
public abstract class TaskCreateManifest
|
||||
{
|
||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||
public abstract class TaskCreateManifest
|
||||
{
|
||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
/// </summary>
|
||||
protected void CreateManifestFile(BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
/// </summary>
|
||||
protected void CreateManifestFile(BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
|
||||
// 创建新补丁清单
|
||||
PackageManifest manifest = new PackageManifest();
|
||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
manifest.PackageName = buildParameters.PackageName;
|
||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
||||
// 创建新补丁清单
|
||||
PackageManifest manifest = new PackageManifest();
|
||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
manifest.PackageName = buildParameters.PackageName;
|
||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
||||
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
// 处理资源包的依赖列表
|
||||
ProcessBundleDepends(context, manifest);
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
// 处理资源包的依赖列表
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
ProcessBundleTags(manifest);
|
||||
}
|
||||
// 处理资源包的标签集合
|
||||
ProcessBundleTags(manifest);
|
||||
}
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToJson(filePath, manifest);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToJson(filePath, manifest);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileMD5(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileMD5(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, packageHash);
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
// 创建补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, packageHash);
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
}
|
||||
// 创建补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的依赖集合
|
||||
/// </summary>
|
||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||
/// <summary>
|
||||
/// 获取资源包的依赖集合
|
||||
/// </summary>
|
||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源对象列表
|
||||
/// </summary>
|
||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
PackageAsset packageAsset = new PackageAsset();
|
||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取主资源对象列表
|
||||
/// </summary>
|
||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
PackageAsset packageAsset = new PackageAsset();
|
||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||
packageAsset.AssetPath = assetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包列表
|
||||
/// </summary>
|
||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var packageBundle = bundleInfo.CreatePackageBundle();
|
||||
result.Add(packageBundle);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源包列表
|
||||
/// </summary>
|
||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var packageBundle = bundleInfo.CreatePackageBundle();
|
||||
result.Add(packageBundle);
|
||||
}
|
||||
|
||||
// 注意:缓存资源包索引
|
||||
for (int index = 0; index < result.Count; index++)
|
||||
{
|
||||
string bundleName = result[index].BundleName;
|
||||
_cachedBundleID.Add(bundleName, index);
|
||||
}
|
||||
// 注意:缓存资源包索引
|
||||
for (int index = 0; index < result.Count; index++)
|
||||
{
|
||||
string bundleName = result[index].BundleName;
|
||||
_cachedBundleID.Add(bundleName, index);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源包的依赖集合
|
||||
/// </summary>
|
||||
private void ProcessBundleDepends(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(depends.Length);
|
||||
foreach (var dependBundleName in depends)
|
||||
{
|
||||
int bundleID = GetCachedBundleID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 处理资源包的依赖集合
|
||||
/// </summary>
|
||||
private void ProcessBundleDepends(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(depends.Length);
|
||||
foreach (var dependBundleName in depends)
|
||||
{
|
||||
int bundleID = GetCachedBundleID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源包的标签集合
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
/// <summary>
|
||||
/// 处理资源包的标签集合
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
if (_cacheBundleTags.ContainsKey(index))
|
||||
{
|
||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CacheBundleTags(int bundleID, string[] assetTags)
|
||||
{
|
||||
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
||||
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
if (_cacheBundleTags.ContainsKey(index))
|
||||
{
|
||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CacheBundleTags(int bundleID, string[] assetTags)
|
||||
{
|
||||
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
||||
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||
|
||||
foreach (var assetTag in assetTags)
|
||||
{
|
||||
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||
_cacheBundleTags[bundleID].Add(assetTag);
|
||||
}
|
||||
}
|
||||
foreach (var assetTag in assetTags)
|
||||
{
|
||||
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||
_cacheBundleTags[bundleID].Add(assetTag);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的索引ID
|
||||
/// </summary>
|
||||
private int GetCachedBundleID(string bundleName)
|
||||
{
|
||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源包的索引ID
|
||||
/// </summary>
|
||||
private int GetCachedBundleID(string bundleName)
|
||||
{
|
||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,205 +6,205 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport
|
||||
{
|
||||
protected void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
||||
{
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
public class TaskCreateReport
|
||||
{
|
||||
protected void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
||||
{
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
PackageManifest manifest = manifestContext.Manifest;
|
||||
BuildReport buildReport = new BuildReport();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
PackageManifest manifest = manifestContext.Manifest;
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||
{
|
||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||
buildReport.Summary.DisableWriteTypeTree = false;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||
}
|
||||
// 构建参数
|
||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||
{
|
||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||
buildReport.Summary.DisableWriteTypeTree = false;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||
}
|
||||
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
||||
}
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
||||
}
|
||||
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.Address = packageAsset.Address;
|
||||
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
||||
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.Address = packageAsset.Address;
|
||||
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
||||
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
|
||||
// 资源包列表
|
||||
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||
reportBundleInfo.BundleName = packageBundle.BundleName;
|
||||
reportBundleInfo.FileName = packageBundle.FileName;
|
||||
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||
reportBundleInfo.Tags = packageBundle.Tags;
|
||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
// 资源包列表
|
||||
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||
reportBundleInfo.BundleName = packageBundle.BundleName;
|
||||
reportBundleInfo.FileName = packageBundle.FileName;
|
||||
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||
reportBundleInfo.Tags = packageBundle.Tags;
|
||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||
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 filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildLogger.Log($"Create build report file: {filePath}");
|
||||
}
|
||||
// 序列化文件
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildLogger.Log($"Create build report file: {filePath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
return dependBundles;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = assetInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||
{
|
||||
if (assetInfo.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = assetInfo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源
|
||||
/// </summary>
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源
|
||||
/// </summary>
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
||||
}
|
||||
|
||||
private int GetMainAssetCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.AssetList.Count;
|
||||
}
|
||||
private int GetAllBundleCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.BundleList.Count;
|
||||
}
|
||||
private long GetAllBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetEncryptedBundleCount(PackageManifest manifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetEncryptedBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
}
|
||||
private int GetMainAssetCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.AssetList.Count;
|
||||
}
|
||||
private int GetAllBundleCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.BundleList.Count;
|
||||
}
|
||||
private long GetAllBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetEncryptedBundleCount(PackageManifest manifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetEncryptedBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,45 +6,45 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||
if (encryptionServices == null)
|
||||
return;
|
||||
public class TaskEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||
if (encryptionServices == null)
|
||||
return;
|
||||
|
||||
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
||||
return;
|
||||
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
||||
return;
|
||||
|
||||
int progressValue = 0;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
if (encryptResult.Encrypted)
|
||||
{
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||
bundleInfo.EncryptedFilePath = filePath;
|
||||
bundleInfo.Encrypted = true;
|
||||
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
bundleInfo.Encrypted = false;
|
||||
}
|
||||
int progressValue = 0;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
if (encryptResult.Encrypted)
|
||||
{
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||
bundleInfo.EncryptedFilePath = filePath;
|
||||
bundleInfo.Encrypted = true;
|
||||
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
bundleInfo.Encrypted = false;
|
||||
}
|
||||
|
||||
// 进度条
|
||||
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
// 进度条
|
||||
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,184 +7,184 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成资源构建上下文
|
||||
/// </summary>
|
||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||
{
|
||||
var buildMode = buildParameters.BuildMode;
|
||||
var packageName = buildParameters.PackageName;
|
||||
public class TaskGetBuildMap
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成资源构建上下文
|
||||
/// </summary>
|
||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||
{
|
||||
var buildMode = buildParameters.BuildMode;
|
||||
var packageName = buildParameters.PackageName;
|
||||
|
||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 获取所有收集器收集的资源
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
||||
// 1. 获取所有收集器收集的资源
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
||||
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
RemoveZeroReferenceAssets(allCollectAssetInfos);
|
||||
|
||||
// 3. 录入所有收集器主动收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||
{
|
||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||
{
|
||||
if (collectAssetInfo.AssetTags.Count > 0)
|
||||
{
|
||||
collectAssetInfo.AssetTags.Clear();
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
// 3. 录入所有收集器主动收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||
{
|
||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||
{
|
||||
if (collectAssetInfo.AssetTags.Count > 0)
|
||||
{
|
||||
collectAssetInfo.AssetTags.Clear();
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Should never get here !");
|
||||
}
|
||||
}
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Should never get here !");
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 录入所有收集资源依赖的其它资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
string bundleName = collectAssetInfo.BundleName;
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(dependAssetPath))
|
||||
{
|
||||
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4. 录入所有收集资源依赖的其它资源
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
string bundleName = collectAssetInfo.BundleName;
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(dependAssetPath))
|
||||
{
|
||||
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
|
||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 填充所有收集资源的依赖列表
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
||||
dependAssetInfos.Add(value);
|
||||
else
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
// 5. 填充所有收集资源的依赖列表
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||
foreach (var dependAssetPath in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value))
|
||||
dependAssetInfos.Add(value);
|
||||
else
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
|
||||
// 6. 自动收集所有依赖的着色器
|
||||
if (collectResult.Command.AutoCollectShaders)
|
||||
{
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||
{
|
||||
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
{
|
||||
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 6. 自动收集所有依赖的着色器
|
||||
if (collectResult.Command.AutoCollectShaders)
|
||||
{
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||
{
|
||||
if (buildAssetInfo.AssetType == typeof(UnityEngine.Shader) || buildAssetInfo.AssetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
{
|
||||
buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 记录关键信息
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||
context.Command = collectResult.Command;
|
||||
// 7. 记录关键信息
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||
context.Command = collectResult.Command;
|
||||
|
||||
// 8. 记录冗余资源
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.IsRedundancyAsset())
|
||||
{
|
||||
var redundancyInfo = new ReportRedundancyInfo();
|
||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
||||
context.RedundancyInfos.Add(redundancyInfo);
|
||||
}
|
||||
}
|
||||
// 8. 记录冗余资源
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.IsRedundancyAsset())
|
||||
{
|
||||
var redundancyInfo = new ReportRedundancyInfo();
|
||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
||||
context.RedundancyInfos.Add(redundancyInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 9. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
removeBuildList.Add(buildAssetInfo);
|
||||
}
|
||||
foreach (var removeValue in removeBuildList)
|
||||
{
|
||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
||||
}
|
||||
// 9. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
removeBuildList.Add(buildAssetInfo);
|
||||
}
|
||||
foreach (var removeValue in removeBuildList)
|
||||
{
|
||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
||||
}
|
||||
|
||||
// 10. 构建资源列表
|
||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||
if (allPackAssets.Count == 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
foreach (var assetInfo in allPackAssets)
|
||||
{
|
||||
context.PackAsset(assetInfo);
|
||||
}
|
||||
// 10. 构建资源列表
|
||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||
if (allPackAssets.Count == 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
foreach (var assetInfo in allPackAssets)
|
||||
{
|
||||
context.PackAsset(assetInfo);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
||||
{
|
||||
// 1. 检测是否任何存在依赖资源
|
||||
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||
return;
|
||||
return context;
|
||||
}
|
||||
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos)
|
||||
{
|
||||
// 1. 检测是否任何存在依赖资源
|
||||
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||
return;
|
||||
|
||||
// 2. 获取所有主资源的依赖资源集合
|
||||
HashSet<string> allDependAsset = new HashSet<string>();
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allDependAsset.Contains(dependAsset) == false)
|
||||
allDependAsset.Add(dependAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2. 获取所有主资源的依赖资源集合
|
||||
HashSet<string> allDependAsset = new HashSet<string>();
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allDependAsset.Contains(dependAsset) == false)
|
||||
allDependAsset.Add(dependAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 找出所有零引用的依赖资源集合
|
||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.DependAssetCollector)
|
||||
{
|
||||
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
||||
removeList.Add(collectAssetInfo);
|
||||
}
|
||||
}
|
||||
// 3. 找出所有零引用的依赖资源集合
|
||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||
foreach (var collectAssetInfo in allCollectAssetInfos)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.DependAssetCollector)
|
||||
{
|
||||
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false)
|
||||
removeList.Add(collectAssetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 移除所有零引用的依赖资源
|
||||
foreach (var removeValue in removeList)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
allCollectAssetInfos.Remove(removeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4. 移除所有零引用的依赖资源
|
||||
foreach (var removeValue in removeList)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
allCollectAssetInfos.Remove(removeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,90 +7,90 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public abstract class TaskUpdateBundleInfo
|
||||
{
|
||||
public void UpdateBundleInfo(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
int outputNameStyle = (int)buildParametersContext.Parameters.FileNameStyle;
|
||||
public abstract class TaskUpdateBundleInfo
|
||||
{
|
||||
public void UpdateBundleInfo(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
int outputNameStyle = (int)buildParametersContext.Parameters.FileNameStyle;
|
||||
|
||||
// 1.检测文件名长度
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
// NOTE:检测文件名长度不要超过260字符。
|
||||
string fileName = bundleInfo.BundleName;
|
||||
if (fileName.Length >= 260)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
// 1.检测文件名长度
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
// NOTE:检测文件名长度不要超过260字符。
|
||||
string fileName = bundleInfo.BundleName;
|
||||
if (fileName.Length >= 260)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 2.更新构建输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
if (bundleInfo.Encrypted)
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.EncryptedFilePath;
|
||||
else
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.BuildOutputFilePath;
|
||||
}
|
||||
// 2.更新构建输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
if (bundleInfo.Encrypted)
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.EncryptedFilePath;
|
||||
else
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.BuildOutputFilePath;
|
||||
}
|
||||
|
||||
// 3.更新文件其它信息
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||
}
|
||||
// 3.更新文件其它信息
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||
}
|
||||
|
||||
// 4.更新补丁包输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string bundleName = bundleInfo.BundleName;
|
||||
string fileHash = bundleInfo.PackageFileHash;
|
||||
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||
}
|
||||
}
|
||||
// 4.更新补丁包输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string bundleName = bundleInfo.BundleName;
|
||||
string fileHash = bundleInfo.PackageFileHash;
|
||||
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
|
||||
protected string GetFilePathTempHash(string filePath)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||
return HashUtility.BytesMD5(bytes);
|
||||
protected string GetFilePathTempHash(string filePath)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||
return HashUtility.BytesMD5(bytes);
|
||||
|
||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||
}
|
||||
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||
{
|
||||
long tempSize = 0;
|
||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||
}
|
||||
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||
{
|
||||
long tempSize = 0;
|
||||
|
||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||
foreach (var assetPath in assetPaths)
|
||||
{
|
||||
long size = FileUtility.GetFileSize(assetPath);
|
||||
tempSize += size;
|
||||
}
|
||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||
foreach (var assetPath in assetPaths)
|
||||
{
|
||||
long size = FileUtility.GetFileSize(assetPath);
|
||||
tempSize += size;
|
||||
}
|
||||
|
||||
if (tempSize == 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
return tempSize;
|
||||
}
|
||||
}
|
||||
if (tempSize == 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
return tempSize;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,48 +7,48 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskBuilding_BBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public AssetBundleManifest UnityManifest;
|
||||
}
|
||||
public class TaskBuilding_BBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public AssetBundleManifest UnityManifest;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success !");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.UnityManifest = unityManifest;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
BuildLogger.Log("UnityEngine build success !");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.UnityManifest = unityManifest;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,21 +6,21 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,21 +5,21 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
if (_buildResultContext == null)
|
||||
_buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
if (_buildResultContext == null)
|
||||
_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
|
||||
{
|
||||
public class TaskCreatePackage_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
public class TaskCreatePackage_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝UnityManifest文本文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝UnityManifest文本文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,18 +6,18 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,13 +7,13 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,18 +6,18 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
public class TaskPrepare_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测Unity版本
|
||||
// 检测Unity版本
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
|
@ -25,6 +25,6 @@ namespace YooAsset.Editor
|
|||
BuildLogger.Warning(warning);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,86 +6,86 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
{
|
||||
return hash.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.BuildOutputFilePath;
|
||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||
{
|
||||
return crc;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
{
|
||||
return hash.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.BuildOutputFilePath;
|
||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||
{
|
||||
return crc;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,66 +8,66 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
||||
}
|
||||
}
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||
// 1. 过滤掉原生Bundle
|
||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
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
|
||||
{
|
||||
public class BuiltinBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
public class BuiltinBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
/// </summary>
|
||||
public BuildAssetBundleOptions GetBundleBuildOptions()
|
||||
{
|
||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
/// </summary>
|
||||
public BuildAssetBundleOptions GetBundleBuildOptions()
|
||||
{
|
||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||
|
||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||
|
||||
if (BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||
return opt;
|
||||
}
|
||||
if (BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||
return opt;
|
||||
}
|
||||
|
||||
if (CompressOption == ECompressOption.Uncompressed)
|
||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
if (CompressOption == ECompressOption.Uncompressed)
|
||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||
if (DisableWriteTypeTree)
|
||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||
if (IgnoreTypeTreeChanges)
|
||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||
if (DisableWriteTypeTree)
|
||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||
if (IgnoreTypeTreeChanges)
|
||||
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.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||
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
|
||||
{
|
||||
public class BuiltinBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
public class BuiltinBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_BBP(),
|
||||
new TaskGetBuildMap_BBP(),
|
||||
new TaskBuilding_BBP(),
|
||||
new TaskVerifyBuildResult_BBP(),
|
||||
new TaskEncryption_BBP(),
|
||||
new TaskUpdateBundleInfo_BBP(),
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_BBP(),
|
||||
new TaskGetBuildMap_BBP(),
|
||||
new TaskBuilding_BBP(),
|
||||
new TaskVerifyBuildResult_BBP(),
|
||||
new TaskEncryption_BBP(),
|
||||
new TaskUpdateBundleInfo_BBP(),
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,35 +5,35 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskBuilding_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
public class TaskBuilding_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝原生文件
|
||||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||
{
|
||||
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 拷贝原生文件
|
||||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var assetInfo in bundleInfo.MainAssets)
|
||||
{
|
||||
EditorTools.CopyFile(assetInfo.AssetPath, dest, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,21 +6,21 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,16 +5,16 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return new string[] { };
|
||||
}
|
||||
}
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return new string[] { };
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,36 +3,36 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreatePackage_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
public class TaskCreatePackage_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,32 +7,32 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
|
||||
// 检测构建结果
|
||||
CheckBuildMapContent(buildMapContext);
|
||||
}
|
||||
// 检测构建结果
|
||||
CheckBuildMapContent(buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测资源构建上下文
|
||||
/// </summary>
|
||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||
{
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (bundleInfo.MainAssets.Count != 1)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测资源构建上下文
|
||||
/// </summary>
|
||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||
{
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (bundleInfo.MainAssets.Count != 1)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,27 +6,27 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
public class TaskPrepare_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,58 +6,58 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class RawFileBuildParameters : BuildParameters
|
||||
{
|
||||
}
|
||||
public class RawFileBuildParameters : BuildParameters
|
||||
{
|
||||
}
|
||||
}
|
|
@ -7,31 +7,31 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class RawFileBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
public class RawFileBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_RFBP(),
|
||||
new TaskGetBuildMap_RFBP(),
|
||||
new TaskBuilding_RFBP(),
|
||||
new TaskUpdateBundleInfo_RFBP(),
|
||||
new TaskCreateManifest_RFBP(),
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_RFBP(),
|
||||
new TaskGetBuildMap_RFBP(),
|
||||
new TaskBuilding_RFBP(),
|
||||
new TaskUpdateBundleInfo_RFBP(),
|
||||
new TaskCreateManifest_RFBP(),
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,51 +8,51 @@ using UnityEditor.Build.Pipeline.Tasks;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskBuilding_SBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
}
|
||||
public class TaskBuilding_SBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 创建着色器信息
|
||||
// 说明:解决因为着色器资源包导致验证失败。
|
||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||
{
|
||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||
}
|
||||
// 创建着色器信息
|
||||
// 说明:解决因为着色器资源包导致验证失败。
|
||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||
{
|
||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,21 +6,21 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,26 +7,26 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
||||
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
if (_buildResultContext == null)
|
||||
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
if (_buildResultContext == null)
|
||||
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
|
||||
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
||||
}
|
||||
}
|
||||
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,53 +3,53 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreatePackage_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
public class TaskCreatePackage_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝构建日志
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/buildlogtep.json";
|
||||
string destPath = $"{packageOutputDirectory}/buildlogtep.json";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝构建日志
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/buildlogtep.json";
|
||||
string destPath = $"{packageOutputDirectory}/buildlogtep.json";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝代码防裁剪配置
|
||||
if (scriptableBuildParameters.WriteLinkXML)
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/link.xml";
|
||||
string destPath = $"{packageOutputDirectory}/link.xml";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
// 拷贝代码防裁剪配置
|
||||
if (scriptableBuildParameters.WriteLinkXML)
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/link.xml";
|
||||
string destPath = $"{packageOutputDirectory}/link.xml";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,19 +6,19 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,18 +6,18 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
{
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,13 +7,13 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,27 +6,27 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
public class TaskPrepare_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,86 +6,86 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Hash.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Crc;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Hash.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var parameters = buildParametersContext.Parameters;
|
||||
var buildMode = parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return value.Crc;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetFilePathTempHash(filePath);
|
||||
else
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return "00000000"; //8位
|
||||
else
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
else
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,66 +9,66 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.Results);
|
||||
}
|
||||
}
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.Results);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||
// 1. 过滤掉原生Bundle
|
||||
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
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
|
||||
{
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
// Setup
|
||||
buildTasks.Add(new SwitchToBuildPlatform());
|
||||
buildTasks.Add(new RebuildSpriteAtlasCache());
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
// Player Scripts
|
||||
buildTasks.Add(new BuildPlayerScripts());
|
||||
buildTasks.Add(new PostScriptsCallback());
|
||||
// Setup
|
||||
buildTasks.Add(new SwitchToBuildPlatform());
|
||||
buildTasks.Add(new RebuildSpriteAtlasCache());
|
||||
|
||||
// Dependency
|
||||
buildTasks.Add(new CalculateSceneDependencyData());
|
||||
// Player Scripts
|
||||
buildTasks.Add(new BuildPlayerScripts());
|
||||
buildTasks.Add(new PostScriptsCallback());
|
||||
|
||||
// Dependency
|
||||
buildTasks.Add(new CalculateSceneDependencyData());
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
buildTasks.Add(new CalculateCustomDependencyData());
|
||||
buildTasks.Add(new CalculateCustomDependencyData());
|
||||
#endif
|
||||
buildTasks.Add(new CalculateAssetDependencyData());
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
buildTasks.Add(new CalculateAssetDependencyData());
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
|
||||
// Packing
|
||||
buildTasks.Add(new GenerateBundlePacking());
|
||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||
buildTasks.Add(new GenerateBundleCommands());
|
||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||
buildTasks.Add(new GenerateBundleMaps());
|
||||
buildTasks.Add(new PostPackingCallback());
|
||||
|
||||
// Writing
|
||||
buildTasks.Add(new WriteSerializedFiles());
|
||||
buildTasks.Add(new ArchiveAndCompressBundles());
|
||||
buildTasks.Add(new AppendBundleHash());
|
||||
buildTasks.Add(new GenerateLinkXml());
|
||||
buildTasks.Add(new PostWritingCallback());
|
||||
|
||||
return buildTasks;
|
||||
}
|
||||
}
|
||||
// Packing
|
||||
buildTasks.Add(new GenerateBundlePacking());
|
||||
buildTasks.Add(new UpdateBundleObjectLayout());
|
||||
buildTasks.Add(new GenerateBundleCommands());
|
||||
buildTasks.Add(new GenerateSubAssetPathMaps());
|
||||
buildTasks.Add(new GenerateBundleMaps());
|
||||
buildTasks.Add(new PostPackingCallback());
|
||||
|
||||
// Writing
|
||||
buildTasks.Add(new WriteSerializedFiles());
|
||||
buildTasks.Add(new ArchiveAndCompressBundles());
|
||||
buildTasks.Add(new AppendBundleHash());
|
||||
buildTasks.Add(new GenerateLinkXml());
|
||||
buildTasks.Add(new PostWritingCallback());
|
||||
|
||||
return buildTasks;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,67 +7,67 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScriptableBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
public class ScriptableBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成代码防裁剪配置
|
||||
/// </summary>
|
||||
public bool WriteLinkXML = true;
|
||||
/// <summary>
|
||||
/// 生成代码防裁剪配置
|
||||
/// </summary>
|
||||
public bool WriteLinkXML = true;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务器地址
|
||||
/// </summary>
|
||||
public string CacheServerHost;
|
||||
/// <summary>
|
||||
/// 缓存服务器地址
|
||||
/// </summary>
|
||||
public string CacheServerHost;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务器端口
|
||||
/// </summary>
|
||||
public int CacheServerPort;
|
||||
/// <summary>
|
||||
/// 缓存服务器端口
|
||||
/// </summary>
|
||||
public int CacheServerPort;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取可编程构建管线的构建参数
|
||||
/// </summary>
|
||||
public BundleBuildParameters GetBundleBuildParameters()
|
||||
{
|
||||
var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(BuildTarget);
|
||||
var pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
var buildParams = new BundleBuildParameters(BuildTarget, targetGroup, pipelineOutputDirectory);
|
||||
/// <summary>
|
||||
/// 获取可编程构建管线的构建参数
|
||||
/// </summary>
|
||||
public BundleBuildParameters GetBundleBuildParameters()
|
||||
{
|
||||
var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(BuildTarget);
|
||||
var pipelineOutputDirectory = GetPipelineOutputDirectory();
|
||||
var buildParams = new BundleBuildParameters(BuildTarget, targetGroup, pipelineOutputDirectory);
|
||||
|
||||
if (CompressOption == ECompressOption.Uncompressed)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||
else if (CompressOption == ECompressOption.LZMA)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
||||
else
|
||||
throw new System.NotImplementedException(CompressOption.ToString());
|
||||
if (CompressOption == ECompressOption.Uncompressed)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
|
||||
else if (CompressOption == ECompressOption.LZMA)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
|
||||
else
|
||||
throw new System.NotImplementedException(CompressOption.ToString());
|
||||
|
||||
if (DisableWriteTypeTree)
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||
if (DisableWriteTypeTree)
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||
|
||||
buildParams.UseCache = true;
|
||||
buildParams.CacheServerHost = CacheServerHost;
|
||||
buildParams.CacheServerPort = CacheServerPort;
|
||||
buildParams.WriteLinkXML = WriteLinkXML;
|
||||
buildParams.UseCache = true;
|
||||
buildParams.CacheServerHost = CacheServerHost;
|
||||
buildParams.CacheServerPort = CacheServerPort;
|
||||
buildParams.WriteLinkXML = WriteLinkXML;
|
||||
|
||||
return buildParams;
|
||||
}
|
||||
}
|
||||
return buildParams;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,33 +4,33 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScriptableBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
public class ScriptableBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_SBP(),
|
||||
new TaskGetBuildMap_SBP(),
|
||||
new TaskBuilding_SBP(),
|
||||
new TaskVerifyBuildResult_SBP(),
|
||||
new TaskEncryption_SBP(),
|
||||
new TaskUpdateBundleInfo_SBP(),
|
||||
new TaskCreateManifest_SBP(),
|
||||
new TaskCreateReport_SBP(),
|
||||
new TaskCreatePackage_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_SBP(),
|
||||
new TaskGetBuildMap_SBP(),
|
||||
new TaskBuilding_SBP(),
|
||||
new TaskVerifyBuildResult_SBP(),
|
||||
new TaskEncryption_SBP(),
|
||||
new TaskUpdateBundleInfo_SBP(),
|
||||
new TaskCreateManifest_SBP(),
|
||||
new TaskCreateReport_SBP(),
|
||||
new TaskCreatePackage_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,47 +4,47 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildContext
|
||||
{
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
public class BuildContext
|
||||
{
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
_contextObjects.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
_contextObjects.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
if (contextObject == null)
|
||||
throw new ArgumentNullException("contextObject");
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
if (contextObject == null)
|
||||
throw new ArgumentNullException("contextObject");
|
||||
|
||||
var type = contextObject.GetType();
|
||||
if (_contextObjects.ContainsKey(type))
|
||||
throw new Exception($"Context object {type} is already existed.");
|
||||
var type = contextObject.GetType();
|
||||
if (_contextObjects.ContainsKey(type))
|
||||
throw new Exception($"Context object {type} is already existed.");
|
||||
|
||||
_contextObjects.Add(type, contextObject);
|
||||
}
|
||||
_contextObjects.Add(type, contextObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,34 +5,34 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal static class BuildLogger
|
||||
{
|
||||
private static bool _enableLog = true;
|
||||
internal static class BuildLogger
|
||||
{
|
||||
private static bool _enableLog = true;
|
||||
|
||||
public static void InitLogger(bool enableLog)
|
||||
{
|
||||
_enableLog = enableLog;
|
||||
}
|
||||
public static void InitLogger(bool enableLog)
|
||||
{
|
||||
_enableLog = enableLog;
|
||||
}
|
||||
|
||||
public static void Log(string message)
|
||||
{
|
||||
if (_enableLog)
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
public static void Warning(string message)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
public static void Error(string message)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
public static void Log(string message)
|
||||
{
|
||||
if (_enableLog)
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
public static void Warning(string message)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
public static void Error(string message)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
|
||||
public static string GetErrorMessage(ErrorCode code, string message)
|
||||
{
|
||||
return $"[ErrorCode{(int)code}] {message}";
|
||||
}
|
||||
}
|
||||
public static string GetErrorMessage(ErrorCode code, string message)
|
||||
{
|
||||
return $"[ErrorCode{(int)code}] {message}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,64 +7,64 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildRunner
|
||||
{
|
||||
private static Stopwatch _buildWatch;
|
||||
public class BuildRunner
|
||||
{
|
||||
private static Stopwatch _buildWatch;
|
||||
|
||||
/// <summary>
|
||||
/// 总耗时
|
||||
/// </summary>
|
||||
public static int TotalSeconds = 0;
|
||||
/// <summary>
|
||||
/// 总耗时
|
||||
/// </summary>
|
||||
public static int TotalSeconds = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建流程
|
||||
/// </summary>
|
||||
/// <returns>如果成功返回TRUE,否则返回FALSE</returns>
|
||||
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
|
||||
{
|
||||
if (pipeline == null)
|
||||
throw new ArgumentNullException("pipeline");
|
||||
if (context == null)
|
||||
throw new ArgumentNullException("context");
|
||||
/// <summary>
|
||||
/// 执行构建流程
|
||||
/// </summary>
|
||||
/// <returns>如果成功返回TRUE,否则返回FALSE</returns>
|
||||
public static BuildResult Run(List<IBuildTask> pipeline, BuildContext context)
|
||||
{
|
||||
if (pipeline == null)
|
||||
throw new ArgumentNullException("pipeline");
|
||||
if (context == null)
|
||||
throw new ArgumentNullException("context");
|
||||
|
||||
BuildResult buildResult = new BuildResult();
|
||||
buildResult.Success = true;
|
||||
TotalSeconds = 0;
|
||||
for (int i = 0; i < pipeline.Count; i++)
|
||||
{
|
||||
IBuildTask task = pipeline[i];
|
||||
try
|
||||
{
|
||||
_buildWatch = Stopwatch.StartNew();
|
||||
string taskName = task.GetType().Name.Split('_')[0];
|
||||
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
||||
task.Run(context);
|
||||
_buildWatch.Stop();
|
||||
BuildResult buildResult = new BuildResult();
|
||||
buildResult.Success = true;
|
||||
TotalSeconds = 0;
|
||||
for (int i = 0; i < pipeline.Count; i++)
|
||||
{
|
||||
IBuildTask task = pipeline[i];
|
||||
try
|
||||
{
|
||||
_buildWatch = Stopwatch.StartNew();
|
||||
string taskName = task.GetType().Name.Split('_')[0];
|
||||
BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
|
||||
task.Run(context);
|
||||
_buildWatch.Stop();
|
||||
|
||||
// 统计耗时
|
||||
int seconds = GetBuildSeconds();
|
||||
TotalSeconds += seconds;
|
||||
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
EditorTools.ClearProgressBar();
|
||||
buildResult.FailedTask = task.GetType().Name;
|
||||
buildResult.ErrorInfo = e.ToString();
|
||||
buildResult.Success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 统计耗时
|
||||
int seconds = GetBuildSeconds();
|
||||
TotalSeconds += seconds;
|
||||
BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
EditorTools.ClearProgressBar();
|
||||
buildResult.FailedTask = task.GetType().Name;
|
||||
buildResult.ErrorInfo = e.ToString();
|
||||
buildResult.Success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回运行结果
|
||||
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
||||
return buildResult;
|
||||
}
|
||||
// 返回运行结果
|
||||
BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
|
||||
return buildResult;
|
||||
}
|
||||
|
||||
private static int GetBuildSeconds()
|
||||
{
|
||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||
return (int)seconds;
|
||||
}
|
||||
}
|
||||
private static int GetBuildSeconds()
|
||||
{
|
||||
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
|
||||
return (int)seconds;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,42 +1,42 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal enum ErrorCode
|
||||
{
|
||||
// TaskPrepare
|
||||
ThePipelineIsBuiding = 100,
|
||||
FoundUnsavedScene = 101,
|
||||
NoBuildTarget = 110,
|
||||
PackageNameIsNullOrEmpty = 111,
|
||||
PackageVersionIsNullOrEmpty = 112,
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
RecommendScriptBuildPipeline = 130,
|
||||
BuildPipelineNotSupportBuildMode = 140,
|
||||
internal enum ErrorCode
|
||||
{
|
||||
// TaskPrepare
|
||||
ThePipelineIsBuiding = 100,
|
||||
FoundUnsavedScene = 101,
|
||||
NoBuildTarget = 110,
|
||||
PackageNameIsNullOrEmpty = 111,
|
||||
PackageVersionIsNullOrEmpty = 112,
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
RecommendScriptBuildPipeline = 130,
|
||||
BuildPipelineNotSupportBuildMode = 140,
|
||||
|
||||
// TaskGetBuildMap
|
||||
RemoveInvalidTags = 200,
|
||||
FoundUndependedAsset = 201,
|
||||
PackAssetListIsEmpty = 202,
|
||||
NotSupportMultipleRawAsset = 210,
|
||||
// TaskGetBuildMap
|
||||
RemoveInvalidTags = 200,
|
||||
FoundUndependedAsset = 201,
|
||||
PackAssetListIsEmpty = 202,
|
||||
NotSupportMultipleRawAsset = 210,
|
||||
|
||||
// TaskBuilding
|
||||
UnityEngineBuildFailed = 300,
|
||||
UnityEngineBuildFatal = 301,
|
||||
// TaskBuilding
|
||||
UnityEngineBuildFailed = 300,
|
||||
UnityEngineBuildFatal = 301,
|
||||
|
||||
// TaskUpdateBundleInfo
|
||||
CharactersOverTheLimit = 400,
|
||||
NotFoundUnityBundleHash = 401,
|
||||
NotFoundUnityBundleCRC = 402,
|
||||
BundleTempSizeIsZero = 403,
|
||||
|
||||
// TaskVerifyBuildResult
|
||||
UnintendedBuildBundle = 500,
|
||||
UnintendedBuildResult = 501,
|
||||
// TaskUpdateBundleInfo
|
||||
CharactersOverTheLimit = 400,
|
||||
NotFoundUnityBundleHash = 401,
|
||||
NotFoundUnityBundleCRC = 402,
|
||||
BundleTempSizeIsZero = 403,
|
||||
|
||||
// TaskCreateManifest
|
||||
NotFoundUnityBundleInBuildResult = 600,
|
||||
FoundStrayBundle = 601,
|
||||
}
|
||||
// TaskVerifyBuildResult
|
||||
UnintendedBuildBundle = 500,
|
||||
UnintendedBuildResult = 501,
|
||||
|
||||
// TaskCreateManifest
|
||||
NotFoundUnityBundleInBuildResult = 600,
|
||||
FoundStrayBundle = 601,
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IContextObject
|
||||
{
|
||||
}
|
||||
public interface IContextObject
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class EncryptionNone : IEncryptionServices
|
||||
{
|
||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class EncryptionNone : IEncryptionServices
|
||||
{
|
||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +1,29 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包流水线的构建模式
|
||||
/// </summary>
|
||||
public enum EBuildMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 强制重建模式
|
||||
/// </summary>
|
||||
ForceRebuild,
|
||||
/// <summary>
|
||||
/// 资源包流水线的构建模式
|
||||
/// </summary>
|
||||
public enum EBuildMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 强制重建模式
|
||||
/// </summary>
|
||||
ForceRebuild,
|
||||
|
||||
/// <summary>
|
||||
/// 增量构建模式
|
||||
/// </summary>
|
||||
IncrementalBuild,
|
||||
/// <summary>
|
||||
/// 增量构建模式
|
||||
/// </summary>
|
||||
IncrementalBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 演练构建模式
|
||||
/// </summary>
|
||||
DryRunBuild,
|
||||
/// <summary>
|
||||
/// 演练构建模式
|
||||
/// </summary>
|
||||
DryRunBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
SimulateBuild,
|
||||
}
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
SimulateBuild,
|
||||
}
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建管线类型
|
||||
/// </summary>
|
||||
public enum EBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 传统内置构建管线 (BBP)
|
||||
/// </summary>
|
||||
BuiltinBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 可编程构建管线 (SBP)
|
||||
/// </summary>
|
||||
ScriptableBuildPipeline,
|
||||
/// <summary>
|
||||
/// 构建管线类型
|
||||
/// </summary>
|
||||
public enum EBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 传统内置构建管线 (BBP)
|
||||
/// </summary>
|
||||
BuiltinBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件构建管线 (RFBP)
|
||||
/// </summary>
|
||||
RawFileBuildPipeline,
|
||||
}
|
||||
/// <summary>
|
||||
/// 可编程构建管线 (SBP)
|
||||
/// </summary>
|
||||
ScriptableBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件构建管线 (RFBP)
|
||||
/// </summary>
|
||||
RawFileBuildPipeline,
|
||||
}
|
||||
}
|
|
@ -1,34 +1,34 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public enum EBuildinFileCopyOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 不拷贝任何文件
|
||||
/// </summary>
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public enum EBuildinFileCopyOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 不拷贝任何文件
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后拷贝所有文件
|
||||
/// </summary>
|
||||
ClearAndCopyAll,
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后拷贝所有文件
|
||||
/// </summary>
|
||||
ClearAndCopyAll,
|
||||
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
ClearAndCopyByTags,
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
ClearAndCopyByTags,
|
||||
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接拷贝所有文件
|
||||
/// </summary>
|
||||
OnlyCopyAll,
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接拷贝所有文件
|
||||
/// </summary>
|
||||
OnlyCopyAll,
|
||||
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
OnlyCopyByTags,
|
||||
}
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
OnlyCopyByTags,
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// AssetBundle压缩选项
|
||||
/// </summary>
|
||||
public enum ECompressOption
|
||||
{
|
||||
Uncompressed = 0,
|
||||
LZMA,
|
||||
LZ4,
|
||||
}
|
||||
/// <summary>
|
||||
/// AssetBundle压缩选项
|
||||
/// </summary>
|
||||
public enum ECompressOption
|
||||
{
|
||||
Uncompressed = 0,
|
||||
LZMA,
|
||||
LZ4,
|
||||
}
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 补丁包内的文件样式
|
||||
/// </summary>
|
||||
public enum EFileNameStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 哈希值名称
|
||||
/// </summary>
|
||||
HashName = 0,
|
||||
/// <summary>
|
||||
/// 补丁包内的文件样式
|
||||
/// </summary>
|
||||
public enum EFileNameStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 哈希值名称
|
||||
/// </summary>
|
||||
HashName = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称(不推荐)
|
||||
/// </summary>
|
||||
BundleName = 1,
|
||||
/// <summary>
|
||||
/// 资源包名称(不推荐)
|
||||
/// </summary>
|
||||
BundleName = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称 + 哈希值名称
|
||||
/// </summary>
|
||||
BundleName_HashName = 2,
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源包名称 + 哈希值名称
|
||||
/// </summary>
|
||||
BundleName_HashName = 2,
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
}
|
||||
public interface IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
}
|
||||
}
|
|
@ -10,201 +10,201 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal abstract class BuildPipelineViewerBase
|
||||
{
|
||||
private const int StyleWidth = 400;
|
||||
internal abstract class BuildPipelineViewerBase
|
||||
{
|
||||
private const int StyleWidth = 400;
|
||||
|
||||
protected readonly string PackageName;
|
||||
protected readonly BuildTarget BuildTarget;
|
||||
protected readonly EBuildPipeline BuildPipeline;
|
||||
protected TemplateContainer Root;
|
||||
protected readonly string PackageName;
|
||||
protected readonly BuildTarget BuildTarget;
|
||||
protected readonly EBuildPipeline BuildPipeline;
|
||||
protected TemplateContainer Root;
|
||||
|
||||
private TextField _buildOutputField;
|
||||
private TextField _buildVersionField;
|
||||
private PopupField<Enum> _buildModeField;
|
||||
private PopupField<Type> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private EnumField _outputNameStyleField;
|
||||
private EnumField _copyBuildinFileOptionField;
|
||||
private TextField _copyBuildinFileTagsField;
|
||||
private TextField _buildOutputField;
|
||||
private TextField _buildVersionField;
|
||||
private PopupField<Enum> _buildModeField;
|
||||
private PopupField<Type> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private EnumField _outputNameStyleField;
|
||||
private EnumField _copyBuildinFileOptionField;
|
||||
private TextField _copyBuildinFileTagsField;
|
||||
|
||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||
{
|
||||
PackageName = packageName;
|
||||
BuildTarget = buildTarget;
|
||||
BuildPipeline = buildPipeline;
|
||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||
{
|
||||
PackageName = packageName;
|
||||
BuildTarget = buildTarget;
|
||||
BuildPipeline = buildPipeline;
|
||||
|
||||
CreateView(parent);
|
||||
RefreshView();
|
||||
}
|
||||
private void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
CreateView(parent);
|
||||
RefreshView();
|
||||
}
|
||||
private void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
_buildVersionField.style.width = StyleWidth;
|
||||
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
_buildVersionField.style.width = StyleWidth;
|
||||
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||
|
||||
// 构建模式
|
||||
{
|
||||
var buildModeContainer = Root.Q("BuildModeContainer");
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var buildModeList = GetSupportBuildModes();
|
||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
||||
_buildModeField.label = "Build Mode";
|
||||
_buildModeField.style.width = StyleWidth;
|
||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildMode(PackageName, BuildPipeline, (EBuildMode)_buildModeField.value);
|
||||
});
|
||||
buildModeContainer.Add(_buildModeField);
|
||||
}
|
||||
// 构建模式
|
||||
{
|
||||
var buildModeContainer = Root.Q("BuildModeContainer");
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var buildModeList = GetSupportBuildModes();
|
||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
||||
_buildModeField.label = "Build Mode";
|
||||
_buildModeField.style.width = StyleWidth;
|
||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildMode(PackageName, BuildPipeline, (EBuildMode)_buildModeField.value);
|
||||
});
|
||||
buildModeContainer.Add(_buildModeField);
|
||||
}
|
||||
|
||||
// 加密方法
|
||||
{
|
||||
var encryptionContainer = Root.Q("EncryptionContainer");
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
if (encryptionClassTypes.Count > 0)
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageEncyptionClassName(PackageName, BuildPipeline, _encryptionField.value.FullName);
|
||||
});
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_encryptionField = new PopupField<Type>();
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
}
|
||||
// 加密方法
|
||||
{
|
||||
var encryptionContainer = Root.Q("EncryptionContainer");
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
if (encryptionClassTypes.Count > 0)
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageEncyptionClassName(PackageName, BuildPipeline, _encryptionField.value.FullName);
|
||||
});
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_encryptionField = new PopupField<Type>();
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
}
|
||||
|
||||
// 压缩方式选项
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(compressOption);
|
||||
_compressionField.SetValueWithoutNotify(compressOption);
|
||||
_compressionField.style.width = StyleWidth;
|
||||
_compressionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
||||
});
|
||||
// 压缩方式选项
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(compressOption);
|
||||
_compressionField.SetValueWithoutNotify(compressOption);
|
||||
_compressionField.style.width = StyleWidth;
|
||||
_compressionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
||||
});
|
||||
|
||||
// 输出文件名称样式
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
_outputNameStyleField.Init(fileNameStyle);
|
||||
_outputNameStyleField.SetValueWithoutNotify(fileNameStyle);
|
||||
_outputNameStyleField.style.width = StyleWidth;
|
||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
||||
});
|
||||
// 输出文件名称样式
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
_outputNameStyleField.Init(fileNameStyle);
|
||||
_outputNameStyleField.SetValueWithoutNotify(fileNameStyle);
|
||||
_outputNameStyleField.style.width = StyleWidth;
|
||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
||||
});
|
||||
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.style.width = StyleWidth;
|
||||
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, BuildPipeline, (EBuildinFileCopyOption)_copyBuildinFileOptionField.value);
|
||||
RefreshView();
|
||||
});
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.style.width = StyleWidth;
|
||||
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, BuildPipeline, (EBuildinFileCopyOption)_copyBuildinFileOptionField.value);
|
||||
RefreshView();
|
||||
});
|
||||
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||
});
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||
});
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
bool tagsFiledVisible = buildinFileCopyOption == EBuildinFileCopyOption.ClearAndCopyByTags || buildinFileCopyOption == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] 打包已经取消");
|
||||
}
|
||||
}
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
bool tagsFiledVisible = buildinFileCopyOption == EBuildinFileCopyOption.ClearAndCopyByTags || buildinFileCopyOption == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] 打包已经取消");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建任务
|
||||
/// </summary>
|
||||
protected abstract void ExecuteBuild();
|
||||
/// <summary>
|
||||
/// 执行构建任务
|
||||
/// </summary>
|
||||
protected abstract void ExecuteBuild();
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线支持的构建模式集合
|
||||
/// </summary>
|
||||
protected abstract List<Enum> GetSupportBuildModes();
|
||||
/// <summary>
|
||||
/// 获取构建管线支持的构建模式集合
|
||||
/// </summary>
|
||||
protected abstract List<Enum> GetSupportBuildModes();
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建版本
|
||||
/// </summary>
|
||||
protected string GetPackageVersion()
|
||||
{
|
||||
return _buildVersionField.value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取构建版本
|
||||
/// </summary>
|
||||
protected string GetPackageVersion()
|
||||
{
|
||||
return _buildVersionField.value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建加密类实例
|
||||
/// </summary>
|
||||
protected IEncryptionServices CreateEncryptionInstance()
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
||||
if (classType != null)
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建加密类实例
|
||||
/// </summary>
|
||||
protected IEncryptionServices CreateEncryptionInstance()
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
||||
if (classType != null)
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetDefaultPackageVersion()
|
||||
{
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
}
|
||||
private string GetDefaultPackageVersion()
|
||||
{
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -10,54 +10,54 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.BuiltinBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.BuiltinBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ö´Ğй¹½¨
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
/// <summary>
|
||||
/// Ö´Ğй¹½¨
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||
buildModeList.Add(EBuildMode.DryRunBuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||
buildModeList.Add(EBuildMode.DryRunBuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -10,52 +10,52 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
var compressionField = Root.Q<EnumField>("Compression");
|
||||
UIElementsTools.SetElementVisible(compressionField, false);
|
||||
}
|
||||
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
var compressionField = Root.Q<EnumField>("Compression");
|
||||
UIElementsTools.SetElementVisible(compressionField, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ö´Ğй¹½¨
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
/// <summary>
|
||||
/// Ö´Ğй¹½¨
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -10,52 +10,52 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public ScriptableBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.ScriptableBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public ScriptableBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.ScriptableBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
protected override List<Enum> GetSupportBuildModes()
|
||||
{
|
||||
List<Enum> buildModeList = new List<Enum>();
|
||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
||||
return buildModeList;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -6,316 +6,316 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集路径
|
||||
/// 注意:支持文件夹或单个资源文件
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
[Serializable]
|
||||
public class AssetBundleCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集路径
|
||||
/// 注意:支持文件夹或单个资源文件
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器的GUID
|
||||
/// </summary>
|
||||
public string CollectorGUID = string.Empty;
|
||||
/// <summary>
|
||||
/// 收集器的GUID
|
||||
/// </summary>
|
||||
public string CollectorGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType = ECollectorType.MainAssetCollector;
|
||||
|
||||
/// <summary>
|
||||
/// 寻址规则类名
|
||||
/// </summary>
|
||||
public string AddressRuleName = nameof(AddressByFileName);
|
||||
/// <summary>
|
||||
/// 寻址规则类名
|
||||
/// </summary>
|
||||
public string AddressRuleName = nameof(AddressByFileName);
|
||||
|
||||
/// <summary>
|
||||
/// 打包规则类名
|
||||
/// </summary>
|
||||
public string PackRuleName = nameof(PackDirectory);
|
||||
/// <summary>
|
||||
/// 打包规则类名
|
||||
/// </summary>
|
||||
public string PackRuleName = nameof(PackDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// 过滤规则类名
|
||||
/// </summary>
|
||||
public string FilterRuleName = nameof(CollectAll);
|
||||
/// <summary>
|
||||
/// 过滤规则类名
|
||||
/// </summary>
|
||||
public string FilterRuleName = nameof(CollectAll);
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 用户自定义数据
|
||||
/// </summary>
|
||||
public string UserData = string.Empty;
|
||||
/// <summary>
|
||||
/// 用户自定义数据
|
||||
/// </summary>
|
||||
public string UserData = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 收集器是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||
return false;
|
||||
/// <summary>
|
||||
/// 收集器是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(CollectPath) == null)
|
||||
return false;
|
||||
|
||||
if (CollectorType == ECollectorType.None)
|
||||
return false;
|
||||
if (CollectorType == ECollectorType.None)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
return false;
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
return false;
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
return false;
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
return false;
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
throw new Exception($"Invalid collect path : {CollectPath}");
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
string assetGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
throw new Exception($"Invalid collect path : {CollectPath}");
|
||||
|
||||
if (CollectorType == ECollectorType.None)
|
||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||
if (CollectorType == ECollectorType.None)
|
||||
throw new Exception($"{nameof(ECollectorType)}.{ECollectorType.None} is invalid in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||
if (AssetBundleCollectorSettingData.HasPackRuleName(PackRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IPackRule)} class type : {PackRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||
if (AssetBundleCollectorSettingData.HasFilterRuleName(FilterRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IFilterRule)} class type : {FilterRuleName} in collector : {CollectPath}");
|
||||
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||
}
|
||||
if (AssetBundleCollectorSettingData.HasAddressRuleName(AddressRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IAddressRule)} class type : {AddressRuleName} in collector : {CollectPath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
|
||||
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
||||
{
|
||||
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
||||
if (string.IsNullOrEmpty(convertAssetPath))
|
||||
{
|
||||
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
||||
CollectorGUID = string.Empty;
|
||||
isFixed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectPath != convertAssetPath)
|
||||
{
|
||||
CollectPath = convertAssetPath;
|
||||
isFixed = true;
|
||||
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(CollectorGUID) == false)
|
||||
{
|
||||
string convertAssetPath = AssetDatabase.GUIDToAssetPath(CollectorGUID);
|
||||
if (string.IsNullOrEmpty(convertAssetPath))
|
||||
{
|
||||
Debug.LogWarning($"Collector GUID {CollectorGUID} is invalid and has been auto removed !");
|
||||
CollectorGUID = string.Empty;
|
||||
isFixed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CollectPath != convertAssetPath)
|
||||
{
|
||||
CollectPath = convertAssetPath;
|
||||
isFixed = true;
|
||||
Debug.LogWarning($"Fix collect path : {CollectPath} -> {convertAssetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if(string.IsNullOrEmpty(convertGUID) == false)
|
||||
{
|
||||
CollectorGUID = convertGUID;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
string convertGUID = AssetDatabase.AssetPathToGUID(CollectPath);
|
||||
if(string.IsNullOrEmpty(convertGUID) == false)
|
||||
{
|
||||
CollectorGUID = convertGUID;
|
||||
}
|
||||
*/
|
||||
|
||||
return isFixed;
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
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))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
// 收集打包资源
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
foreach (string assetPath in findAssets)
|
||||
{
|
||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting asset file is existed : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
|
||||
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
||||
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
||||
if (address.StartsWith("Assets/") || address.StartsWith("assets/"))
|
||||
throw new Exception($"The address can not set asset path in collector : {CollectPath} \nAssetPath: {assetPath}");
|
||||
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in collector : {CollectPath} \nAssetPath:\n {existed}\n {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
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)
|
||||
{
|
||||
string address = GetAddress(command, group, assetPath);
|
||||
string bundleName = GetBundleName(command, group, assetPath);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
|
||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
string address = GetAddress(command, group, assetPath);
|
||||
string bundleName = GetBundleName(command, group, assetPath);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags);
|
||||
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
collectAssetInfo.DependAssets = new List<string>();
|
||||
else
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
collectAssetInfo.DependAssets = new List<string>();
|
||||
else
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
||||
|
||||
return collectAssetInfo;
|
||||
}
|
||||
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
||||
{
|
||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
return collectAssetInfo;
|
||||
}
|
||||
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
||||
{
|
||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
||||
{
|
||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 忽略文件夹
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
return false;
|
||||
// 忽略文件夹
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
return false;
|
||||
|
||||
// 忽略编辑器下的类型资源
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(LightingDataAsset))
|
||||
return false;
|
||||
// 忽略编辑器下的类型资源
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(LightingDataAsset))
|
||||
return false;
|
||||
|
||||
// 忽略Unity引擎无法识别的文件
|
||||
if (command.IgnoreDefaultType)
|
||||
{
|
||||
if (assetType == typeof(UnityEditor.DefaultAsset))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 忽略Unity引擎无法识别的文件
|
||||
if (command.IgnoreDefaultType)
|
||||
{
|
||||
if (assetType == typeof(UnityEditor.DefaultAsset))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
||||
return false;
|
||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
// 根据规则设置过滤资源文件
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
}
|
||||
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (command.EnableAddressable == false)
|
||||
return string.Empty;
|
||||
return true;
|
||||
}
|
||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
// 根据规则设置过滤资源文件
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
}
|
||||
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (command.EnableAddressable == false)
|
||||
return string.Empty;
|
||||
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return string.Empty;
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return string.Empty;
|
||||
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return adressValue;
|
||||
}
|
||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (command.AutoCollectShaders)
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
|
||||
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return adressValue;
|
||||
}
|
||||
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
if (command.AutoCollectShaders)
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return shaderPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取其它资源打包规则结果
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
||||
}
|
||||
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (string assetPath in depends)
|
||||
{
|
||||
// 注意:排除主资源对象
|
||||
if (assetPath == mainAssetPath)
|
||||
continue;
|
||||
// 获取其它资源打包规则结果
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData));
|
||||
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
||||
}
|
||||
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (string assetPath in depends)
|
||||
{
|
||||
// 注意:排除主资源对象
|
||||
if (assetPath == mainAssetPath)
|
||||
continue;
|
||||
|
||||
if (IsValidateAsset(command, assetPath))
|
||||
result.Add(assetPath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (IsValidateAsset(command, assetPath))
|
||||
result.Add(assetPath);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,257 +8,257 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "v2.0.0";
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "v2.0.0";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
|
||||
public const string XmlShowPackageView = "ShowPackageView";
|
||||
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||
public const string XmlShowPackageView = "ShowPackageView";
|
||||
public const string XmlShowEditorAlias = "ShowEditorAlias";
|
||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||
|
||||
public const string XmlPackage = "Package";
|
||||
public const string XmlPackageName = "PackageName";
|
||||
public const string XmlPackageDesc = "PackageDesc";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlLocationToLower = "LocationToLower";
|
||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
||||
public const string XmlPackage = "Package";
|
||||
public const string XmlPackageName = "PackageName";
|
||||
public const string XmlPackageDesc = "PackageDesc";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlLocationToLower = "LocationToLower";
|
||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
||||
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||
public const string XmlGroupName = "GroupName";
|
||||
public const string XmlGroupDesc = "GroupDesc";
|
||||
public const string XmlGroup = "Group";
|
||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||
public const string XmlGroupName = "GroupName";
|
||||
public const string XmlGroupDesc = "GroupDesc";
|
||||
|
||||
public const string XmlCollector = "Collector";
|
||||
public const string XmlCollectPath = "CollectPath";
|
||||
public const string XmlCollectorGUID = "CollectGUID";
|
||||
public const string XmlCollectorType = "CollectType";
|
||||
public const string XmlAddressRule = "AddressRule";
|
||||
public const string XmlPackRule = "PackRule";
|
||||
public const string XmlFilterRule = "FilterRule";
|
||||
public const string XmlUserData = "UserData";
|
||||
public const string XmlAssetTags = "AssetTags";
|
||||
public const string XmlCollector = "Collector";
|
||||
public const string XmlCollectPath = "CollectPath";
|
||||
public const string XmlCollectorGUID = "CollectGUID";
|
||||
public const string XmlCollectorType = "CollectType";
|
||||
public const string XmlAddressRule = "AddressRule";
|
||||
public const string XmlPackRule = "PackRule";
|
||||
public const string XmlFilterRule = "FilterRule";
|
||||
public const string XmlUserData = "UserData";
|
||||
public const string XmlAssetTags = "AssetTags";
|
||||
|
||||
/// <summary>
|
||||
/// 导入XML配置表
|
||||
/// </summary>
|
||||
public static void ImportXmlConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
/// <summary>
|
||||
/// 导入XML配置表
|
||||
/// </summary>
|
||||
public static void ImportXmlConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
if (Path.GetExtension(filePath) != ".xml")
|
||||
throw new Exception($"Only support xml : {filePath}");
|
||||
if (Path.GetExtension(filePath) != ".xml")
|
||||
throw new Exception($"Only support xml : {filePath}");
|
||||
|
||||
// 加载配置文件
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(filePath);
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
// 加载配置文件
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.Load(filePath);
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
|
||||
// 读取配置版本
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if (configVersion != ConfigVersion)
|
||||
{
|
||||
if (UpdateXmlConfig(xmlDoc) == false)
|
||||
throw new Exception($"The config version update failed : {configVersion} -> {ConfigVersion}");
|
||||
else
|
||||
Debug.Log($"The config version update succeed : {configVersion} -> {ConfigVersion}");
|
||||
}
|
||||
// 读取配置版本
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if (configVersion != ConfigVersion)
|
||||
{
|
||||
if (UpdateXmlConfig(xmlDoc) == false)
|
||||
throw new Exception($"The config version update failed : {configVersion} -> {ConfigVersion}");
|
||||
else
|
||||
Debug.Log($"The config version update succeed : {configVersion} -> {ConfigVersion}");
|
||||
}
|
||||
|
||||
// 读取公共配置
|
||||
bool uniqueBundleName = false;
|
||||
bool showPackageView = false;
|
||||
bool showEditorAlias = false;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlShowPackageView))
|
||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||
if (commonElement.HasAttribute(XmlShowEditorAlias))
|
||||
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
||||
if (commonElement.HasAttribute(XmlUniqueBundleName))
|
||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||
}
|
||||
// 读取公共配置
|
||||
bool uniqueBundleName = false;
|
||||
bool showPackageView = false;
|
||||
bool showEditorAlias = false;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlShowPackageView))
|
||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||
if (commonElement.HasAttribute(XmlShowEditorAlias))
|
||||
showEditorAlias = commonElement.GetAttribute(XmlShowEditorAlias) == "True" ? true : false;
|
||||
if (commonElement.HasAttribute(XmlUniqueBundleName))
|
||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||
}
|
||||
|
||||
// 读取包裹配置
|
||||
List<AssetBundleCollectorPackage> packages = new List<AssetBundleCollectorPackage>();
|
||||
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||
foreach (var packageNode in packageNodeList)
|
||||
{
|
||||
XmlElement packageElement = packageNode as XmlElement;
|
||||
if (packageElement.HasAttribute(XmlPackageName) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackageName} in {XmlPackage}");
|
||||
if (packageElement.HasAttribute(XmlPackageDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackageDesc} in {XmlPackage}");
|
||||
// 读取包裹配置
|
||||
List<AssetBundleCollectorPackage> packages = new List<AssetBundleCollectorPackage>();
|
||||
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||
foreach (var packageNode in packageNodeList)
|
||||
{
|
||||
XmlElement packageElement = packageNode as XmlElement;
|
||||
if (packageElement.HasAttribute(XmlPackageName) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackageName} in {XmlPackage}");
|
||||
if (packageElement.HasAttribute(XmlPackageDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackageDesc} in {XmlPackage}");
|
||||
|
||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
||||
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
||||
packages.Add(package);
|
||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
||||
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
||||
packages.Add(package);
|
||||
|
||||
// 读取分组配置
|
||||
var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement groupElement = groupNode as XmlElement;
|
||||
if (groupElement.HasAttribute(XmlGroupActiveRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupActiveRule} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||
// 读取分组配置
|
||||
var groupNodeList = packageElement.GetElementsByTagName(XmlGroup);
|
||||
foreach (var groupNode in groupNodeList)
|
||||
{
|
||||
XmlElement groupElement = groupNode as XmlElement;
|
||||
if (groupElement.HasAttribute(XmlGroupActiveRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupActiveRule} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupName) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupName} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlGroupDesc) == false)
|
||||
throw new Exception($"Not found attribute {XmlGroupDesc} in {XmlGroup}");
|
||||
if (groupElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlGroup}");
|
||||
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.ActiveRuleName = groupElement.GetAttribute(XmlGroupActiveRule);
|
||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||
package.Groups.Add(group);
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.ActiveRuleName = groupElement.GetAttribute(XmlGroupActiveRule);
|
||||
group.GroupName = groupElement.GetAttribute(XmlGroupName);
|
||||
group.GroupDesc = groupElement.GetAttribute(XmlGroupDesc);
|
||||
group.AssetTags = groupElement.GetAttribute(XmlAssetTags);
|
||||
package.Groups.Add(group);
|
||||
|
||||
// 读取收集器配置
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
if (collectorElement.HasAttribute(XmlCollectPath) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectorGUID} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlCollectorType) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAddressRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlPackRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||
// 读取收集器配置
|
||||
var collectorNodeList = groupElement.GetElementsByTagName(XmlCollector);
|
||||
foreach (var collectorNode in collectorNodeList)
|
||||
{
|
||||
XmlElement collectorElement = collectorNode as XmlElement;
|
||||
if (collectorElement.HasAttribute(XmlCollectPath) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectPath} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlCollectorGUID) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectorGUID} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlCollectorType) == false)
|
||||
throw new Exception($"Not found attribute {XmlCollectorType} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAddressRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlAddressRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlPackRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlPackRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlFilterRule) == false)
|
||||
throw new Exception($"Not found attribute {XmlFilterRule} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlUserData) == false)
|
||||
throw new Exception($"Not found attribute {XmlUserData} in {XmlCollector}");
|
||||
if (collectorElement.HasAttribute(XmlAssetTags) == false)
|
||||
throw new Exception($"Not found attribute {XmlAssetTags} in {XmlCollector}");
|
||||
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
||||
collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
||||
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
}
|
||||
AssetBundleCollector collector = new AssetBundleCollector();
|
||||
collector.CollectPath = collectorElement.GetAttribute(XmlCollectPath);
|
||||
collector.CollectorGUID = collectorElement.GetAttribute(XmlCollectorGUID);
|
||||
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(collectorElement.GetAttribute(XmlCollectorType));
|
||||
collector.AddressRuleName = collectorElement.GetAttribute(XmlAddressRule);
|
||||
collector.PackRuleName = collectorElement.GetAttribute(XmlPackRule);
|
||||
collector.FilterRuleName = collectorElement.GetAttribute(XmlFilterRule);
|
||||
collector.UserData = collectorElement.GetAttribute(XmlUserData);
|
||||
collector.AssetTags = collectorElement.GetAttribute(XmlAssetTags);
|
||||
group.Collectors.Add(collector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检测配置错误
|
||||
foreach (var package in packages)
|
||||
{
|
||||
package.CheckConfigError();
|
||||
}
|
||||
// 检测配置错误
|
||||
foreach (var package in packages)
|
||||
{
|
||||
package.CheckConfigError();
|
||||
}
|
||||
|
||||
// 保存配置数据
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"Asset bundle collector config import complete!");
|
||||
}
|
||||
// 保存配置数据
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||
AssetBundleCollectorSettingData.Setting.ShowEditorAlias = showEditorAlias;
|
||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
Debug.Log($"Asset bundle collector config import complete!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出XML配置表
|
||||
/// </summary>
|
||||
public static void ExportXmlConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
/// <summary>
|
||||
/// 导出XML配置表
|
||||
/// </summary>
|
||||
public static void ExportXmlConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
sb.AppendLine("<root>");
|
||||
sb.AppendLine("</root>");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||
sb.AppendLine("<root>");
|
||||
sb.AppendLine("</root>");
|
||||
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(sb.ToString());
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(sb.ToString());
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
|
||||
// 设置配置版本
|
||||
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||
// 设置配置版本
|
||||
root.SetAttribute(XmlVersion, ConfigVersion);
|
||||
|
||||
// 设置公共配置
|
||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||
root.AppendChild(commonElement);
|
||||
// 设置公共配置
|
||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||
commonElement.SetAttribute(XmlShowEditorAlias, AssetBundleCollectorSettingData.Setting.ShowEditorAlias.ToString());
|
||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||
root.AppendChild(commonElement);
|
||||
|
||||
// 设置Package配置
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
var packageElement = xmlDoc.CreateElement(XmlPackage);
|
||||
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
||||
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
||||
root.AppendChild(packageElement);
|
||||
// 设置Package配置
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
var packageElement = xmlDoc.CreateElement(XmlPackage);
|
||||
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
||||
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
||||
root.AppendChild(packageElement);
|
||||
|
||||
// 设置分组配置
|
||||
foreach (var group in package.Groups)
|
||||
{
|
||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||
groupElement.SetAttribute(XmlGroupActiveRule, group.ActiveRuleName);
|
||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||
packageElement.AppendChild(groupElement);
|
||||
// 设置分组配置
|
||||
foreach (var group in package.Groups)
|
||||
{
|
||||
var groupElement = xmlDoc.CreateElement(XmlGroup);
|
||||
groupElement.SetAttribute(XmlGroupActiveRule, group.ActiveRuleName);
|
||||
groupElement.SetAttribute(XmlGroupName, group.GroupName);
|
||||
groupElement.SetAttribute(XmlGroupDesc, group.GroupDesc);
|
||||
groupElement.SetAttribute(XmlAssetTags, group.AssetTags);
|
||||
packageElement.AppendChild(groupElement);
|
||||
|
||||
// 设置收集器配置
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
||||
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置收集器配置
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
var collectorElement = xmlDoc.CreateElement(XmlCollector);
|
||||
collectorElement.SetAttribute(XmlCollectPath, collector.CollectPath);
|
||||
collectorElement.SetAttribute(XmlCollectorGUID, collector.CollectorGUID);
|
||||
collectorElement.SetAttribute(XmlCollectorType, collector.CollectorType.ToString());
|
||||
collectorElement.SetAttribute(XmlAddressRule, collector.AddressRuleName);
|
||||
collectorElement.SetAttribute(XmlPackRule, collector.PackRuleName);
|
||||
collectorElement.SetAttribute(XmlFilterRule, collector.FilterRuleName);
|
||||
collectorElement.SetAttribute(XmlUserData, collector.UserData);
|
||||
collectorElement.SetAttribute(XmlAssetTags, collector.AssetTags);
|
||||
groupElement.AppendChild(collectorElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 生成配置文件
|
||||
xmlDoc.Save(savePath);
|
||||
Debug.Log($"Asset bundle collector config export complete!");
|
||||
}
|
||||
// 生成配置文件
|
||||
xmlDoc.Save(savePath);
|
||||
Debug.Log($"Asset bundle collector config export complete!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 升级XML配置表
|
||||
/// </summary>
|
||||
private static bool UpdateXmlConfig(XmlDocument xmlDoc)
|
||||
{
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if (configVersion == ConfigVersion)
|
||||
return true;
|
||||
/// <summary>
|
||||
/// 升级XML配置表
|
||||
/// </summary>
|
||||
private static bool UpdateXmlConfig(XmlDocument xmlDoc)
|
||||
{
|
||||
XmlElement root = xmlDoc.DocumentElement;
|
||||
string configVersion = root.GetAttribute(XmlVersion);
|
||||
if (configVersion == ConfigVersion)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,120 +7,120 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleCollectorGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GroupName = string.Empty;
|
||||
[Serializable]
|
||||
public class AssetBundleCollectorGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GroupName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组描述
|
||||
/// </summary>
|
||||
public string GroupDesc = string.Empty;
|
||||
/// <summary>
|
||||
/// 分组描述
|
||||
/// </summary>
|
||||
public string GroupDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 分组激活规则
|
||||
/// </summary>
|
||||
public string ActiveRuleName = nameof(EnableGroup);
|
||||
/// <summary>
|
||||
/// 分组激活规则
|
||||
/// </summary>
|
||||
public string ActiveRuleName = nameof(EnableGroup);
|
||||
|
||||
/// <summary>
|
||||
/// 分组的收集器列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollector> Collectors = new List<AssetBundleCollector>();
|
||||
/// <summary>
|
||||
/// 分组的收集器列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollector> Collectors = new List<AssetBundleCollector>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
|
||||
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
|
||||
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
return;
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
return;
|
||||
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
collector.CheckConfigError();
|
||||
}
|
||||
}
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
collector.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
if (collector.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
if (collector.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
{
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
{
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
var temper = collector.GetAllCollectAssets(command, this);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
// 收集打包资源
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
var temper = collector.GetAllCollectAssets(command, this);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} in group : {GroupName} \nAssetPath:\n {existed}\n {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
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
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetBundleCollectorPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName = string.Empty;
|
||||
[Serializable]
|
||||
public class AssetBundleCollectorPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹描述
|
||||
/// </summary>
|
||||
public string PackageDesc = string.Empty;
|
||||
/// <summary>
|
||||
/// 包裹描述
|
||||
/// </summary>
|
||||
public string PackageDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower = false;
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower = false;
|
||||
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID = false;
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType = true;
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType = true;
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders = true;
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders = true;
|
||||
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||
/// <summary>
|
||||
/// 分组列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollectorGroup> Groups = new List<AssetBundleCollectorGroup>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
group.CheckConfigError();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
group.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
if (group.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修复配置错误
|
||||
/// </summary>
|
||||
public bool FixConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
if (group.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
var temper = group.GetAllCollectAssets(command);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
// 收集打包资源
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
var temper = group.GetAllCollectAssets(command);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
result.Add(assetInfo.AssetPath, assetInfo);
|
||||
else
|
||||
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
// 检测可寻址地址是否重复
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
var addressTemper = new Dictionary<string, string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
{
|
||||
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
string address = collectInfoPair.Value.Address;
|
||||
string assetPath = collectInfoPair.Value.AssetPath;
|
||||
if (string.IsNullOrEmpty(address))
|
||||
continue;
|
||||
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} \nAssetPath:\n {existed}\n {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (addressTemper.TryGetValue(address, out var existed) == false)
|
||||
addressTemper.Add(address, assetPath);
|
||||
else
|
||||
throw new Exception($"The address is existed : {address} \nAssetPath:\n {existed}\n {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
return result.Values.ToList();
|
||||
}
|
||||
// 返回列表
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public List<string> GetAllTags()
|
||||
{
|
||||
HashSet<string> result = new HashSet<string>();
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
List<string> groupTags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
foreach (var tag in groupTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public List<string> GetAllTags()
|
||||
{
|
||||
HashSet<string> result = new HashSet<string>();
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
List<string> groupTags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
foreach (var tag in groupTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
List<string> collectorTags = EditorTools.StringToStringList(collector.AssetTags, ';');
|
||||
foreach (var tag in collectorTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.ToList();
|
||||
}
|
||||
}
|
||||
foreach (var collector in group.Collectors)
|
||||
{
|
||||
List<string> collectorTags = EditorTools.StringToStringList(collector.AssetTags, ';');
|
||||
foreach (var tag in collectorTags)
|
||||
{
|
||||
if (result.Contains(tag) == false)
|
||||
result.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.ToList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,125 +6,125 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[CreateAssetMenu(fileName = "AssetBundleCollectorSetting", menuName = "YooAsset/Create AssetBundle Collector Settings")]
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示包裹列表视图
|
||||
/// </summary>
|
||||
public bool ShowPackageView = false;
|
||||
[CreateAssetMenu(fileName = "AssetBundleCollectorSetting", menuName = "YooAsset/Create AssetBundle Collector Settings")]
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 显示包裹列表视图
|
||||
/// </summary>
|
||||
public bool ShowPackageView = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示编辑器别名
|
||||
/// </summary>
|
||||
public bool ShowEditorAlias = false;
|
||||
/// <summary>
|
||||
/// 是否显示编辑器别名
|
||||
/// </summary>
|
||||
public bool ShowEditorAlias = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName = false;
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollectorPackage> Packages = new List<AssetBundleCollectorPackage>();
|
||||
/// <summary>
|
||||
/// 包裹列表
|
||||
/// </summary>
|
||||
public List<AssetBundleCollectorPackage> Packages = new List<AssetBundleCollectorPackage>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public void ClearAll()
|
||||
{
|
||||
ShowPackageView = false;
|
||||
UniqueBundleName = false;
|
||||
ShowEditorAlias = false;
|
||||
Packages.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public void ClearAll()
|
||||
{
|
||||
ShowPackageView = false;
|
||||
UniqueBundleName = false;
|
||||
ShowEditorAlias = false;
|
||||
Packages.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测包裹配置错误
|
||||
/// </summary>
|
||||
public void CheckPackageConfigError(string packageName)
|
||||
{
|
||||
var package = GetPackage(packageName);
|
||||
package.CheckConfigError();
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测包裹配置错误
|
||||
/// </summary>
|
||||
public void CheckPackageConfigError(string packageName)
|
||||
{
|
||||
var package = GetPackage(packageName);
|
||||
package.CheckConfigError();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测所有配置错误
|
||||
/// </summary>
|
||||
public void CheckAllPackageConfigError()
|
||||
{
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
package.CheckConfigError();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 检测所有配置错误
|
||||
/// </summary>
|
||||
public void CheckAllPackageConfigError()
|
||||
{
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
package.CheckConfigError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复所有配置错误
|
||||
/// </summary>
|
||||
public bool FixAllPackageConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
if (package.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修复所有配置错误
|
||||
/// </summary>
|
||||
public bool FixAllPackageConfigError()
|
||||
{
|
||||
bool isFixed = false;
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
if (package.FixConfigError())
|
||||
{
|
||||
isFixed = true;
|
||||
}
|
||||
}
|
||||
return isFixed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public List<string> GetPackageAllTags(string packageName)
|
||||
{
|
||||
var package = GetPackage(packageName);
|
||||
return package.GetAllTags();
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public List<string> GetPackageAllTags(string packageName)
|
||||
{
|
||||
var package = GetPackage(packageName);
|
||||
return package.GetAllTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包裹收集的资源文件
|
||||
/// </summary>
|
||||
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Build package name is null or empty !");
|
||||
/// <summary>
|
||||
/// 获取包裹收集的资源文件
|
||||
/// </summary>
|
||||
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Build package name is null or empty !");
|
||||
|
||||
// 检测配置合法性
|
||||
var package = GetPackage(packageName);
|
||||
package.CheckConfigError();
|
||||
// 检测配置合法性
|
||||
var package = GetPackage(packageName);
|
||||
package.CheckConfigError();
|
||||
|
||||
// 创建资源收集命令
|
||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||
package.EnableAddressable,
|
||||
package.LocationToLower,
|
||||
package.IncludeAssetGUID,
|
||||
package.IgnoreDefaultType,
|
||||
package.AutoCollectShaders,
|
||||
UniqueBundleName);
|
||||
// 创建资源收集命令
|
||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||
package.EnableAddressable,
|
||||
package.LocationToLower,
|
||||
package.IncludeAssetGUID,
|
||||
package.IgnoreDefaultType,
|
||||
package.AutoCollectShaders,
|
||||
UniqueBundleName);
|
||||
|
||||
// 获取收集的资源集合
|
||||
CollectResult collectResult = new CollectResult(command);
|
||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||
return collectResult;
|
||||
}
|
||||
// 获取收集的资源集合
|
||||
CollectResult collectResult = new CollectResult(command);
|
||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||
return collectResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包裹类
|
||||
/// </summary>
|
||||
public AssetBundleCollectorPackage GetPackage(string packageName)
|
||||
{
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
return package;
|
||||
}
|
||||
throw new Exception($"Not found package : {packageName}");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取包裹类
|
||||
/// </summary>
|
||||
public AssetBundleCollectorPackage GetPackage(string packageName)
|
||||
{
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
return package;
|
||||
}
|
||||
throw new Exception($"Not found package : {packageName}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,424 +7,424 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorSettingData
|
||||
{
|
||||
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
|
||||
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
|
||||
public class AssetBundleCollectorSettingData
|
||||
{
|
||||
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, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
|
||||
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, System.Type> _cachePackRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IPackRule> _cachePackRuleInstance = new Dictionary<string, IPackRule>();
|
||||
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, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
static AssetBundleCollectorSettingData()
|
||||
{
|
||||
// IPackRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cachePackRuleTypes.Clear();
|
||||
_cachePackRuleInstance.Clear();
|
||||
static AssetBundleCollectorSettingData()
|
||||
{
|
||||
// IPackRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cachePackRuleTypes.Clear();
|
||||
_cachePackRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(PackSeparately),
|
||||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGroup),
|
||||
typeof(PackRawFile),
|
||||
typeof(PackShaderVariants)
|
||||
};
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(PackSeparately),
|
||||
typeof(PackDirectory),
|
||||
typeof(PackTopDirectory),
|
||||
typeof(PackCollector),
|
||||
typeof(PackGroup),
|
||||
typeof(PackRawFile),
|
||||
typeof(PackShaderVariants)
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cachePackRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cachePackRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IPackRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cachePackRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cachePackRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IFilterRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheFilterRuleTypes.Clear();
|
||||
_cacheFilterRuleInstance.Clear();
|
||||
// IFilterRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheFilterRuleTypes.Clear();
|
||||
_cacheFilterRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(CollectAll),
|
||||
typeof(CollectScene),
|
||||
typeof(CollectPrefab),
|
||||
typeof(CollectSprite)
|
||||
};
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(CollectAll),
|
||||
typeof(CollectScene),
|
||||
typeof(CollectPrefab),
|
||||
typeof(CollectSprite)
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheFilterRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheFilterRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IFilterRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheFilterRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheFilterRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IAddressRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheAddressRuleTypes.Clear();
|
||||
_cacheAddressRuleInstance.Clear();
|
||||
// IAddressRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheAddressRuleTypes.Clear();
|
||||
_cacheAddressRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByFolderAndFileName),
|
||||
typeof(AddressByGroupAndFileName),
|
||||
typeof(AddressDisable)
|
||||
};
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(AddressByFileName),
|
||||
typeof(AddressByFolderAndFileName),
|
||||
typeof(AddressByGroupAndFileName),
|
||||
typeof(AddressDisable)
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheAddressRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheAddressRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IAddressRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheAddressRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheAddressRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
|
||||
// IActiveRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheActiveRuleTypes.Clear();
|
||||
_cacheActiveRuleInstance.Clear();
|
||||
// IActiveRule
|
||||
{
|
||||
// 清空缓存集合
|
||||
_cacheActiveRuleTypes.Clear();
|
||||
_cacheActiveRuleInstance.Clear();
|
||||
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(EnableGroup),
|
||||
typeof(DisableGroup),
|
||||
};
|
||||
// 获取所有类型
|
||||
List<Type> types = new List<Type>(100)
|
||||
{
|
||||
typeof(EnableGroup),
|
||||
typeof(DisableGroup),
|
||||
};
|
||||
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
Type type = types[i];
|
||||
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
|
||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static AssetBundleCollectorSetting _setting = null;
|
||||
public static AssetBundleCollectorSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
private static AssetBundleCollectorSetting _setting = null;
|
||||
public static AssetBundleCollectorSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
_setting = SettingLoader.LoadSettingData<AssetBundleCollectorSetting>();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetBundleCollectorSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复配置文件
|
||||
/// </summary>
|
||||
public static void FixFile()
|
||||
{
|
||||
bool isFixed = Setting.FixAllPackageConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 修复配置文件
|
||||
/// </summary>
|
||||
public static void FixFile()
|
||||
{
|
||||
bool isFixed = Setting.FixAllPackageConfigError();
|
||||
if (isFixed)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.ClearAll();
|
||||
SaveFile();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.ClearAll();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
public static List<RuleDisplayName> GetActiveRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetAddressRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheAddressRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetPackRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cachePackRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetFilterRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheFilterRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
private static string GetRuleDisplayName(string name, Type type)
|
||||
{
|
||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||
return attribute.DisplayName;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
public static List<RuleDisplayName> GetActiveRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheActiveRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetAddressRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheAddressRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetPackRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cachePackRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
public static List<RuleDisplayName> GetFilterRuleNames()
|
||||
{
|
||||
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||
foreach (var pair in _cacheFilterRuleTypes)
|
||||
{
|
||||
RuleDisplayName ruleName = new RuleDisplayName();
|
||||
ruleName.ClassName = pair.Key;
|
||||
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||
names.Add(ruleName);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
private static string GetRuleDisplayName(string name, Type type)
|
||||
{
|
||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||
return attribute.DisplayName;
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasAddressRuleName(string ruleName)
|
||||
{
|
||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasPackRuleName(string ruleName)
|
||||
{
|
||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasFilterRuleName(string ruleName)
|
||||
{
|
||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasAddressRuleName(string ruleName)
|
||||
{
|
||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasPackRuleName(string ruleName)
|
||||
{
|
||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
public static bool HasFilterRuleName(string ruleName)
|
||||
{
|
||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||
}
|
||||
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||
return instance;
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IActiveRule)Activator.CreateInstance(type);
|
||||
_cacheActiveRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IActiveRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
||||
return instance;
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IActiveRule)Activator.CreateInstance(type);
|
||||
_cacheActiveRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IActiveRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IAddressRule GetAddressRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheAddressRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IAddressRule)Activator.CreateInstance(type);
|
||||
_cacheAddressRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IAddressRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IPackRule GetPackRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cachePackRuleInstance.TryGetValue(ruleName, out IPackRule instance))
|
||||
return instance;
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheAddressRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IAddressRule)Activator.CreateInstance(type);
|
||||
_cacheAddressRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IAddressRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IPackRule GetPackRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cachePackRuleInstance.TryGetValue(ruleName, out IPackRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cachePackRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IPackRule)Activator.CreateInstance(type);
|
||||
_cachePackRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IPackRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheFilterRuleInstance.TryGetValue(ruleName, out IFilterRule instance))
|
||||
return instance;
|
||||
// 如果不存在创建类的实例
|
||||
if (_cachePackRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IPackRule)Activator.CreateInstance(type);
|
||||
_cachePackRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IPackRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
public static IFilterRule GetFilterRuleInstance(string ruleName)
|
||||
{
|
||||
if (_cacheFilterRuleInstance.TryGetValue(ruleName, out IFilterRule instance))
|
||||
return instance;
|
||||
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheFilterRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IFilterRule)Activator.CreateInstance(type);
|
||||
_cacheFilterRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
// 如果不存在创建类的实例
|
||||
if (_cacheFilterRuleTypes.TryGetValue(ruleName, out Type type))
|
||||
{
|
||||
instance = (IFilterRule)Activator.CreateInstance(type);
|
||||
_cacheFilterRuleInstance.Add(ruleName, instance);
|
||||
return instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||
}
|
||||
}
|
||||
|
||||
// 公共参数编辑相关
|
||||
public static void ModifyShowPackageView(bool showPackageView)
|
||||
{
|
||||
Setting.ShowPackageView = showPackageView;
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void ModifyShowEditorAlias(bool showAlias)
|
||||
{
|
||||
Setting.ShowEditorAlias = showAlias;
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||
{
|
||||
Setting.UniqueBundleName = uniqueBundleName;
|
||||
IsDirty = true;
|
||||
}
|
||||
// 公共参数编辑相关
|
||||
public static void ModifyShowPackageView(bool showPackageView)
|
||||
{
|
||||
Setting.ShowPackageView = showPackageView;
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void ModifyShowEditorAlias(bool showAlias)
|
||||
{
|
||||
Setting.ShowEditorAlias = showAlias;
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||
{
|
||||
Setting.UniqueBundleName = uniqueBundleName;
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 资源包裹编辑相关
|
||||
public static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||
{
|
||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||
package.PackageName = packageName;
|
||||
Setting.Packages.Add(package);
|
||||
IsDirty = true;
|
||||
return package;
|
||||
}
|
||||
public static void RemovePackage(AssetBundleCollectorPackage package)
|
||||
{
|
||||
if (Setting.Packages.Remove(package))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove package : {package.PackageName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyPackage(AssetBundleCollectorPackage package)
|
||||
{
|
||||
if (package != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
// 资源包裹编辑相关
|
||||
public static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||
{
|
||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||
package.PackageName = packageName;
|
||||
Setting.Packages.Add(package);
|
||||
IsDirty = true;
|
||||
return package;
|
||||
}
|
||||
public static void RemovePackage(AssetBundleCollectorPackage package)
|
||||
{
|
||||
if (Setting.Packages.Remove(package))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove package : {package.PackageName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyPackage(AssetBundleCollectorPackage package)
|
||||
{
|
||||
if (package != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static AssetBundleCollectorGroup CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
||||
{
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
package.Groups.Add(group);
|
||||
IsDirty = true;
|
||||
return group;
|
||||
}
|
||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (package.Groups.Remove(group))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (package != null && group != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
// 资源分组编辑相关
|
||||
public static AssetBundleCollectorGroup CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
||||
{
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
package.Groups.Add(group);
|
||||
IsDirty = true;
|
||||
return group;
|
||||
}
|
||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (package.Groups.Remove(group))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove group : {group.GroupName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||
{
|
||||
if (package != null && group != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
group.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
// 资源收集器编辑相关
|
||||
public static void CreateCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
group.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
if (group != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public static string GetPackageAllTags(string packageName)
|
||||
{
|
||||
var allTags = Setting.GetPackageAllTags(packageName);
|
||||
return string.Join(";", allTags);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取所有的资源标签
|
||||
/// </summary>
|
||||
public static string GetPackageAllTags(string packageName)
|
||||
{
|
||||
var allTags = Setting.GetPackageAllTags(packageName);
|
||||
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
|
||||
{
|
||||
public class CollectAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
public class CollectAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public List<string> AssetTags { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源分类标签
|
||||
/// </summary>
|
||||
public List<string> AssetTags { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
/// <summary>
|
||||
/// 依赖的资源列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
|
||||
|
||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
AssetTags = assetTags;
|
||||
}
|
||||
}
|
||||
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetPath = assetPath;
|
||||
AssetTags = assetTags;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +1,68 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode { private set; get; }
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType { private set; get; }
|
||||
/// <summary>
|
||||
/// 忽略Unity引擎无法识别的文件
|
||||
/// </summary>
|
||||
public bool IgnoreDefaultType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { private set; get; }
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID { private set; get; }
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders { private set; get; }
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName { private set; get; }
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 着色器统一全名称
|
||||
/// </summary>
|
||||
public string ShadersBundleName { private set; get; }
|
||||
/// <summary>
|
||||
/// 着色器统一全名称
|
||||
/// </summary>
|
||||
public string ShadersBundleName { private set; get; }
|
||||
|
||||
|
||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
||||
{
|
||||
BuildMode = buildMode;
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
LocationToLower = locationToLower;
|
||||
IncludeAssetGUID = includeAssetGUID;
|
||||
IgnoreDefaultType = ignoreDefaultType;
|
||||
AutoCollectShaders = autoCollectShaders;
|
||||
UniqueBundleName = uniqueBundleName;
|
||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
||||
{
|
||||
BuildMode = buildMode;
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
LocationToLower = locationToLower;
|
||||
IncludeAssetGUID = includeAssetGUID;
|
||||
IgnoreDefaultType = ignoreDefaultType;
|
||||
AutoCollectShaders = autoCollectShaders;
|
||||
UniqueBundleName = uniqueBundleName;
|
||||
|
||||
// 着色器统一全名称
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
}
|
||||
// 着色器统一全名称
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,25 +3,25 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { private set; get; }
|
||||
public class CollectResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 收集的资源信息列表
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||
/// <summary>
|
||||
/// 收集的资源信息列表
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||
|
||||
public CollectResult(CollectCommand command)
|
||||
{
|
||||
Command = command;
|
||||
}
|
||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||
{
|
||||
CollectAssets = collectAssets;
|
||||
}
|
||||
}
|
||||
public CollectResult(CollectCommand command)
|
||||
{
|
||||
Command = command;
|
||||
}
|
||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||
{
|
||||
CollectAssets = collectAssets;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源分组激活规则接口
|
||||
/// </summary>
|
||||
public interface IActiveRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否激活分组
|
||||
/// </summary>
|
||||
bool IsActiveGroup();
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源分组激活规则接口
|
||||
/// </summary>
|
||||
public interface IActiveRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否激活分组
|
||||
/// </summary>
|
||||
bool IsActiveGroup();
|
||||
}
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct AddressRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
public struct AddressRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
public AddressRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 寻址规则接口
|
||||
/// </summary>
|
||||
public interface IAddressRule
|
||||
{
|
||||
string GetAssetAddress(AddressRuleData data);
|
||||
}
|
||||
/// <summary>
|
||||
/// 寻址规则接口
|
||||
/// </summary>
|
||||
public interface IAddressRule
|
||||
{
|
||||
string GetAssetAddress(AddressRuleData data);
|
||||
}
|
||||
}
|
|
@ -1,31 +1,31 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct FilterRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
public struct FilterRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
|
||||
public FilterRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
public FilterRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源过滤规则接口
|
||||
/// </summary>
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源过滤规则接口
|
||||
/// </summary>
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
}
|
||||
}
|
|
@ -1,56 +1,56 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct PackRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
public struct PackRuleData
|
||||
{
|
||||
public string AssetPath;
|
||||
public string CollectPath;
|
||||
public string GroupName;
|
||||
public string UserData;
|
||||
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
public PackRuleData(string assetPath, string collectPath, string groupName, string userData)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
CollectPath = collectPath;
|
||||
GroupName = groupName;
|
||||
UserData = userData;
|
||||
}
|
||||
}
|
||||
|
||||
public struct PackRuleResult
|
||||
{
|
||||
private readonly string _bundleName;
|
||||
private readonly string _bundleExtension;
|
||||
public struct PackRuleResult
|
||||
{
|
||||
private readonly string _bundleName;
|
||||
private readonly string _bundleExtension;
|
||||
|
||||
public PackRuleResult(string bundleName, string bundleExtension)
|
||||
{
|
||||
_bundleName = bundleName;
|
||||
_bundleExtension = bundleExtension;
|
||||
}
|
||||
public PackRuleResult(string bundleName, string bundleExtension)
|
||||
{
|
||||
_bundleName = bundleName;
|
||||
_bundleExtension = bundleExtension;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包全名称
|
||||
/// </summary>
|
||||
public string GetBundleName(string packageName, bool uniqueBundleName)
|
||||
{
|
||||
string fullName;
|
||||
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||
if (uniqueBundleName)
|
||||
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
||||
else
|
||||
fullName = $"{bundleName}.{_bundleExtension}";
|
||||
return fullName.ToLower();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源包全名称
|
||||
/// </summary>
|
||||
public string GetBundleName(string packageName, bool uniqueBundleName)
|
||||
{
|
||||
string fullName;
|
||||
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
||||
if (uniqueBundleName)
|
||||
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
||||
else
|
||||
fullName = $"{bundleName}.{_bundleExtension}";
|
||||
return fullName.ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源打包规则接口
|
||||
/// </summary>
|
||||
public interface IPackRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取打包规则结果
|
||||
/// </summary>
|
||||
PackRuleResult GetPackRuleResult(PackRuleData data);
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源打包规则接口
|
||||
/// </summary>
|
||||
public interface IPackRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取打包规则结果
|
||||
/// </summary>
|
||||
PackRuleResult GetPackRuleResult(PackRuleData data);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[DisplayName("启用分组")]
|
||||
public class EnableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
[DisplayName("启用分组")]
|
||||
public class EnableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("禁用分组")]
|
||||
public class DisableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
[DisplayName("禁用分组")]
|
||||
public class DisableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,42 +2,42 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[DisplayName("定位地址: 禁用")]
|
||||
public class AddressDisable : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
[DisplayName("定位地址: 禁用")]
|
||||
public class AddressDisable : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("定位地址: 文件名")]
|
||||
public class AddressByFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
}
|
||||
}
|
||||
[DisplayName("定位地址: 文件名")]
|
||||
public class AddressByFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
return Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("定位地址: 分组名_文件名")]
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return $"{data.GroupName}_{fileName}";
|
||||
}
|
||||
}
|
||||
[DisplayName("定位地址: 分组名_文件名")]
|
||||
public class AddressByGroupAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return $"{data.GroupName}_{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("定位地址: 文件夹名_文件名")]
|
||||
public class AddressByFolderAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
FileInfo fileInfo = new FileInfo(data.AssetPath);
|
||||
return $"{fileInfo.Directory.Name}_{fileName}";
|
||||
}
|
||||
}
|
||||
[DisplayName("定位地址: 文件夹名_文件名")]
|
||||
public class AddressByFolderAndFileName : IAddressRule
|
||||
{
|
||||
string IAddressRule.GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
FileInfo fileInfo = new FileInfo(data.AssetPath);
|
||||
return $"{fileInfo.Directory.Name}_{fileName}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,76 +6,76 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class DefaultFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
public class DefaultFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
private readonly static HashSet<string> _ignoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
|
||||
/// <summary>
|
||||
/// 查询是否为忽略文件
|
||||
/// </summary>
|
||||
public static bool IsIgnoreFile(string fileExtension)
|
||||
{
|
||||
return _ignoreFileExtensions.Contains(fileExtension);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询是否为忽略文件
|
||||
/// </summary>
|
||||
public static bool IsIgnoreFile(string fileExtension)
|
||||
{
|
||||
return _ignoreFileExtensions.Contains(fileExtension);
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||
}
|
||||
}
|
||||
[DisplayName("收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
}
|
||||
}
|
||||
[DisplayName("收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集精灵类型的纹理")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
if (mainAssetType == typeof(Texture2D))
|
||||
{
|
||||
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
||||
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
[DisplayName("收集精灵类型的纹理")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
if (mainAssetType == typeof(Texture2D))
|
||||
{
|
||||
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
|
||||
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
}
|
||||
}
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,158 +4,158 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class DefaultPackRule
|
||||
{
|
||||
/// <summary>
|
||||
/// AssetBundle文件的后缀名
|
||||
/// </summary>
|
||||
public const string AssetBundleFileExtension = "bundle";
|
||||
public class DefaultPackRule
|
||||
{
|
||||
/// <summary>
|
||||
/// AssetBundle文件的后缀名
|
||||
/// </summary>
|
||||
public const string AssetBundleFileExtension = "bundle";
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件的后缀名
|
||||
/// </summary>
|
||||
public const string RawFileExtension = "rawfile";
|
||||
/// <summary>
|
||||
/// 原生文件的后缀名
|
||||
/// </summary>
|
||||
public const string RawFileExtension = "rawfile";
|
||||
|
||||
/// <summary>
|
||||
/// Unity着色器资源包名称
|
||||
/// </summary>
|
||||
public const string ShadersBundleName = "unityshaders";
|
||||
/// <summary>
|
||||
/// Unity着色器资源包名称
|
||||
/// </summary>
|
||||
public const string ShadersBundleName = "unityshaders";
|
||||
|
||||
|
||||
public static PackRuleResult CreateShadersPackRuleResult()
|
||||
{
|
||||
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public static PackRuleResult CreateShadersPackRuleResult()
|
||||
{
|
||||
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以文件路径作为资源包名
|
||||
/// 注意:每个文件独自打资源包
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 文件路径")]
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = PathUtility.RemoveExtension(data.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 以文件路径作为资源包名
|
||||
/// 注意:每个文件独自打资源包
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image_backgroud.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view_main.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 文件路径")]
|
||||
public class PackSeparately : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = PathUtility.RemoveExtension(data.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以父类文件夹路径作为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 父类文件夹路径")]
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 以父类文件夹路径作为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop_image.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop_view.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 父类文件夹路径")]
|
||||
public class PackDirectory : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(data.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径下顶级文件夹为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||
assetPath = assetPath.TrimStart('/');
|
||||
string[] splits = assetPath.Split('/');
|
||||
if (splits.Length > 0)
|
||||
{
|
||||
if (Path.HasExtension(splits[0]))
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 以收集器路径下顶级文件夹为资源包名
|
||||
/// 注意:文件夹下所有文件打进一个资源包
|
||||
/// 例如:收集器路径为 "Assets/UIPanel"
|
||||
/// 例如:"Assets/UIPanel/Shop/Image/backgroud.png" --> "assets_uipanel_shop.bundle"
|
||||
/// 例如:"Assets/UIPanel/Shop/View/main.prefab" --> "assets_uipanel_shop.bundle"
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 收集器下顶级文件夹路径")]
|
||||
public class PackTopDirectory : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath.Replace(data.CollectPath, string.Empty);
|
||||
assetPath = assetPath.TrimStart('/');
|
||||
string[] splits = assetPath.Split('/');
|
||||
if (splits.Length > 0)
|
||||
{
|
||||
if (Path.HasExtension(splits[0]))
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
string bundleName = $"{data.CollectPath}/{splits[0]}";
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Not found root directory : {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 收集器路径")]
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName;
|
||||
string collectPath = data.CollectPath;
|
||||
if (AssetDatabase.IsValidFolder(collectPath))
|
||||
{
|
||||
bundleName = collectPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
bundleName = PathUtility.RemoveExtension(collectPath);
|
||||
}
|
||||
/// <summary>
|
||||
/// 以收集器路径作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 收集器路径")]
|
||||
public class PackCollector : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName;
|
||||
string collectPath = data.CollectPath;
|
||||
if (AssetDatabase.IsValidFolder(collectPath))
|
||||
{
|
||||
bundleName = collectPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
bundleName = PathUtility.RemoveExtension(collectPath);
|
||||
}
|
||||
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 分组名称")]
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = data.GroupName;
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 以分组名称作为资源包名
|
||||
/// 注意:收集的所有文件打进一个资源包
|
||||
/// </summary>
|
||||
[DisplayName("资源包名: 分组名称")]
|
||||
public class PackGroup : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = data.GroupName;
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包原生文件
|
||||
/// </summary>
|
||||
[DisplayName("打包原生文件")]
|
||||
public class PackRawFile : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = data.AssetPath;
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打包原生文件
|
||||
/// </summary>
|
||||
[DisplayName("打包原生文件")]
|
||||
public class PackRawFile : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = data.AssetPath;
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.RawFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包着色器变种集合
|
||||
/// </summary>
|
||||
[DisplayName("打包着色器变种集合文件")]
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
return DefaultPackRule.CreateShadersPackRuleResult();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打包着色器变种集合
|
||||
/// </summary>
|
||||
[DisplayName("打包着色器变种集合文件")]
|
||||
public class PackShaderVariants : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
return DefaultPackRule.CreateShadersPackRuleResult();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,34 +3,34 @@ using System.Reflection;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器显示名字
|
||||
/// </summary>
|
||||
public class DisplayNameAttribute : Attribute
|
||||
{
|
||||
public string DisplayName;
|
||||
/// <summary>
|
||||
/// 编辑器显示名字
|
||||
/// </summary>
|
||||
public class DisplayNameAttribute : Attribute
|
||||
{
|
||||
public string DisplayName;
|
||||
|
||||
public DisplayNameAttribute(string name)
|
||||
{
|
||||
this.DisplayName = name;
|
||||
}
|
||||
}
|
||||
public DisplayNameAttribute(string name)
|
||||
{
|
||||
this.DisplayName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DisplayNameAttributeHelper
|
||||
{
|
||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||
{
|
||||
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
public static class DisplayNameAttributeHelper
|
||||
{
|
||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||
{
|
||||
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||
{
|
||||
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||
{
|
||||
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||
{
|
||||
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
}
|
||||
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||
{
|
||||
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,28 +2,28 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public enum ECollectorType
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||
/// </summary>
|
||||
MainAssetCollector,
|
||||
[Serializable]
|
||||
public enum ECollectorType
|
||||
{
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,并写入到资源清单的资源列表里(可以通过代码加载)。
|
||||
/// </summary>
|
||||
MainAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// </summary>
|
||||
StaticAssetCollector,
|
||||
/// <summary>
|
||||
/// 收集参与打包的主资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// </summary>
|
||||
StaticAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
||||
/// </summary>
|
||||
DependAssetCollector,
|
||||
/// <summary>
|
||||
/// 收集参与打包的依赖资源对象,但不写入到资源清单的资源列表里(无法通过代码加载)。
|
||||
/// 注意:如果依赖资源对象没有被主资源对象引用,则不参与打包构建。
|
||||
/// </summary>
|
||||
DependAssetCollector,
|
||||
|
||||
/// <summary>
|
||||
/// 该收集器类型不能被设置
|
||||
/// </summary>
|
||||
None,
|
||||
}
|
||||
/// <summary>
|
||||
/// 该收集器类型不能被设置
|
||||
/// </summary>
|
||||
None,
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class RuleDisplayName
|
||||
{
|
||||
public string ClassName;
|
||||
public string DisplayName;
|
||||
}
|
||||
public class RuleDisplayName
|
||||
{
|
||||
public string ClassName;
|
||||
public string DisplayName;
|
||||
}
|
||||
}
|
|
@ -10,319 +10,319 @@ using UnityEngine.Networking.PlayerConnection;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleDebuggerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
|
||||
wnd.minSize = new Vector2(800, 600);
|
||||
}
|
||||
public class AssetBundleDebuggerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
|
||||
wnd.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存视图
|
||||
/// </summary>
|
||||
MemoryView,
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 内存视图
|
||||
/// </summary>
|
||||
MemoryView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
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 ToolbarMenu _viewModeMenu;
|
||||
private SliderInt _frameSlider;
|
||||
private DebuggerAssetListViewer _assetListViewer;
|
||||
private DebuggerBundleListViewer _bundleListViewer;
|
||||
private Label _playerName;
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private SliderInt _frameSlider;
|
||||
private DebuggerAssetListViewer _assetListViewer;
|
||||
private DebuggerBundleListViewer _bundleListViewer;
|
||||
|
||||
private EViewMode _viewMode;
|
||||
private string _searchKeyWord;
|
||||
private DebugReport _currentReport;
|
||||
private RemotePlayerSession _currentPlayerSession;
|
||||
private int _rangeIndex = 0;
|
||||
private EViewMode _viewMode;
|
||||
private string _searchKeyWord;
|
||||
private DebugReport _currentReport;
|
||||
private RemotePlayerSession _currentPlayerSession;
|
||||
private int _rangeIndex = 0;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = rootVisualElement;
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleDebuggerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 采样按钮
|
||||
var sampleBtn = root.Q<Button>("SampleButton");
|
||||
sampleBtn.clicked += SampleBtn_onClick;
|
||||
// 采样按钮
|
||||
var sampleBtn = root.Q<Button>("SampleButton");
|
||||
sampleBtn.clicked += SampleBtn_onClick;
|
||||
|
||||
// 导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
// 导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
|
||||
// 用户列表菜单
|
||||
_playerName = root.Q<Label>("PlayerName");
|
||||
_playerName.text = "Editor player";
|
||||
// 用户列表菜单
|
||||
_playerName = root.Q<Label>("PlayerName");
|
||||
_playerName.text = "Editor player";
|
||||
|
||||
// 视口模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
// 视口模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 帧数相关
|
||||
{
|
||||
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
||||
_frameSlider.label = "Frame:";
|
||||
_frameSlider.highValue = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
OnFrameSliderChange(evt.newValue);
|
||||
});
|
||||
// 帧数相关
|
||||
{
|
||||
_frameSlider = root.Q<SliderInt>("FrameSlider");
|
||||
_frameSlider.label = "Frame:";
|
||||
_frameSlider.highValue = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
OnFrameSliderChange(evt.newValue);
|
||||
});
|
||||
|
||||
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
||||
frameLast.clicked += OnFrameLast_clicked;
|
||||
var frameLast = root.Q<ToolbarButton>("FrameLast");
|
||||
frameLast.clicked += OnFrameLast_clicked;
|
||||
|
||||
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
||||
frameNext.clicked += OnFrameNext_clicked;
|
||||
var frameNext = root.Q<ToolbarButton>("FrameNext");
|
||||
frameNext.clicked += OnFrameNext_clicked;
|
||||
|
||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||
frameClear.clicked += OnFrameClear_clicked;
|
||||
}
|
||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||
frameClear.clicked += OnFrameClear_clicked;
|
||||
}
|
||||
|
||||
// 加载视图
|
||||
_assetListViewer = new DebuggerAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
// 加载视图
|
||||
_assetListViewer = new DebuggerAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_bundleListViewer = new DebuggerBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
// 加载视图
|
||||
_bundleListViewer = new DebuggerBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.AssetView;
|
||||
_assetListViewer.AttachParent(root);
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.AssetView;
|
||||
_assetListViewer.AttachParent(root);
|
||||
|
||||
// 远程调试
|
||||
EditorConnection.instance.Initialize();
|
||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 远程调试
|
||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
_playerSessions.Clear();
|
||||
}
|
||||
// 远程调试
|
||||
EditorConnection.instance.Initialize();
|
||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 远程调试
|
||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
_playerSessions.Clear();
|
||||
}
|
||||
|
||||
private void OnHandleConnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player connection : {playerId}");
|
||||
_playerName.text = $"Connected player : {playerId}";
|
||||
}
|
||||
private void OnHandleDisconnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player disconnection : {playerId}");
|
||||
_playerName.text = $"Disconneced player : {playerId}";
|
||||
}
|
||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||
{
|
||||
var debugReport = DebugReport.Deserialize(args.data);
|
||||
OnHandleDebugReport(args.playerId, debugReport);
|
||||
}
|
||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||
{
|
||||
Debug.Log($"Handle player {playerId} debug report !");
|
||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||
_currentPlayerSession.AddDebugReport(debugReport);
|
||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||
UpdateFrameView(_currentPlayerSession);
|
||||
}
|
||||
private void OnFrameSliderChange(int sliderValue)
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameLast_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameNext_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameClear_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_frameSlider.label = $"Frame:";
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.highValue = 0;
|
||||
_currentPlayerSession.ClearDebugReport();
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
}
|
||||
}
|
||||
private void OnHandleConnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player connection : {playerId}");
|
||||
_playerName.text = $"Connected player : {playerId}";
|
||||
}
|
||||
private void OnHandleDisconnectionEvent(int playerId)
|
||||
{
|
||||
Debug.Log($"Game player disconnection : {playerId}");
|
||||
_playerName.text = $"Disconneced player : {playerId}";
|
||||
}
|
||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||
{
|
||||
var debugReport = DebugReport.Deserialize(args.data);
|
||||
OnHandleDebugReport(args.playerId, debugReport);
|
||||
}
|
||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||
{
|
||||
Debug.Log($"Handle player {playerId} debug report !");
|
||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||
_currentPlayerSession.AddDebugReport(debugReport);
|
||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||
UpdateFrameView(_currentPlayerSession);
|
||||
}
|
||||
private void OnFrameSliderChange(int sliderValue)
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameLast_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameNext_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameClear_clicked()
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_frameSlider.label = $"Frame:";
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.highValue = 0;
|
||||
_currentPlayerSession.ClearDebugReport();
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
}
|
||||
}
|
||||
|
||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||
{
|
||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||
_playerSessions.Add(playerId, newSession);
|
||||
return newSession;
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||
{
|
||||
if (playerSession != null)
|
||||
{
|
||||
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||
{
|
||||
if (playerSession == null)
|
||||
return;
|
||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||
{
|
||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||
_playerSessions.Add(playerId, newSession);
|
||||
return newSession;
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||
{
|
||||
if (playerSession != null)
|
||||
{
|
||||
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||
{
|
||||
if (playerSession == null)
|
||||
return;
|
||||
|
||||
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||
if (debugReport != null)
|
||||
{
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||
if (debugReport != null)
|
||||
{
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
|
||||
private void SampleBtn_onClick()
|
||||
{
|
||||
// 发送采集数据的命令
|
||||
RemoteCommand command = new RemoteCommand();
|
||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||
command.CommandParam = string.Empty;
|
||||
byte[] data = RemoteCommand.Serialize(command);
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
if (_currentReport == null)
|
||||
{
|
||||
Debug.LogWarning("Debug report is null.");
|
||||
return;
|
||||
}
|
||||
private void SampleBtn_onClick()
|
||||
{
|
||||
// 发送采集数据的命令
|
||||
RemoteCommand command = new RemoteCommand();
|
||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||
command.CommandParam = string.Empty;
|
||||
byte[] data = RemoteCommand.Serialize(command);
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
if (_currentReport == null)
|
||||
{
|
||||
Debug.LogWarning("Debug report is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
// 注意:排序保证生成配置的稳定性
|
||||
foreach (var packageData in _currentReport.PackageDatas)
|
||||
{
|
||||
packageData.ProviderInfos.Sort();
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
providerInfo.DependBundleInfos.Sort();
|
||||
}
|
||||
}
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
// 注意:排序保证生成配置的稳定性
|
||||
foreach (var packageData in _currentReport.PackageDatas)
|
||||
{
|
||||
packageData.ProviderInfos.Sort();
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
providerInfo.DependBundleInfos.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||
FileUtility.WriteAllText(filePath, fileContent);
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_currentReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode != viewMode)
|
||||
{
|
||||
_viewMode = viewMode;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = viewMode.ToString();
|
||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||
FileUtility.WriteAllText(filePath, fileContent);
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_currentReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode != viewMode)
|
||||
{
|
||||
_viewMode = viewMode;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = viewMode.ToString();
|
||||
|
||||
if (viewMode == EViewMode.AssetView)
|
||||
{
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
}
|
||||
else if (viewMode == EViewMode.BundleView)
|
||||
{
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(viewMode.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode == viewMode)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
if (viewMode == EViewMode.AssetView)
|
||||
{
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
}
|
||||
else if (viewMode == EViewMode.BundleView)
|
||||
{
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(viewMode.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||
{
|
||||
var viewMode = (EViewMode)action.userData;
|
||||
if (_viewMode == viewMode)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -4,90 +4,90 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class RemotePlayerSession
|
||||
{
|
||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||
internal class RemotePlayerSession
|
||||
{
|
||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public int PlayerId { private set; get; }
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public int PlayerId { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 保存的报告最大数量
|
||||
/// </summary>
|
||||
public int MaxReportCount { private set; get; }
|
||||
/// <summary>
|
||||
/// 保存的报告最大数量
|
||||
/// </summary>
|
||||
public int MaxReportCount { private set; get; }
|
||||
|
||||
public int MinRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int MaxRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = _reportList.Count - 1;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
public int MinRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public int MaxRangeValue
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = _reportList.Count - 1;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||
{
|
||||
PlayerId = playerId;
|
||||
MaxReportCount = maxReportCount;
|
||||
}
|
||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||
{
|
||||
PlayerId = playerId;
|
||||
MaxReportCount = maxReportCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存数据
|
||||
/// </summary>
|
||||
public void ClearDebugReport()
|
||||
{
|
||||
_reportList.Clear();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清理缓存数据
|
||||
/// </summary>
|
||||
public void ClearDebugReport()
|
||||
{
|
||||
_reportList.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个调试报告
|
||||
/// </summary>
|
||||
public void AddDebugReport(DebugReport report)
|
||||
{
|
||||
if (report == null)
|
||||
Debug.LogWarning("Invalid debug report data !");
|
||||
/// <summary>
|
||||
/// 添加一个调试报告
|
||||
/// </summary>
|
||||
public void AddDebugReport(DebugReport report)
|
||||
{
|
||||
if (report == null)
|
||||
Debug.LogWarning("Invalid debug report data !");
|
||||
|
||||
if (_reportList.Count >= MaxReportCount)
|
||||
_reportList.RemoveAt(0);
|
||||
_reportList.Add(report);
|
||||
}
|
||||
if (_reportList.Count >= MaxReportCount)
|
||||
_reportList.RemoveAt(0);
|
||||
_reportList.Add(report);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取调试报告
|
||||
/// </summary>
|
||||
public DebugReport GetDebugReport(int rangeIndex)
|
||||
{
|
||||
if (_reportList.Count == 0)
|
||||
return null;
|
||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||
return null;
|
||||
return _reportList[rangeIndex];
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取调试报告
|
||||
/// </summary>
|
||||
public DebugReport GetDebugReport(int rangeIndex)
|
||||
{
|
||||
if (_reportList.Count == 0)
|
||||
return null;
|
||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||
return null;
|
||||
return _reportList[rangeIndex];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 规范索引值
|
||||
/// </summary>
|
||||
public int ClampRangeIndex(int rangeIndex)
|
||||
{
|
||||
if (rangeIndex < 0)
|
||||
return 0;
|
||||
/// <summary>
|
||||
/// 规范索引值
|
||||
/// </summary>
|
||||
public int ClampRangeIndex(int rangeIndex)
|
||||
{
|
||||
if (rangeIndex < 0)
|
||||
return 0;
|
||||
|
||||
if (rangeIndex > MaxRangeValue)
|
||||
return MaxRangeValue;
|
||||
if (rangeIndex > MaxRangeValue)
|
||||
return MaxRangeValue;
|
||||
|
||||
return rangeIndex;
|
||||
}
|
||||
}
|
||||
return rangeIndex;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,300 +9,300 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerAssetListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
internal class DebuggerAssetListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private DebugReport _debugReport;
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private DebugReport _debugReport;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
SplitView.Adjuster(_root);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource.Clear();
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource.Clear();
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
providerInfo.PackageName = packageData.PackageName;
|
||||
tempList.Add(providerInfo);
|
||||
}
|
||||
providerInfo.PackageName = packageData.PackageName;
|
||||
tempList.Add(providerInfo);
|
||||
}
|
||||
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label6";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label6";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||
var providerInfo = sourceData[index];
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||
var providerInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = providerInfo.PackageName;
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = providerInfo.PackageName;
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Loading Time
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.LoadingTime.ToString();
|
||||
// Loading Time
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.LoadingTime.ToString();
|
||||
|
||||
// Ref Count
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.RefCount.ToString();
|
||||
// Ref Count
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label6 = element.Q<Label>("Label6");
|
||||
label6.text = providerInfo.Status.ToString();
|
||||
label6.style.color = textColor;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||
FillDependListView(providerInfo);
|
||||
}
|
||||
}
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label6 = element.Q<Label>("Label6");
|
||||
label6.text = providerInfo.Status.ToString();
|
||||
label6.style.color = textColor;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||
FillDependListView(providerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 底部列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||
DebugBundleInfo bundleInfo = bundles[index];
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||
DebugBundleInfo bundleInfo = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
}
|
||||
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||
{
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
}
|
||||
}
|
||||
// Status
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
}
|
||||
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||
{
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -9,312 +9,312 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerBundleListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
internal class DebuggerBundleListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _bundleListView;
|
||||
private ListView _usingListView;
|
||||
private DebugReport _debugReport;
|
||||
private ListView _bundleListView;
|
||||
private ListView _usingListView;
|
||||
private DebugReport _debugReport;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
_usingListView.bindItem = BindIncludeListViewItem;
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
_usingListView.bindItem = BindIncludeListViewItem;
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
SplitView.Adjuster(_root);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource.Clear();
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource.Clear();
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||
foreach (var pakcageData in debugReport.PackageDatas)
|
||||
{
|
||||
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||
foreach (var pakcageData in debugReport.PackageDatas)
|
||||
{
|
||||
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||
{
|
||||
bundleInfo.PackageName = pakcageData.PackageName;
|
||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||
{
|
||||
bundleInfo.PackageName = pakcageData.PackageName;
|
||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tempList = tempDic.Values.ToList();
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
var tempList = tempDic.Values.ToList();
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = bundleInfo.PackageName;
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = bundleInfo.PackageName;
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
label4.style.color = textColor;
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||
FillUsingListView(bundleInfo);
|
||||
}
|
||||
}
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
label4.style.color = textColor;
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||
FillUsingListView(bundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 底部列表相关
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||
DebugProviderInfo providerInfo = providers[index];
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||
DebugProviderInfo providerInfo = providers[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var packageData in _debugReport.PackageDatas)
|
||||
{
|
||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||
{
|
||||
source.Add(providerInfo);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Status
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var packageData in _debugReport.PackageDatas)
|
||||
{
|
||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||
{
|
||||
source.Add(providerInfo);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
}
|
||||
}
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -4,43 +4,43 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleInspector
|
||||
{
|
||||
[CustomEditor(typeof(AssetBundle))]
|
||||
internal class AssetBundleEditor : UnityEditor.Editor
|
||||
{
|
||||
internal bool pathFoldout = false;
|
||||
internal bool advancedFoldout = false;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetBundle bundle = target as AssetBundle;
|
||||
public class AssetBundleInspector
|
||||
{
|
||||
[CustomEditor(typeof(AssetBundle))]
|
||||
internal class AssetBundleEditor : UnityEditor.Editor
|
||||
{
|
||||
internal bool pathFoldout = false;
|
||||
internal bool advancedFoldout = false;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
AssetBundle bundle = target as AssetBundle;
|
||||
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
||||
leftStyle.alignment = TextAnchor.UpperLeft;
|
||||
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
|
||||
leftStyle.alignment = TextAnchor.UpperLeft;
|
||||
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
|
||||
|
||||
var assetNames = bundle.GetAllAssetNames();
|
||||
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
||||
if (pathFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (var asset in assetNames)
|
||||
EditorGUILayout.LabelField(asset);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
var assetNames = bundle.GetAllAssetNames();
|
||||
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
|
||||
if (pathFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
foreach (var asset in assetNames)
|
||||
EditorGUILayout.LabelField(asset);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
||||
}
|
||||
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
|
||||
}
|
||||
|
||||
if (advancedFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
base.OnInspectorGUI();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (advancedFoldout)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
base.OnInspectorGUI();
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,61 +5,61 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleRecorder
|
||||
{
|
||||
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
||||
public static class AssetBundleRecorder
|
||||
{
|
||||
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
|
||||
|
||||
/// <summary>
|
||||
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
||||
/// </summary>
|
||||
public static AssetBundle GetAssetBundle(string filePath)
|
||||
{
|
||||
// 如果文件不存在
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
||||
return null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
|
||||
/// </summary>
|
||||
public static AssetBundle GetAssetBundle(string filePath)
|
||||
{
|
||||
// 如果文件不存在
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
Debug.LogWarning($"Not found asset bundle file : {filePath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 验证文件有效性(可能文件被加密)
|
||||
byte[] fileData = File.ReadAllBytes(filePath);
|
||||
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
||||
{
|
||||
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
||||
return null;
|
||||
}
|
||||
// 验证文件有效性(可能文件被加密)
|
||||
byte[] fileData = File.ReadAllBytes(filePath);
|
||||
if (EditorTools.CheckBundleFileValid(fileData) == false)
|
||||
{
|
||||
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
||||
{
|
||||
return bundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||
if(newBundle != null)
|
||||
{
|
||||
string[] assetNames = newBundle.GetAllAssetNames();
|
||||
foreach (string name in assetNames)
|
||||
{
|
||||
newBundle.LoadAsset(name);
|
||||
}
|
||||
_loadedAssetBundles.Add(filePath, newBundle);
|
||||
}
|
||||
return newBundle;
|
||||
}
|
||||
}
|
||||
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
|
||||
{
|
||||
return bundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
|
||||
if (newBundle != null)
|
||||
{
|
||||
string[] assetNames = newBundle.GetAllAssetNames();
|
||||
foreach (string name in assetNames)
|
||||
{
|
||||
newBundle.LoadAsset(name);
|
||||
}
|
||||
_loadedAssetBundles.Add(filePath, newBundle);
|
||||
}
|
||||
return newBundle;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载所有已经加载的AssetBundle文件
|
||||
/// </summary>
|
||||
public static void UnloadAll()
|
||||
{
|
||||
foreach(var valuePair in _loadedAssetBundles)
|
||||
{
|
||||
if (valuePair.Value != null)
|
||||
valuePair.Value.Unload(true);
|
||||
}
|
||||
_loadedAssetBundles.Clear();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 卸载所有已经加载的AssetBundle文件
|
||||
/// </summary>
|
||||
public static void UnloadAll()
|
||||
{
|
||||
foreach (var valuePair in _loadedAssetBundles)
|
||||
{
|
||||
if (valuePair.Value != null)
|
||||
valuePair.Value.Unload(true);
|
||||
}
|
||||
_loadedAssetBundles.Clear();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,215 +7,215 @@ using UnityEngine.UIElements;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleReporterWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
public class AssetBundleReporterWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 概览视图
|
||||
/// </summary>
|
||||
Summary,
|
||||
/// <summary>
|
||||
/// 视图模式
|
||||
/// </summary>
|
||||
private enum EViewMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 概览视图
|
||||
/// </summary>
|
||||
Summary,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
/// <summary>
|
||||
/// 资源对象视图
|
||||
/// </summary>
|
||||
AssetView,
|
||||
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
/// <summary>
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
|
||||
/// <summary>
|
||||
/// 冗余资源试图
|
||||
/// </summary>
|
||||
Redundancy,
|
||||
}
|
||||
/// <summary>
|
||||
/// 冗余资源试图
|
||||
/// </summary>
|
||||
Redundancy,
|
||||
}
|
||||
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private ReporterSummaryViewer _summaryViewer;
|
||||
private ReporterAssetListViewer _assetListViewer;
|
||||
private ReporterBundleListViewer _bundleListViewer;
|
||||
private ReporterRedundancyListViewer _redundancyListViewer;
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private ReporterSummaryViewer _summaryViewer;
|
||||
private ReporterAssetListViewer _assetListViewer;
|
||||
private ReporterBundleListViewer _bundleListViewer;
|
||||
private ReporterRedundancyListViewer _redundancyListViewer;
|
||||
|
||||
private EViewMode _viewMode;
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
private EViewMode _viewMode;
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
// 导入按钮
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_onClick;
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 视图模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_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);
|
||||
// 导入按钮
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_onClick;
|
||||
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
// 视图模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_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();
|
||||
_summaryViewer.InitViewer();
|
||||
// 搜索栏
|
||||
var searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 加载视图
|
||||
_assetListViewer = new ReporterAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
// 加载视图
|
||||
_summaryViewer = new ReporterSummaryViewer();
|
||||
_summaryViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_bundleListViewer = new ReporterBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
// 加载视图
|
||||
_assetListViewer = new ReporterAssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
|
||||
// 加载试图
|
||||
_redundancyListViewer = new ReporterRedundancyListViewer();
|
||||
_redundancyListViewer.InitViewer();
|
||||
// 加载视图
|
||||
_bundleListViewer = new ReporterBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.Summary;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
AssetBundleRecorder.UnloadAll();
|
||||
}
|
||||
// 加载试图
|
||||
_redundancyListViewer = new ReporterRedundancyListViewer();
|
||||
_redundancyListViewer.InitViewer();
|
||||
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.Summary;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
AssetBundleRecorder.UnloadAll();
|
||||
}
|
||||
|
||||
_reportFilePath = selectFilePath;
|
||||
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
||||
_buildReport = BuildReport.Deserialize(jsonData);
|
||||
_summaryViewer.FillViewData(_buildReport);
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_buildReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.Summary)
|
||||
{
|
||||
_viewMode = EViewMode.Summary;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.AssetView)
|
||||
{
|
||||
_viewMode = EViewMode.AssetView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.BundleView)
|
||||
{
|
||||
_viewMode = EViewMode.BundleView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction3(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.Redundancy)
|
||||
{
|
||||
_viewMode = EViewMode.Redundancy;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.Redundancy.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.AttachParent(root);
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.Summary)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.AssetView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.BundleView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.Redundancy)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
_reportFilePath = selectFilePath;
|
||||
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
||||
_buildReport = BuildReport.Deserialize(jsonData);
|
||||
_summaryViewer.FillViewData(_buildReport);
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_buildReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.Summary)
|
||||
{
|
||||
_viewMode = EViewMode.Summary;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.Summary.ToString();
|
||||
_summaryViewer.AttachParent(root);
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.AssetView)
|
||||
{
|
||||
_viewMode = EViewMode.AssetView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.BundleView)
|
||||
{
|
||||
_viewMode = EViewMode.BundleView;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.BundleView.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
_redundancyListViewer.DetachParent();
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction3(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode != EViewMode.Redundancy)
|
||||
{
|
||||
_viewMode = EViewMode.Redundancy;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_viewModeMenu.text = EViewMode.Redundancy.ToString();
|
||||
_summaryViewer.DetachParent();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
_redundancyListViewer.AttachParent(root);
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.Summary)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.AssetView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.BundleView)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
|
||||
{
|
||||
if (_viewMode == EViewMode.Redundancy)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -6,72 +6,72 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建报告
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuildReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 汇总信息
|
||||
/// </summary>
|
||||
public ReportSummary Summary = new ReportSummary();
|
||||
/// <summary>
|
||||
/// 构建报告
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuildReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 汇总信息
|
||||
/// </summary>
|
||||
public ReportSummary Summary = new ReportSummary();
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象列表
|
||||
/// </summary>
|
||||
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
|
||||
/// <summary>
|
||||
/// 资源对象列表
|
||||
/// </summary>
|
||||
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 冗余的资源列表
|
||||
/// </summary>
|
||||
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}");
|
||||
}
|
||||
/// <summary>
|
||||
/// 冗余的资源列表
|
||||
/// </summary>
|
||||
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>();
|
||||
|
||||
|
||||
public static void Serialize(string savePath, BuildReport buildReport)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
/// <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}");
|
||||
}
|
||||
|
||||
string json = JsonUtility.ToJson(buildReport, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
public static BuildReport Deserialize(string jsonData)
|
||||
{
|
||||
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
|
||||
return report;
|
||||
}
|
||||
}
|
||||
/// <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)
|
||||
{
|
||||
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
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address;
|
||||
[Serializable]
|
||||
public class ReportAssetInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address;
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// 说明:Meta文件记录的GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// 说明:Meta文件记录的GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public string[] AssetTags;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包名称
|
||||
/// </summary>
|
||||
public string MainBundleName;
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public string[] AssetTags;
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源包的大小
|
||||
/// </summary>
|
||||
public long MainBundleSize;
|
||||
/// <summary>
|
||||
/// 所属资源包名称
|
||||
/// </summary>
|
||||
public string MainBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源路径列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属资源包的大小
|
||||
/// </summary>
|
||||
public long MainBundleSize;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源路径列表
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
}
|
||||
}
|
|
@ -5,63 +5,63 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
[Serializable]
|
||||
public class ReportBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string FileHash;
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string FileHash;
|
||||
|
||||
/// <summary>
|
||||
/// 文件校验码
|
||||
/// </summary>
|
||||
public string FileCRC;
|
||||
/// <summary>
|
||||
/// 文件校验码
|
||||
/// </summary>
|
||||
public string FileCRC;
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小(字节数)
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
/// <summary>
|
||||
/// 文件大小(字节数)
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public bool Encrypted;
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public bool Encrypted;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包标签集合
|
||||
/// </summary>
|
||||
public string[] Tags;
|
||||
/// <summary>
|
||||
/// 资源包标签集合
|
||||
/// </summary>
|
||||
public string[] Tags;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包的依赖集合
|
||||
/// </summary>
|
||||
public List<string> DependBundles;
|
||||
/// <summary>
|
||||
/// 资源包的依赖集合
|
||||
/// </summary>
|
||||
public List<string> DependBundles;
|
||||
|
||||
/// <summary>
|
||||
/// 该资源包内包含的所有资源
|
||||
/// </summary>
|
||||
public List<string> AllBuiltinAssets = new List<string>();
|
||||
/// <summary>
|
||||
/// 该资源包内包含的所有资源
|
||||
/// </summary>
|
||||
public List<string> AllBuiltinAssets = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源分类标签的字符串
|
||||
/// </summary>
|
||||
public string GetTagsString()
|
||||
{
|
||||
if (Tags != null)
|
||||
return String.Join(";", Tags);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取资源分类标签的字符串
|
||||
/// </summary>
|
||||
public string GetTagsString()
|
||||
{
|
||||
if (Tags != null)
|
||||
return String.Join(";", Tags);
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,33 +4,33 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportRedundancyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
[Serializable]
|
||||
public class ReportRedundancyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public string AssetType;
|
||||
/// <summary>
|
||||
/// 资源类型
|
||||
/// </summary>
|
||||
public string AssetType;
|
||||
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// 说明:Meta文件记录的GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
/// <summary>
|
||||
/// 资源GUID
|
||||
/// 说明:Meta文件记录的GUID
|
||||
/// </summary>
|
||||
public string AssetGUID;
|
||||
|
||||
/// <summary>
|
||||
/// 资源文件大小
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
/// <summary>
|
||||
/// 资源文件大小
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
|
||||
/// <summary>
|
||||
/// 冗余的资源包数量
|
||||
/// </summary>
|
||||
public int Number;
|
||||
}
|
||||
/// <summary>
|
||||
/// 冗余的资源包数量
|
||||
/// </summary>
|
||||
public int Number;
|
||||
}
|
||||
}
|
|
@ -5,75 +5,75 @@ using UnityEditor;
|
|||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// YooAsset版本
|
||||
/// </summary>
|
||||
public string YooVersion;
|
||||
[Serializable]
|
||||
public class ReportSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// YooAsset版本
|
||||
/// </summary>
|
||||
public string YooVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 引擎版本
|
||||
/// </summary>
|
||||
public string UnityVersion;
|
||||
/// <summary>
|
||||
/// 引擎版本
|
||||
/// </summary>
|
||||
public string UnityVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建时间
|
||||
/// </summary>
|
||||
public string BuildDate;
|
||||
/// <summary>
|
||||
/// 构建时间
|
||||
/// </summary>
|
||||
public string BuildDate;
|
||||
|
||||
/// <summary>
|
||||
/// 构建耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int BuildSeconds;
|
||||
/// <summary>
|
||||
/// 构建耗时(单位:秒)
|
||||
/// </summary>
|
||||
public int BuildSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// 构建平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
/// <summary>
|
||||
/// 构建平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹名称
|
||||
/// </summary>
|
||||
public string BuildPackageName;
|
||||
/// <summary>
|
||||
/// 构建包裹名称
|
||||
/// </summary>
|
||||
public string BuildPackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹版本
|
||||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
/// <summary>
|
||||
/// 构建包裹版本
|
||||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
|
||||
// 收集器配置
|
||||
public bool UniqueBundleName;
|
||||
public bool EnableAddressable;
|
||||
public bool LocationToLower;
|
||||
public bool IncludeAssetGUID;
|
||||
public bool IgnoreDefaultType;
|
||||
public bool AutoCollectShaders;
|
||||
// 收集器配置
|
||||
public bool UniqueBundleName;
|
||||
public bool EnableAddressable;
|
||||
public bool LocationToLower;
|
||||
public bool IncludeAssetGUID;
|
||||
public bool IgnoreDefaultType;
|
||||
public bool AutoCollectShaders;
|
||||
|
||||
// 构建参数
|
||||
public string EncryptionClassName;
|
||||
public EFileNameStyle FileNameStyle;
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
// 构建参数
|
||||
public string EncryptionClassName;
|
||||
public EFileNameStyle FileNameStyle;
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
|
||||
// 构建结果
|
||||
public int AssetFileTotalCount;
|
||||
public int MainAssetTotalCount;
|
||||
public int AllBundleTotalCount;
|
||||
public long AllBundleTotalSize;
|
||||
public int EncryptedBundleTotalCount;
|
||||
public long EncryptedBundleTotalSize;
|
||||
}
|
||||
// 构建结果
|
||||
public int AssetFileTotalCount;
|
||||
public int MainAssetTotalCount;
|
||||
public int AllBundleTotalCount;
|
||||
public long AllBundleTotalSize;
|
||||
public int EncryptedBundleTotalCount;
|
||||
public long EncryptedBundleTotalSize;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue