mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
yoo2.2,9
yoo2.2,9
This commit is contained in:
@@ -2,6 +2,496 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.2.9] - 2025-01-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#438) 修复了纯血鸿蒙加载本地文件失败的问题。
|
||||
- (#445) 修复了小游戏扩展文件系统脚本编译错误。
|
||||
|
||||
### Changed
|
||||
|
||||
- EditorSimulateModeHelper.SimulateBuild()方法变更
|
||||
|
||||
```csharp
|
||||
public static PackageInvokeBuildResult SimulateBuild(string packageName);
|
||||
```
|
||||
|
||||
## [2.2.8-preview] - 2025-01-03
|
||||
|
||||
新增了单元测试用例。
|
||||
|
||||
### Improvements
|
||||
|
||||
- EditorSimulateModeHelper.SimulateBuild()方法提供指定自定义构建类
|
||||
|
||||
```csharp
|
||||
public class EditorSimulateBuildParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟构建类所属程序集名称
|
||||
/// </summary>
|
||||
public string InvokeAssmeblyName = "YooAsset.Editor";
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建执行的类名全称
|
||||
/// 注意:类名必须包含命名空间!
|
||||
/// </summary>
|
||||
public string InvokeClassFullName = "YooAsset.Editor.AssetBundleSimulateBuilder";
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建执行的方法名称
|
||||
/// 注意:执行方法必须满足 BindingFlags.Public | BindingFlags.Static
|
||||
/// </summary>
|
||||
public string InvokeMethodName = "SimulateBuild";
|
||||
}
|
||||
```
|
||||
|
||||
- 文件清理方式新增清理缓存清单。
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 文件清理方式
|
||||
/// </summary>
|
||||
public enum EFileClearMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理所有清单
|
||||
/// </summary>
|
||||
ClearAllManifestFiles,
|
||||
|
||||
/// <summary>
|
||||
/// 清理未在使用的清单
|
||||
/// </summary>
|
||||
ClearUnusedManifestFiles,
|
||||
}
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#426) 修复了鸿蒙next平台加载内置文件路径报错的问题。
|
||||
- (#428) 修复了鸿蒙next平台加载内置文件路径报错的问题。
|
||||
- (#434) 修复了2.2版本 catalog文件对Json格式原生文件不记录的问题。
|
||||
- (#435) 修复了WebGL平台调用MD5算法触发异常的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了视频打包规则。
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 打包视频文件
|
||||
/// </summary>
|
||||
[DisplayName("打包视频文件")]
|
||||
public class PackVideoFile : IPackRule
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 重命名FileSystemParameters.RootDirectory字段为PackageRoot
|
||||
- 重命名ResourcePackage.ClearCacheBundleFilesAsync()方法为ClearCacheFilesAsync()
|
||||
|
||||
## [2.2.7-preview] - 2024-12-30
|
||||
|
||||
### Improvements
|
||||
|
||||
- 重构了下载器的委托方法。
|
||||
|
||||
- YooAssetSettings配置文件新增Package Manifest Prefix参数。
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 资源清单前缀名称(默认为空)
|
||||
/// </summary>
|
||||
public string PackageManifestPrefix = string.Empty;
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#422) 修复了同步加载场景的NotImplementedException异常报错。
|
||||
- (#418) 修复了web远程文件系统初始化不正确的问题
|
||||
- (#392) 修复了引擎版本代码兼容相关的警告。
|
||||
- (#332) 修复了当用户的设备中有特殊字符时,URL路径无法被正确识别的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增代码字段:AsyncOperationBase.PackageName
|
||||
|
||||
### Changed
|
||||
|
||||
- 重命名DownloaderOperation.OnDownloadOver()方法为DownloaderFinish()
|
||||
- 重命名DownloaderOperation.OnDownloadProgress()方法为DownloadUpdate()
|
||||
- 重命名DownloaderOperation.OnDownloadError()方法为DownloadError()
|
||||
- 重命名DownloaderOperation.OnStartDownloadFile()方法为DownloadFileBegin()
|
||||
|
||||
## [2.2.6-preview] - 2024-12-27
|
||||
|
||||
### Improvements
|
||||
|
||||
- 增强了对Steam平台DLC拓展包的支持。
|
||||
|
||||
```csharp
|
||||
// 新增参数关闭Catalog目录查询内置文件的功能
|
||||
var fileSystemParams = CreateDefaultBuildinFileSystemParameters();
|
||||
fileSystemParams .AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||
```
|
||||
|
||||
- 资源句柄基类提供了统一的Release方法。
|
||||
|
||||
```csharp
|
||||
public abstract class HandleBase : IEnumerator, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release();
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose();
|
||||
}
|
||||
```
|
||||
|
||||
- 优化了场景卸载逻辑。
|
||||
|
||||
```csharp
|
||||
//框架内不在区分主场景和附加场景。
|
||||
//场景卸载后自动释放资源句柄。
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了Unity2020版本提示的脚本编译错误。
|
||||
- (#417) 修复了DefaultWebServerFileSystem文件系统内Catalog未起效的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增示例文件 GetCacheBundleSizeOperation.cs
|
||||
|
||||
可以获取指定Package的缓存资源总大小。
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了SceneHandle.IsMainScene()方法。
|
||||
|
||||
## [2.2.5-preview] - 2024-12-25
|
||||
|
||||
依赖的ScriptableBuildPipeline (SBP) 插件库版本切换为1.21.25版本!
|
||||
|
||||
重构了ResourceManager相关的核心代码,方便借助文件系统扩展和支持更复杂的需求!
|
||||
|
||||
### Editor
|
||||
|
||||
- 新增了编辑器模拟构建管线 EditorSimulateBuildPipeline
|
||||
- 移除了EBuildMode枚举类型,构建界面有变动。
|
||||
- IActiveRule分组激活接口新增GroupData类。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 增加抖音小游戏文件系统,见扩展示例代码。
|
||||
|
||||
- 微信小游戏文件系统支持删除无用缓存文件和全部缓存文件。
|
||||
|
||||
- 资源构建管线现在默认剔除了Gizmos和编辑器资源。
|
||||
|
||||
- 优化了资源构建管线里资源收集速度。
|
||||
|
||||
资源收集速度提升100倍!
|
||||
|
||||
```csharp
|
||||
class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用资源依赖缓存数据库
|
||||
/// 说明:开启此项可以极大提高资源收集速度
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB = false;
|
||||
}
|
||||
```
|
||||
|
||||
- WebPlayMode支持跨域加载。
|
||||
|
||||
```csharp
|
||||
// 创建默认的WebServer文件系统参数
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||
|
||||
// 创建默认的WebRemote文件系统参数(支持跨域加载)
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||
```
|
||||
|
||||
- 编辑器模拟文件系统新增初始化参数:支持异步模拟加载帧数。
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 异步模拟加载最小帧数
|
||||
/// </summary>
|
||||
FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME
|
||||
|
||||
/// <summary>
|
||||
/// 异步模拟加载最大帧数
|
||||
/// </summary>
|
||||
FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME
|
||||
```
|
||||
|
||||
- 缓存文件系统新增初始化参数:支持设置下载器最大并发连接数和单帧最大请求数
|
||||
|
||||
```csharp
|
||||
var fileSystremParams = FileSystemParameters.CreateDefaultCacheFileSystemParameters();
|
||||
fileSystremParams .AddParameter(FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY, 99);
|
||||
fileSystremParams .AddParameter(FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME, 10);
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#349) 修复了在加载清单的时候,即使本地存在缓存文件还会去远端下载。
|
||||
- (#361) 修复了协程里等待的asset handle被release,会无限等待并输出警告信息。
|
||||
- (#359) 修复了SubAssetsHandle.GetSubAssetObject会获取到同名的主资源。
|
||||
- (#387) 修复了加密后文件哈希冲突的时候没有抛出异常错误。
|
||||
- (#404) 修复了Unity2022.3.8版本提示编译错误:Cannot resolve symbol 'AsyncInstantiateOperation'
|
||||
|
||||
### Added
|
||||
|
||||
- 新增示例文件 CopyBuildinManifestOperation.cs
|
||||
|
||||
- 新增示例文件 LoadGameObjectOperation.cs
|
||||
|
||||
- 新增了获取配置清单详情的方法
|
||||
|
||||
```csharp
|
||||
class ResourcePackage
|
||||
{
|
||||
public PackageDetails GetPackageDetails()
|
||||
}
|
||||
```
|
||||
|
||||
- 新增了获取所有资源信息的方法
|
||||
|
||||
```csharp
|
||||
class ResourcePackage
|
||||
{
|
||||
public AssetInfo[] GetAllAssetInfos()
|
||||
}
|
||||
```
|
||||
|
||||
- 新增了清理缓存文件的通用方法
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 文件清理方式
|
||||
/// </summary>
|
||||
public enum EFileClearMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理所有文件
|
||||
/// </summary>
|
||||
ClearAllBundleFiles = 1,
|
||||
/// <summary>
|
||||
/// 清理未在使用的文件
|
||||
/// </summary>
|
||||
ClearUnusedBundleFiles = 2,
|
||||
/// <summary>
|
||||
/// 清理指定标签的文件
|
||||
/// 说明:需要指定参数,可选:string, string[], List<string>
|
||||
/// </summary>
|
||||
ClearBundleFilesByTags = 3,
|
||||
}
|
||||
class ResourcePackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
/// <param name="clearMode">清理方式</param>
|
||||
/// <param name="clearParam">执行参数</param>
|
||||
public ClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 修改了EditorSimulateModeHelper.SimulateBuild()方法
|
||||
|
||||
- 重命名ResourcePackage.GetAssetsInfoByTags()方法为GetAssetInfosByTags()
|
||||
|
||||
- 实例化对象方法增加激活参数。
|
||||
|
||||
```csharp
|
||||
public InstantiateOperation InstantiateAsync(bool actived = true)
|
||||
```
|
||||
|
||||
- 清单文件的版本提升到2.2.5版本
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 资源包裹的备注信息
|
||||
/// </summary>
|
||||
public string PackageNote;
|
||||
```
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了HostPlayModeParameters.DeliveryFileSystemParameters字段
|
||||
- 移除了ResourcePackage.ClearAllBundleFilesAsync()方法
|
||||
- 移除了ResourcePackage.ClearUnusedBundleFilesAsync()方法
|
||||
- 移除了FileSystemParameters.CreateDefaultBuildinRawFileSystemParameters()方法
|
||||
- 移除了FileSystemParameters.CreateDefaultCacheRawFileSystemParameters()方法
|
||||
- 移除了枚举类型:EDefaultBuildPipeline
|
||||
- 移除了配置参数:YooAssetSettings.ManifestFileName
|
||||
|
||||
## [2.2.4-preview] - 2024-08-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了HostPlayMode初始化卡死的问题。
|
||||
|
||||
## [2.2.3-preview] - 2024-08-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#311) 修复了断点续传下载器极小概率报错 : “416 Range Not Satisfiable”
|
||||
|
||||
### Improvements
|
||||
|
||||
- 原生文件构建管线支持原生文件加密。
|
||||
|
||||
- HostPlayMode模式下内置文件系统初始化参数可以为空。
|
||||
|
||||
- 场景加载增加了LocalPhysicsMode参数来控制物理运行模式。
|
||||
|
||||
- 默认的内置文件系统和缓存文件系统增加解密方法。
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 创建默认的内置文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的缓存文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||
```
|
||||
|
||||
## [2.2.2-preview] - 2024-07-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#321) 修复了在Unity2022里编辑器下离线模式运行失败的问题。
|
||||
- (#325) 修复了在Unity2019里编译报错问题。
|
||||
|
||||
## [2.2.1-preview] - 2024-07-10
|
||||
|
||||
统一了所有PlayMode的初始化逻辑,EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单!
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了IFileSystem.ReadFileData方法,支持原生文件自定义获取文本和二进制数据。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化了DefaultWebFileSystem和DefaultBuildFileSystem文件系统的内部初始化逻辑。
|
||||
|
||||
## [2.2.0-preview] - 2024-07-07
|
||||
|
||||
重构了运行时代码,新增了文件系统接口(IFileSystem)方便开发者扩展特殊需求。
|
||||
|
||||
新增微信小游戏文件系统示例代码,详细见Extension Sample/Runtime/WechatFileSystem
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了ResourcePackage.DestroyAsync方法
|
||||
|
||||
- 新增了FileSystemParameters类帮助初始化文件系统
|
||||
|
||||
内置了编辑器文件系统参数,内置文件系统参数,缓存文件系统参数,Web文件系统参数。
|
||||
|
||||
```csharp
|
||||
public class FileSystemParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件系统类
|
||||
/// </summary>
|
||||
public string FileSystemClass { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统的根目录
|
||||
/// </summary>
|
||||
public string RootDirectory { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 添加自定义参数
|
||||
/// </summary>
|
||||
public void AddParameter(string name, object value)
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 重构了InitializeParameters初始化参数
|
||||
- 重命名YooAssets.DestroyPackage方法为RemovePackage
|
||||
- 重命名ResourcePackage.UpdatePackageVersionAsync方法为RequestPackageVersionAsync
|
||||
- 重命名ResourcePackage.UnloadUnusedAssets方法为UnloadUnusedAssetsAsync
|
||||
- 重命名ResourcePackage.ForceUnloadAllAssets方法为UnloadAllAssetsAsync
|
||||
- 重命名ResourcePackage.ClearUnusedCacheFilesAsync方法为ClearUnusedBundleFilesAsync
|
||||
- 重命名ResourcePackage.ClearAllCacheFilesAsync方法为ClearAllBundleFilesAsync
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了YooAssets.Destroy方法
|
||||
- 移除了YooAssets.SetDownloadSystemClearFileResponseCode方法
|
||||
- 移除了YooAssets.SetCacheSystemDisableCacheOnWebGL方法
|
||||
- 移除了ResourcePackage.GetPackageBuildinRootDirectory方法
|
||||
- 移除了ResourcePackage.GetPackageSandboxRootDirectory方法
|
||||
- 移除了ResourcePackage.ClearPackageSandbox方法
|
||||
- 移除了IBuildinQueryServices接口
|
||||
- 移除了IDeliveryLoadServices接口
|
||||
- 移除了IDeliveryQueryServices接口
|
||||
|
||||
|
||||
## [2.1.2] - 2024-05-16
|
||||
|
||||
SBP库依赖版本升级至2.1.3
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#236) 修复了资源配置界面AutoCollectShader复选框没有刷新的问题。
|
||||
- (#244) 修复了导入器在安卓平台导入本地下载的资源失败的问题。
|
||||
- (#268) 修复了挂起场景未解除状态前无法卸载的问题。
|
||||
- (#269) 优化场景挂起流程,支持中途取消挂起操作。
|
||||
- (#276) 修复了HostPlayMode模式下,如果内置清单是最新版本,每次运行都会触发拷贝行为。
|
||||
- (#289) 修复了Unity2019版本脚本IWebRequester编译报错。
|
||||
- (#295) 解决了在安卓移动平台,华为和三星真机上有极小概率加载资源包失败 : Unable to open archive file
|
||||
|
||||
### Added
|
||||
|
||||
- 新增GetAllCacheFileInfosOperation()获取缓存文件信息的方法。
|
||||
|
||||
- 新增LoadSceneSync()同步加载场景的方法。
|
||||
|
||||
- 新增IIgnoreRule接口,资源收集流程可以自定义。
|
||||
|
||||
- 新增IWechatQueryServices接口,用于微信平台本地文件查询。
|
||||
|
||||
后续将会通过虚拟文件系统来支持!
|
||||
|
||||
### Changed
|
||||
|
||||
- 调整了UnloadSceneOperation代码里场景的卸载顺序。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化了资源清单的解析过程。
|
||||
- 移除资源包名里的空格字符。
|
||||
- 支持华为鸿蒙系统。
|
||||
|
||||
## [2.1.1] - 2024-01-17
|
||||
|
||||
### Fixed
|
||||
|
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
||||
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,18 +18,6 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
}
|
||||
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
@@ -89,5 +77,29 @@ namespace YooAsset.Editor
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ClearBuildCache
|
||||
public static bool GetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline, bool clearBuildCache)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
||||
}
|
||||
|
||||
// UseAssetDependencyDB
|
||||
public static bool GetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline, bool useAssetDependencyDB)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
@@ -69,6 +69,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_pipelineMenu.style.width = 200;
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.EditorSimulateBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.EditorSimulateBuildPipeline);
|
||||
_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);
|
||||
@@ -93,7 +94,11 @@ namespace YooAsset.Editor
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
||||
{
|
||||
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
|
@@ -8,87 +8,37 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||
public static PackageInvokeBuildResult SimulateBuild(PackageInvokeBuildParam buildParam)
|
||||
{
|
||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
||||
string packageName = buildParam.PackageName;
|
||||
string buildPipelineName = buildParam.BuildPipelineName;
|
||||
|
||||
if (buildPipelineName == "EditorSimulateBuildPipeline")
|
||||
{
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
var buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = buildPipelineName;
|
||||
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
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);
|
||||
var pipeline = new EditorSimulateBuildPipeline();
|
||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
var reulst = new PackageInvokeBuildResult();
|
||||
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||
return reulst;
|
||||
}
|
||||
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;
|
||||
|
||||
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;
|
||||
Debug.LogError(buildResult.ErrorInfo);
|
||||
throw new System.Exception($"{nameof(EditorSimulateBuildPipeline)} build failed !");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@@ -56,6 +56,7 @@ namespace YooAsset.Editor
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
@@ -84,9 +85,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo buildAsset)
|
||||
{
|
||||
if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
|
||||
string assetPath = buildAsset.AssetInfo.AssetPath;
|
||||
if (_assetPaths.Contains(assetPath))
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}");
|
||||
|
||||
_assetPaths.Add(assetPath);
|
||||
MainAssets.Add(buildAsset);
|
||||
}
|
||||
|
||||
@@ -95,14 +98,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
{
|
||||
foreach (var buildAsset in MainAssets)
|
||||
{
|
||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return _assetPaths.Contains(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -22,20 +22,20 @@ namespace YooAsset.Editor
|
||||
public string BuildinFileRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// 构建管线名称
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建资源包类型
|
||||
/// </summary>
|
||||
public int BuildBundleType;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
@@ -46,9 +46,24 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string PackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹备注
|
||||
/// </summary>
|
||||
public string PackageNote;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用共享资源打包
|
||||
/// 清空构建缓存文件
|
||||
/// </summary>
|
||||
public bool ClearBuildCacheFiles = false;
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖缓存数据库
|
||||
/// 说明:开启此项可以极大提高资源收集速度
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用共享资源打包
|
||||
/// </summary>
|
||||
public bool EnableSharePackRule = false;
|
||||
|
||||
@@ -60,12 +75,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 资源包名称样式
|
||||
/// </summary>
|
||||
public EFileNameStyle FileNameStyle;
|
||||
public EFileNameStyle FileNameStyle = EFileNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
@@ -95,32 +110,12 @@ namespace YooAsset.Editor
|
||||
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 !");
|
||||
@@ -131,33 +126,31 @@ namespace YooAsset.Editor
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 强制构建删除包裹目录
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
if (string.IsNullOrEmpty(BuildPipeline))
|
||||
{
|
||||
string packageRootDirectory = GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineIsNullOrEmpty, "Build pipeline is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (BuildBundleType == (int)EBuildBundleType.Unknown)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeIsUnknown, $"Build bundle type is unknown {BuildBundleType} !");
|
||||
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 (BuildMode != EBuildMode.SimulateBuild)
|
||||
// 设置默认备注信息
|
||||
if (string.IsNullOrEmpty(PackageNote))
|
||||
{
|
||||
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}");
|
||||
PackageNote = DateTime.Now.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,19 +12,22 @@ namespace YooAsset.Editor
|
||||
|
||||
public abstract class TaskCreateManifest
|
||||
{
|
||||
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
|
||||
private readonly Dictionary<string, int> _cachedBundleIndexIDs = 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)
|
||||
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
|
||||
// 检测资源包哈希冲突
|
||||
CheckBundleHashConflict(buildMapContext);
|
||||
|
||||
// 创建新补丁清单
|
||||
PackageManifest manifest = new PackageManifest();
|
||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||
@@ -32,20 +35,24 @@ namespace YooAsset.Editor
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
manifest.PackageName = buildParameters.PackageName;
|
||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
||||
manifest.PackageNote = buildParameters.PackageNote;
|
||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
// 处理资源包的依赖列表
|
||||
// 处理资源清单的ID数据
|
||||
ProcessPacakgeIDs(manifest);
|
||||
|
||||
// 处理资源包的依赖列表
|
||||
if (processBundleDepends)
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
// 处理资源包的标签集合
|
||||
if (processBundleTags)
|
||||
ProcessBundleTags(manifest);
|
||||
}
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
@@ -61,7 +68,7 @@ namespace YooAsset.Editor
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileMD5(filePath);
|
||||
packageHash = HashUtility.FileCRC32(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
@@ -87,15 +94,37 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测资源包哈希冲突
|
||||
/// </summary>
|
||||
private void CheckBundleHashConflict(BuildMapContext buildMapContext)
|
||||
{
|
||||
// 说明:在特殊情况下,例如某些文件加密算法会导致加密后的文件哈希值冲突!
|
||||
// 说明:二进制完全相同的原生文件也会冲突!
|
||||
HashSet<string> guids = new HashSet<string>();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (guids.Contains(bundleInfo.PackageFileHash))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleHashConflict, $"Bundle hash conflict : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
guids.Add(bundleInfo.PackageFileHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的依赖集合
|
||||
/// </summary>
|
||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源对象列表
|
||||
/// 创建资源对象列表
|
||||
/// </summary>
|
||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
||||
private List<PackageAsset> CreatePackageAssetList(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
@@ -108,17 +137,20 @@ namespace YooAsset.Editor
|
||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
|
||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
|
||||
// 按照AssetPath排序
|
||||
result.Sort((a, b) => a.AssetPath.CompareTo(b.AssetPath));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包列表
|
||||
/// 创建资源包列表
|
||||
/// </summary>
|
||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
||||
private List<PackageBundle> CreatePackageBundleList(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
@@ -127,14 +159,28 @@ namespace YooAsset.Editor
|
||||
result.Add(packageBundle);
|
||||
}
|
||||
|
||||
// 注意:缓存资源包索引
|
||||
for (int index = 0; index < result.Count; index++)
|
||||
// 按照BundleName排序
|
||||
result.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源清单的ID数据
|
||||
/// </summary>
|
||||
private void ProcessPacakgeIDs(PackageManifest manifest)
|
||||
{
|
||||
// 注意:优先缓存资源包索引
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
string bundleName = result[index].BundleName;
|
||||
_cachedBundleID.Add(bundleName, index);
|
||||
string bundleName = manifest.BundleList[index].BundleName;
|
||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||
}
|
||||
|
||||
return result;
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
string bundleName = packageAsset.BundleNameInEditor;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,12 +191,12 @@ namespace YooAsset.Editor
|
||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
||||
int mainBundleID = GetCachedBundleIndexID(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);
|
||||
int bundleID = GetCachedBundleIndexID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
}
|
||||
@@ -171,18 +217,21 @@ namespace YooAsset.Editor
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
if (packageBundle.DependIDs != null)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
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))
|
||||
if (_cacheBundleTags.TryGetValue(index, out var value))
|
||||
{
|
||||
packageBundle.Tags = _cacheBundleTags[index].ToArray();
|
||||
packageBundle.Tags = value.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -205,13 +254,13 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的索引ID
|
||||
/// 获取缓存的资源包的索引ID
|
||||
/// </summary>
|
||||
private int GetCachedBundleID(string bundleName)
|
||||
private int GetCachedBundleIndexID(string bundleName)
|
||||
{
|
||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
||||
if (_cachedBundleIndexIDs.TryGetValue(bundleName, out int value) == false)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
|
||||
throw new Exception($"Should never get here ! Not found bundle index ID : {bundleName}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
@@ -28,9 +28,10 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildBundleType = buildParameters.BuildBundleType;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||
|
||||
// 收集器配置
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
@@ -41,6 +42,8 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
||||
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||
@@ -113,7 +116,7 @@ namespace YooAsset.Editor
|
||||
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
|
||||
|
||||
// 序列化文件
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string fileName = YooAssetSettingsData.GetBuildReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildLogger.Log($"Create build report file: {filePath}");
|
||||
@@ -130,6 +133,7 @@ namespace YooAsset.Editor
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
dependBundles.Sort();
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
@@ -159,6 +163,7 @@ namespace YooAsset.Editor
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -168,7 +173,9 @@ namespace YooAsset.Editor
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
||||
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
private int GetMainAssetCount(PackageManifest manifest)
|
||||
|
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
fileInfo.FileLoadPath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
if (encryptResult.Encrypted)
|
||||
{
|
||||
|
@@ -12,16 +12,16 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 生成资源构建上下文
|
||||
/// </summary>
|
||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
||||
public BuildMapContext CreateBuildMap(bool simulateBuild, BuildParameters buildParameters)
|
||||
{
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
var buildMode = buildParameters.BuildMode;
|
||||
var packageName = buildParameters.PackageName;
|
||||
|
||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 获取所有收集器收集的资源
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, useAssetDependencyDB, packageName);
|
||||
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
@@ -56,9 +56,9 @@ namespace YooAsset.Editor
|
||||
string bundleName = collectAssetInfo.BundleName;
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(dependAsset.AssetPath))
|
||||
if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out var value))
|
||||
{
|
||||
allBuildAssetInfos[dependAsset.AssetPath].AddReferenceBundleName(bundleName);
|
||||
value.AddReferenceBundleName(bundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -65,32 +65,5 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
|
||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||
//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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,11 +20,6 @@ namespace YooAsset.Editor
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
@@ -35,14 +30,12 @@ namespace YooAsset.Editor
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||
// 检测输出目录
|
||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
{
|
||||
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);
|
||||
}
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success !");
|
||||
|
@@ -12,14 +12,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
CreateManifestFile(true, true, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
@@ -9,17 +9,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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);
|
||||
}
|
||||
CreatePackagePatch(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
|
@@ -13,12 +13,7 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
}
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||
@@ -12,12 +7,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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);
|
||||
}
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
|
@@ -17,13 +17,42 @@ namespace YooAsset.Editor
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测是否有未保存场景
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 删除包裹目录
|
||||
if (buildParameters.ClearBuildCacheFiles)
|
||||
{
|
||||
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测包裹输出目录是否存在
|
||||
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
|
||||
// 检测Unity版本
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||
BuildLogger.Warning(warning);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@@ -15,77 +15,45 @@ namespace YooAsset.Editor
|
||||
|
||||
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)
|
||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
return hash.ToString();
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
string filePath = bundleInfo.BuildOutputFilePath;
|
||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||
{
|
||||
return 0;
|
||||
return crc;
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,10 +15,6 @@ namespace YooAsset.Editor
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
@@ -32,15 +28,14 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
||||
string[] unityBuildContent = unityManifest.GetAllAssetBundles();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||
// 1. 计划内容
|
||||
string[] planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
||||
// 2. 验证差异
|
||||
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
@@ -53,8 +48,8 @@ namespace YooAsset.Editor
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
||||
// 3. 验证差异
|
||||
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
|
@@ -34,18 +34,12 @@ namespace YooAsset.Editor
|
||||
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 (CompressOption == ECompressOption.Uncompressed)
|
||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
|
||||
if (BuildMode == EBuildMode.ForceRebuild)
|
||||
if (ClearBuildCacheFiles)
|
||||
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).
|
||||
|
@@ -8,8 +8,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
if (buildParameters is BuiltinBuildParameters)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0b4ccec8007a6047aade899b4b74fcf
|
||||
guid: 12f78ad22f0513c44b6037469dbd6363
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa6624433c5d8e445b1426dcdf0763ba
|
||||
guid: 1138888cdba447345abb498b0c89affa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@@ -0,0 +1,18 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_ESBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff1eb84d9996ca1409e37f45617b1bdb
|
||||
guid: 120e126cc10604c4f811c3b6377f7452
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -0,0 +1,15 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_ESBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b6f2523a865e454d8fa3f48a2852d5a
|
||||
guid: 789c337b5b82f1c438a588982dfca346
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -0,0 +1,17 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_ESBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ff3c700b7f108b48998aa1630a769e1
|
||||
guid: abbe56a7120e34349b10f20956ed51a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -0,0 +1,63 @@
|
||||
|
||||
using System.Text;
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_ESBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return GetFilePathTempHash(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
return "00000000"; //8位
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
}
|
||||
|
||||
private string GetFilePathTempHash(string filePath)
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||
return HashUtility.BytesMD5(bytes);
|
||||
|
||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||
}
|
||||
private long GetBundleTempSize(BuildBundleInfo bundleInfo)
|
||||
{
|
||||
long tempSize = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 699068f8f637708409436199baa62c1f
|
||||
guid: 990b41f647b80a34ab666a3b0c1ba3f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@@ -0,0 +1,7 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class EditorSimulateBuildParameters : BuildParameters
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03ea37371e6dc644cb2e6eabf9e7e2ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,37 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class EditorSimulateBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
if (buildParameters is EditorSimulateBuildParameters)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_ESBP(),
|
||||
new TaskGetBuildMap_ESBP(),
|
||||
new TaskUpdateBundleInfo_ESBP(),
|
||||
new TaskCreateManifest_ESBP()
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9caf8e4846ad8b64eb04a4d5179942ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -10,14 +10,8 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
}
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -13,13 +13,9 @@ namespace YooAsset.Editor
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,12 +9,12 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
CreateManifestFile(false, true, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return new string[] { };
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,17 +9,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
CreatePackagePatch(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
@@ -13,12 +13,7 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
}
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_RFBP : TaskEncryption, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3e156139dcc25f4c9440ec3d6cb96d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
|
||||
// 检测构建结果
|
||||
|
@@ -16,23 +16,29 @@ namespace YooAsset.Editor
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测不被支持的参数
|
||||
if (buildParameters.EnableSharePackRule)
|
||||
// 删除包裹目录
|
||||
if (buildParameters.ClearBuildCacheFiles)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportSharePackRule, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support share pack rule !");
|
||||
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测包裹输出目录是否存在
|
||||
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
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);
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,18 +15,8 @@ namespace YooAsset.Editor
|
||||
|
||||
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);
|
||||
}
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
@@ -35,29 +25,17 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
@@ -11,8 +11,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
if (buildParameters is RawFileBuildParameters)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,6 +32,7 @@ namespace YooAsset.Editor
|
||||
new TaskPrepare_RFBP(),
|
||||
new TaskGetBuildMap_RFBP(),
|
||||
new TaskBuilding_RFBP(),
|
||||
new TaskEncryption_RFBP(),
|
||||
new TaskUpdateBundleInfo_RFBP(),
|
||||
new TaskCreateManifest_RFBP(),
|
||||
new TaskCreateReport_RFBP(),
|
||||
|
@@ -21,18 +21,13 @@ namespace YooAsset.Editor
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过引擎构建
|
||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName, null);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
|
@@ -12,14 +12,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(context);
|
||||
CreateManifestFile(true, true, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
@@ -9,17 +9,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildMode = buildParameters.Parameters.BuildMode;
|
||||
if (buildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
CreatePackageCatalog(buildParameters, buildMapContext);
|
||||
}
|
||||
CreatePackagePatch(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
|
@@ -13,12 +13,7 @@ namespace YooAsset.Editor
|
||||
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);
|
||||
}
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||
@@ -12,12 +7,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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);
|
||||
}
|
||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
||||
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
|
@@ -16,17 +16,40 @@ namespace YooAsset.Editor
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 检测不被支持的构建模式
|
||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
||||
// 检测是否有未保存场景
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
|
||||
// 删除包裹目录
|
||||
if (buildParameters.ClearBuildCacheFiles)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||
// Deletes the build cache directory.
|
||||
UnityEditor.Build.Pipeline.Utilities.BuildCache.PurgeCache(false);
|
||||
|
||||
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
// 检测包裹输出目录是否存在
|
||||
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 如果输出目录不存在
|
||||
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,77 +15,45 @@ namespace YooAsset.Editor
|
||||
|
||||
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)
|
||||
// 注意:当资源包的依赖列表发生变化的时候,ContentHash也会发生变化!
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return "00000000000000000000000000000000"; //32位
|
||||
return value.Hash.ToString();
|
||||
}
|
||||
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);
|
||||
}
|
||||
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)
|
||||
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
|
||||
{
|
||||
return 0;
|
||||
return value.Crc;
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
@@ -16,10 +16,6 @@ namespace YooAsset.Editor
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 模拟构建模式下跳过验证
|
||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
||||
return;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
@@ -33,15 +29,14 @@ namespace YooAsset.Editor
|
||||
/// </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();
|
||||
List<string> unityBuildContent = buildResults.BundleInfos.Keys.ToList();
|
||||
|
||||
// 1. 过滤掉原生Bundle
|
||||
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||
// 1. 计划内容
|
||||
List<string> planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||
|
||||
// 2. 验证Bundle
|
||||
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
||||
// 2. 验证差异
|
||||
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
@@ -54,8 +49,8 @@ namespace YooAsset.Editor
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证Bundle
|
||||
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
||||
// 3. 验证差异
|
||||
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
|
@@ -9,7 +9,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
{
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName, string unityMonoScriptsBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
@@ -28,7 +28,10 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
#endif
|
||||
buildTasks.Add(new CalculateAssetDependencyData());
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
if (string.IsNullOrEmpty(unityMonoScriptsBundleName) == false)
|
||||
buildTasks.Add(new CreateMonoScriptBundle(unityMonoScriptsBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
|
||||
// Packing
|
||||
|
@@ -8,8 +8,15 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
if (buildParameters is ScriptableBuildParameters)
|
||||
{
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -12,9 +12,9 @@ namespace YooAsset.Editor
|
||||
BuildOutputRootIsNullOrEmpty = 113,
|
||||
BuildinFileRootIsNullOrEmpty = 114,
|
||||
PackageOutputDirectoryExists = 115,
|
||||
BuildPipelineIsNullOrEmpty = 116,
|
||||
BuildBundleTypeIsUnknown = 117,
|
||||
RecommendScriptBuildPipeline = 130,
|
||||
BuildPipelineNotSupportBuildMode = 140,
|
||||
BuildPipelineNotSupportSharePackRule = 141,
|
||||
|
||||
// TaskGetBuildMap
|
||||
RemoveInvalidTags = 200,
|
||||
@@ -39,5 +39,6 @@ namespace YooAsset.Editor
|
||||
// TaskCreateManifest
|
||||
NotFoundUnityBundleInBuildResult = 600,
|
||||
FoundStrayBundle = 601,
|
||||
BundleHashConflict = 602,
|
||||
}
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包流水线的构建模式
|
||||
/// </summary>
|
||||
public enum EBuildMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 强制重建模式
|
||||
/// </summary>
|
||||
ForceRebuild,
|
||||
|
||||
/// <summary>
|
||||
/// 增量构建模式
|
||||
/// </summary>
|
||||
IncrementalBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 演练构建模式
|
||||
/// </summary>
|
||||
DryRunBuild,
|
||||
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
SimulateBuild,
|
||||
}
|
||||
}
|
@@ -6,6 +6,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public enum EBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下的模拟构建管线(ESBP)
|
||||
/// </summary>
|
||||
EditorSimulateBuildPipeline,
|
||||
|
||||
/// <summary>
|
||||
/// 传统内置构建管线 (BBP)
|
||||
/// </summary>
|
||||
|
@@ -3,6 +3,6 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public interface IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
}
|
||||
}
|
@@ -13,6 +13,7 @@ namespace YooAsset.Editor
|
||||
internal abstract class BuildPipelineViewerBase
|
||||
{
|
||||
private const int StyleWidth = 400;
|
||||
private const int LabelMinWidth = 180;
|
||||
|
||||
protected readonly string PackageName;
|
||||
protected readonly BuildTarget BuildTarget;
|
||||
@@ -27,6 +28,8 @@ namespace YooAsset.Editor
|
||||
private EnumField _outputNameStyleField;
|
||||
private EnumField _copyBuildinFileOptionField;
|
||||
private TextField _copyBuildinFileTagsField;
|
||||
private Toggle _clearBuildCacheToggle;
|
||||
private Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||
{
|
||||
@@ -59,24 +62,6 @@ namespace YooAsset.Editor
|
||||
_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));
|
||||
if (defaultIndex < 0)
|
||||
defaultIndex = (int)(EBuildMode)buildModeList[0];
|
||||
_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");
|
||||
@@ -148,6 +133,35 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||
});
|
||||
|
||||
// 清理构建缓存
|
||||
bool clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
_clearBuildCacheToggle.SetValueWithoutNotify(clearBuildCache);
|
||||
_clearBuildCacheToggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageClearBuildCache(PackageName, BuildPipeline, _clearBuildCacheToggle.value);
|
||||
});
|
||||
|
||||
// 使用资源依赖数据库
|
||||
bool useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
_useAssetDependencyDBToggle.SetValueWithoutNotify(useAssetDependencyDB);
|
||||
_useAssetDependencyDBToggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageUseAssetDependencyDB(PackageName, BuildPipeline, _useAssetDependencyDBToggle.value);
|
||||
});
|
||||
|
||||
// 对齐文本间距
|
||||
UIElementsTools.SetElementLabelMinWidth(_buildOutputField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_buildVersionField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_compressionField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_encryptionField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_outputNameStyleField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_copyBuildinFileOptionField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_copyBuildinFileTagsField, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_clearBuildCacheToggle, LabelMinWidth);
|
||||
UIElementsTools.SetElementLabelMinWidth(_useAssetDependencyDBToggle, LabelMinWidth);
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
@@ -160,8 +174,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
||||
if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
@@ -177,11 +190,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
protected abstract void ExecuteBuild();
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线支持的构建模式集合
|
||||
/// </summary>
|
||||
protected abstract List<Enum> GetSupportBuildModes();
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建版本
|
||||
/// </summary>
|
||||
|
@@ -2,7 +2,8 @@
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||
<ui:VisualElement name="BuildModeContainer" style="height: 24px;" />
|
||||
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
|
@@ -22,18 +22,19 @@ namespace YooAsset.Editor
|
||||
/// </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);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
@@ -41,24 +42,16 @@ namespace YooAsset.Editor
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,70 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class EditorSimulateBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public EditorSimulateBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
var compressionField = Root.Q<EnumField>("Compression");
|
||||
UIElementsTools.SetElementVisible(compressionField, false);
|
||||
|
||||
var encryptionContainer = Root.Q<VisualElement>("EncryptionContainer");
|
||||
UIElementsTools.SetElementVisible(encryptionContainer, false);
|
||||
|
||||
var fileNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
UIElementsTools.SetElementVisible(fileNameStyleField, false);
|
||||
|
||||
var copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
UIElementsTools.SetElementVisible(copyBuildinFileOptionField, false);
|
||||
|
||||
var copyBuildinFileParamField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
UIElementsTools.SetElementVisible(copyBuildinFileParamField, false);
|
||||
|
||||
var clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
UIElementsTools.SetElementVisible(clearBuildCacheToggle, false);
|
||||
|
||||
var useAssetDependencyToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
UIElementsTools.SetElementVisible(useAssetDependencyToggle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
|
||||
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01e426f05b237b340881910d779e4c2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -24,23 +24,26 @@ namespace YooAsset.Editor
|
||||
/// </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 clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
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.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
@@ -48,14 +51,6 @@ namespace YooAsset.Editor
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -22,18 +22,19 @@ namespace YooAsset.Editor
|
||||
/// </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);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.BuildMode = buildMode;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
@@ -41,22 +42,16 @@ namespace YooAsset.Editor
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -140,7 +140,7 @@ namespace YooAsset.Editor
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
if (command.SimulateBuild)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
@@ -149,7 +149,7 @@ namespace YooAsset.Editor
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
|
||||
|
||||
// 收集打包资源路径
|
||||
List<string> findAssets =new List<string>();
|
||||
List<string> findAssets = new List<string>();
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
@@ -218,13 +218,7 @@ namespace YooAsset.Editor
|
||||
string bundleName = GetBundleName(command, group, assetInfo);
|
||||
List<string> assetTags = GetAssetTags(group);
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetInfo, assetTags);
|
||||
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
collectAssetInfo.DependAssets = new List<AssetInfo>();
|
||||
else
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
|
||||
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
|
||||
return collectAssetInfo;
|
||||
}
|
||||
|
||||
@@ -272,7 +266,11 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.SimulateBuild)
|
||||
return new List<AssetInfo>();
|
||||
|
||||
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);
|
||||
List<AssetInfo> result = new List<AssetInfo>(depends.Length);
|
||||
foreach (string assetPath in depends)
|
||||
{
|
||||
|
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
if (activeRule.IsActiveGroup(new GroupData(GroupName)) == false)
|
||||
return;
|
||||
|
||||
foreach (var collector in Collectors)
|
||||
@@ -80,7 +80,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 检测分组是否激活
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||
if (activeRule.IsActiveGroup() == false)
|
||||
if (activeRule.IsActiveGroup(new GroupData(GroupName)) == false)
|
||||
{
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取包裹收集的资源文件
|
||||
/// </summary>
|
||||
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||
public CollectResult GetPackageAssets(bool simulateBuild, bool useAssetDependencyDB, string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Build package name is null or empty !");
|
||||
@@ -100,7 +100,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建资源收集命令
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
||||
CollectCommand command = new CollectCommand(simulateBuild, useAssetDependencyDB, packageName,
|
||||
package.EnableAddressable,
|
||||
package.LocationToLower,
|
||||
package.IncludeAssetGUID,
|
||||
|
@@ -23,7 +23,7 @@ namespace YooAsset.Editor
|
||||
|
||||
private static readonly Dictionary<string, System.Type> _cacheIgnoreRuleTypes = new Dictionary<string, System.Type>();
|
||||
private static readonly Dictionary<string, IIgnoreRule> _cacheIgnoreRuleInstance = new Dictionary<string, IIgnoreRule>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
@@ -201,7 +201,6 @@ namespace YooAsset.Editor
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.ClearAll();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
public static List<RuleDisplayName> GetActiveRuleNames()
|
||||
@@ -275,23 +274,23 @@ namespace YooAsset.Editor
|
||||
|
||||
public static bool HasActiveRuleName(string ruleName)
|
||||
{
|
||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheActiveRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasAddressRuleName(string ruleName)
|
||||
{
|
||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheAddressRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasPackRuleName(string ruleName)
|
||||
{
|
||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
||||
return _cachePackRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasFilterRuleName(string ruleName)
|
||||
{
|
||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheFilterRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
public static bool HasIgnoreRuleName(string ruleName)
|
||||
{
|
||||
return _cacheIgnoreRuleTypes.Keys.Contains(ruleName);
|
||||
return _cacheIgnoreRuleTypes.ContainsKey(ruleName);
|
||||
}
|
||||
|
||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||
|
@@ -42,7 +42,7 @@ namespace YooAsset.Editor
|
||||
private Toggle _includeAssetGUIDToogle;
|
||||
private Toggle _autoCollectShadersToogle;
|
||||
private PopupField<RuleDisplayName> _ignoreRulePopupField;
|
||||
|
||||
|
||||
private VisualElement _packageContainer;
|
||||
private ListView _packageListView;
|
||||
private TextField _packageNameTxt;
|
||||
@@ -172,10 +172,10 @@ namespace YooAsset.Editor
|
||||
_ignoreRulePopupField.style.width = 300;
|
||||
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
if(selectPackage != null)
|
||||
if (selectPackage != null)
|
||||
{
|
||||
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||
@@ -205,7 +205,9 @@ namespace YooAsset.Editor
|
||||
_packageListView = root.Q<ListView>("PackageListView");
|
||||
_packageListView.makeItem = MakePackageListViewItem;
|
||||
_packageListView.bindItem = BindPackageListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_packageListView.selectionChanged += PackageListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
|
||||
#else
|
||||
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
|
||||
@@ -250,7 +252,9 @@ namespace YooAsset.Editor
|
||||
_groupListView = root.Q<ListView>("GroupListView");
|
||||
_groupListView.makeItem = MakeGroupListViewItem;
|
||||
_groupListView.bindItem = BindGroupListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_groupListView.selectionChanged += GroupListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||
#else
|
||||
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||
@@ -657,7 +661,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 激活状态
|
||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
|
||||
bool isActive = activeRule.IsActiveGroup();
|
||||
bool isActive = activeRule.IsActiveGroup(new GroupData(group.GroupName));
|
||||
textField1.SetEnabled(isActive);
|
||||
}
|
||||
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||
@@ -991,7 +995,7 @@ namespace YooAsset.Editor
|
||||
try
|
||||
{
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
||||
CollectCommand command = new CollectCommand(true, false,
|
||||
_packageNameTxt.value,
|
||||
_enableAddressableToogle.value,
|
||||
_locationToLowerToogle.value,
|
||||
|
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetDependencyCache
|
||||
{
|
||||
private readonly AssetDependencyDatabase _database;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源依赖缓存系统
|
||||
/// </summary>
|
||||
public AssetDependencyCache(bool useAssetDependencyDB)
|
||||
{
|
||||
if (useAssetDependencyDB)
|
||||
Debug.Log("Use asset dependency database !");
|
||||
|
||||
string databaseFilePath = "Library/AssetDependencyDB";
|
||||
_database = new AssetDependencyDatabase();
|
||||
_database.CreateDatabase(useAssetDependencyDB, databaseFilePath);
|
||||
|
||||
if (useAssetDependencyDB)
|
||||
{
|
||||
_database.SaveDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源的依赖列表
|
||||
/// </summary>
|
||||
/// <param name="assetPath">资源路径</param>
|
||||
/// <param name="recursive">递归查找所有依赖</param>
|
||||
/// <returns>返回依赖的资源路径集合</returns>
|
||||
public string[] GetDependencies(string assetPath, bool recursive = true)
|
||||
{
|
||||
// 通过本地缓存获取依赖关系
|
||||
return _database.GetDependencies(assetPath, recursive);
|
||||
|
||||
// 通过Unity引擎获取依赖关系
|
||||
//return AssetDatabase.GetDependencies(assetPath, recursive);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddc7e04182c802b468e038777e4dd442
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,240 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源依赖数据库
|
||||
/// </summary>
|
||||
public class AssetDependencyDatabase
|
||||
{
|
||||
private const string FILE_VERSION = "1.0";
|
||||
|
||||
private class DependencyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 此哈希函数会聚合了以下内容:源资源路径、源资源、元文件、目标平台以及导入器版本。
|
||||
/// 如果此哈希值发送变化,则说明导入资源可能已更改,因此应重新搜集依赖关系。
|
||||
/// </summary>
|
||||
public string DependHash;
|
||||
|
||||
/// <summary>
|
||||
/// 直接依赖资源的GUID列表
|
||||
/// </summary>
|
||||
public List<string> DependGUIDs = new List<string>();
|
||||
}
|
||||
|
||||
private string _databaseFilePath;
|
||||
private readonly Dictionary<string, DependencyInfo> _database = new Dictionary<string, DependencyInfo>(100000);
|
||||
|
||||
/// <summary>
|
||||
/// 创建缓存数据库
|
||||
/// </summary>
|
||||
public void CreateDatabase(bool readCacheDatabaseFile, string databaseFilePath)
|
||||
{
|
||||
_databaseFilePath = databaseFilePath;
|
||||
_database.Clear();
|
||||
|
||||
try
|
||||
{
|
||||
if (readCacheDatabaseFile && File.Exists(databaseFilePath))
|
||||
{
|
||||
// 解析缓存文件
|
||||
using var stream = File.OpenRead(databaseFilePath);
|
||||
using var reader = new BinaryReader(stream);
|
||||
string fileVersion = reader.ReadString();
|
||||
if (fileVersion != FILE_VERSION)
|
||||
throw new Exception("The database file version not match !");
|
||||
|
||||
var count = reader.ReadInt32();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var assetPath = reader.ReadString();
|
||||
var cacheInfo = new DependencyInfo
|
||||
{
|
||||
DependHash = reader.ReadString(),
|
||||
DependGUIDs = ReadStringList(reader),
|
||||
};
|
||||
_database.Add(assetPath, cacheInfo);
|
||||
}
|
||||
|
||||
// 移除无效资源
|
||||
List<string> removeList = new List<string>(10000);
|
||||
foreach (var cacheInfoPair in _database)
|
||||
{
|
||||
var assetPath = cacheInfoPair.Key;
|
||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
{
|
||||
removeList.Add(assetPath);
|
||||
}
|
||||
}
|
||||
foreach (var assetPath in removeList)
|
||||
{
|
||||
_database.Remove(assetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ClearDatabase(true);
|
||||
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
||||
}
|
||||
|
||||
// 查找新增或变动资源
|
||||
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
||||
foreach (var assetPath in allAssetPaths)
|
||||
{
|
||||
if (_database.TryGetValue(assetPath, out DependencyInfo cacheInfo))
|
||||
{
|
||||
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||
if (dependHash.ToString() != cacheInfo.DependHash)
|
||||
{
|
||||
_database[assetPath] = CreateDependencyInfo(assetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var newCacheInfo = CreateDependencyInfo(assetPath);
|
||||
_database.Add(assetPath, newCacheInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存缓存数据库
|
||||
/// </summary>
|
||||
public void SaveDatabase()
|
||||
{
|
||||
if (File.Exists(_databaseFilePath))
|
||||
File.Delete(_databaseFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
using var stream = File.Create(_databaseFilePath);
|
||||
using var writer = new BinaryWriter(stream);
|
||||
writer.Write(FILE_VERSION);
|
||||
writer.Write(_database.Count);
|
||||
foreach (var assetPair in _database)
|
||||
{
|
||||
string assetPath = assetPair.Key;
|
||||
var assetInfo = assetPair.Value;
|
||||
writer.Write(assetPath);
|
||||
writer.Write(assetInfo.DependHash);
|
||||
WriteStringList(writer, assetInfo.DependGUIDs);
|
||||
}
|
||||
writer.Flush();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Failed to save cache database : {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存数据库
|
||||
/// </summary>
|
||||
public void ClearDatabase(bool deleteDatabaseFile)
|
||||
{
|
||||
if (deleteDatabaseFile)
|
||||
{
|
||||
if (File.Exists(_databaseFilePath))
|
||||
File.Delete(_databaseFilePath);
|
||||
}
|
||||
|
||||
_database.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源的依赖列表
|
||||
/// </summary>
|
||||
public string[] GetDependencies(string assetPath, bool recursive)
|
||||
{
|
||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会包含主资源路径!
|
||||
|
||||
// 注意:机制上不允许存在未收录的资源
|
||||
if (_database.ContainsKey(assetPath) == false)
|
||||
{
|
||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||
}
|
||||
|
||||
var result = new HashSet<string> { assetPath };
|
||||
CollectDependencies(assetPath, result, recursive);
|
||||
|
||||
// 注意:AssetDatabase.GetDependencies保持一致,将主资源添加到依赖列表最前面
|
||||
return result.ToArray();
|
||||
}
|
||||
private void CollectDependencies(string assetPath, HashSet<string> result, bool recursive)
|
||||
{
|
||||
if (_database.TryGetValue(assetPath, out var cacheInfo) == false)
|
||||
{
|
||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||
}
|
||||
|
||||
foreach (var dependGUID in cacheInfo.DependGUIDs)
|
||||
{
|
||||
string dependAssetPath = AssetDatabase.GUIDToAssetPath(dependGUID);
|
||||
if (string.IsNullOrEmpty(dependAssetPath))
|
||||
continue;
|
||||
|
||||
// 如果是文件夹资源
|
||||
if (AssetDatabase.IsValidFolder(dependAssetPath))
|
||||
continue;
|
||||
|
||||
// 如果已经收集过
|
||||
if (result.Contains(dependAssetPath))
|
||||
continue;
|
||||
|
||||
result.Add(dependAssetPath);
|
||||
|
||||
// 递归收集依赖
|
||||
if (recursive)
|
||||
CollectDependencies(dependAssetPath, result, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> ReadStringList(BinaryReader reader)
|
||||
{
|
||||
var count = reader.ReadInt32();
|
||||
var values = new List<string>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
values.Add(reader.ReadString());
|
||||
}
|
||||
return values;
|
||||
}
|
||||
private void WriteStringList(BinaryWriter writer, List<string> values)
|
||||
{
|
||||
writer.Write(values.Count);
|
||||
foreach (var value in values)
|
||||
{
|
||||
writer.Write(value);
|
||||
}
|
||||
}
|
||||
private DependencyInfo CreateDependencyInfo(string assetPath)
|
||||
{
|
||||
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||
var dependGUIDs = new List<string>();
|
||||
foreach (var dependAssetPath in dependAssetPaths)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(dependAssetPath);
|
||||
if (string.IsNullOrEmpty(guid) == false)
|
||||
{
|
||||
dependGUIDs.Add(guid);
|
||||
}
|
||||
}
|
||||
|
||||
var cacheInfo = new DependencyInfo();
|
||||
cacheInfo.DependHash = dependHash.ToString();
|
||||
cacheInfo.DependGUIDs = dependGUIDs;
|
||||
return cacheInfo;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 38f3f2338cca06a42a0f845df9fbb563
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -4,10 +4,15 @@ namespace YooAsset.Editor
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode { private set; get; }
|
||||
public bool SimulateBuild { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖数据库
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
@@ -49,11 +54,12 @@ namespace YooAsset.Editor
|
||||
public IIgnoreRule IgnoreRule { private set; get; }
|
||||
|
||||
|
||||
public CollectCommand(EBuildMode buildMode, string packageName,
|
||||
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
||||
public CollectCommand(bool simulateBuild, bool useAssetDependencyDB, string packageName,
|
||||
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
||||
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
|
||||
{
|
||||
BuildMode = buildMode;
|
||||
SimulateBuild = simulateBuild;
|
||||
UseAssetDependencyDB = useAssetDependencyDB;
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
LocationToLower = locationToLower;
|
||||
@@ -66,5 +72,16 @@ namespace YooAsset.Editor
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
private AssetDependencyCache _assetDependency;
|
||||
public AssetDependencyCache AssetDependency
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_assetDependency == null)
|
||||
_assetDependency = new AssetDependencyCache(UseAssetDependencyDB);
|
||||
return _assetDependency;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,16 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public struct GroupData
|
||||
{
|
||||
public string GroupName;
|
||||
|
||||
public GroupData(string groupName)
|
||||
{
|
||||
GroupName = groupName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源分组激活规则接口
|
||||
/// </summary>
|
||||
@@ -9,6 +19,6 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 是否激活分组
|
||||
/// </summary>
|
||||
bool IsActiveGroup();
|
||||
bool IsActiveGroup(GroupData data);
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ namespace YooAsset.Editor
|
||||
[DisplayName("启用分组")]
|
||||
public class EnableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
public bool IsActiveGroup(GroupData data)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
||||
[DisplayName("禁用分组")]
|
||||
public class DisableGroup : IActiveRule
|
||||
{
|
||||
public bool IsActiveGroup()
|
||||
public bool IsActiveGroup(GroupData data)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@@ -20,7 +20,8 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".unity";
|
||||
string extension = Path.GetExtension(data.AssetPath);
|
||||
return extension == ".unity" || extension == ".scene";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,14 @@ namespace YooAsset.Editor
|
||||
if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
|
||||
return true;
|
||||
|
||||
// 忽略编辑器图标资源
|
||||
if (assetInfo.AssetPath.Contains("/Gizmos/"))
|
||||
return true;
|
||||
|
||||
// 忽略编辑器专属资源
|
||||
if (assetInfo.AssetPath.Contains("/Editor/") || assetInfo.AssetPath.Contains("/Editor Resources/"))
|
||||
return true;
|
||||
|
||||
// 忽略编辑器下的类型资源
|
||||
if (assetInfo.AssetType == typeof(LightingDataAsset))
|
||||
return true;
|
||||
|
@@ -147,6 +147,22 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包视频文件
|
||||
/// </summary>
|
||||
[DisplayName("打包视频文件")]
|
||||
public class PackVideoFile : IPackRule
|
||||
{
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = data.AssetPath;
|
||||
string fileExtension = Path.GetExtension(data.AssetPath);
|
||||
fileExtension = fileExtension.Remove(0, 1);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打包着色器
|
||||
/// </summary>
|
||||
|
@@ -35,7 +35,9 @@ namespace YooAsset.Editor
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_assetListView.selectionChanged += AssetListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
|
@@ -35,7 +35,9 @@ namespace YooAsset.Editor
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
@@ -189,7 +191,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
||||
if (bundleInfo.Status == EOperationStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
|
@@ -104,7 +104,7 @@ namespace YooAsset.Editor
|
||||
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "json");
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "report");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
|
@@ -33,16 +33,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的资源包类型
|
||||
/// </summary>
|
||||
public int BuildBundleType;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹名称
|
||||
/// </summary>
|
||||
@@ -53,6 +53,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹备注
|
||||
/// </summary>
|
||||
public string BuildPackageNote;
|
||||
|
||||
// 收集器配置
|
||||
public bool UniqueBundleName;
|
||||
public bool EnableAddressable;
|
||||
@@ -62,6 +67,8 @@ namespace YooAsset.Editor
|
||||
public string IgnoreRuleName;
|
||||
|
||||
// 构建参数
|
||||
public bool ClearBuildCacheFiles;
|
||||
public bool UseAssetDependencyDB;
|
||||
public bool EnableSharePackRule;
|
||||
public string EncryptionClassName;
|
||||
public EFileNameStyle FileNameStyle;
|
||||
|
@@ -58,7 +58,9 @@ namespace YooAsset.Editor
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_assetListView.selectionChanged += AssetListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
|
@@ -66,7 +66,9 @@ namespace YooAsset.Editor
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
|
@@ -62,9 +62,10 @@ namespace YooAsset.Editor
|
||||
_items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)));
|
||||
_items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("Build Mode", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString()));
|
||||
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||
_items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Collect Settings", string.Empty));
|
||||
@@ -77,6 +78,8 @@ namespace YooAsset.Editor
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||
_items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}"));
|
||||
_items.Add(new ItemWrapper("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}"));
|
||||
_items.Add(new ItemWrapper("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"));
|
||||
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
|
||||
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
|
||||
|
@@ -42,6 +42,12 @@ namespace YooAsset.Editor
|
||||
AssetPath = assetPath;
|
||||
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
|
||||
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
|
||||
|
||||
// 注意:如果资源文件损坏或者实例化关联脚本丢失,获取的资源类型会无效!
|
||||
if (AssetType == null)
|
||||
{
|
||||
throw new Exception($"Found invalid asset : {AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@@ -559,6 +559,21 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除路径里的后缀名
|
||||
/// </summary>
|
||||
public static string RemoveExtension(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return str;
|
||||
|
||||
int index = str.LastIndexOf('.');
|
||||
if (index == -1)
|
||||
return str;
|
||||
else
|
||||
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取项目工程路径
|
||||
|
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using YooAsset.Editor;
|
||||
|
||||
[DisplayName("打包特效纹理(自定义)")]
|
||||
public class PackEffectTexture : IPackRule
|
||||
{
|
||||
private const string PackDirectory = "Assets/Effect/Textures/";
|
||||
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath;
|
||||
if (assetPath.StartsWith(PackDirectory) == false)
|
||||
throw new Exception($"Only support folder : {PackDirectory}");
|
||||
|
||||
string assetName = Path.GetFileName(assetPath).ToLower();
|
||||
string firstChar = assetName.Substring(0, 1);
|
||||
string bundleName = $"{PackDirectory}effect_texture_{firstChar}";
|
||||
var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return packRuleResult;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("打包视频(自定义)")]
|
||||
public class PackVideo : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = RemoveExtension(data.AssetPath);
|
||||
string fileExtension = Path.GetExtension(data.AssetPath);
|
||||
fileExtension = fileExtension.Remove(0, 1);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
private string RemoveExtension(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return str;
|
||||
|
||||
int index = str.LastIndexOf(".");
|
||||
if (index == -1)
|
||||
return str;
|
||||
else
|
||||
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
|
||||
}
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class PackageComparatorWindow : EditorWindow
|
||||
{
|
||||
static PackageComparatorWindow _thisInstance;
|
||||
|
||||
[MenuItem("YooAsset/Extension/补丁包比对工具", false, 102)]
|
||||
static void ShowWindow()
|
||||
{
|
||||
if (_thisInstance == null)
|
||||
{
|
||||
_thisInstance = EditorWindow.GetWindow(typeof(PackageComparatorWindow), false, "补丁包比对工具", true) as PackageComparatorWindow;
|
||||
_thisInstance.minSize = new Vector2(800, 600);
|
||||
}
|
||||
_thisInstance.Show();
|
||||
}
|
||||
|
||||
private string _manifestPath1 = string.Empty;
|
||||
private string _manifestPath2 = string.Empty;
|
||||
private readonly List<PackageBundle> _changeList = new List<PackageBundle>();
|
||||
private readonly List<PackageBundle> _newList = new List<PackageBundle>();
|
||||
private Vector2 _scrollPos1;
|
||||
private Vector2 _scrollPos2;
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包1", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (string.IsNullOrEmpty(resultPath))
|
||||
return;
|
||||
_manifestPath1 = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath1);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包2", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (string.IsNullOrEmpty(resultPath))
|
||||
return;
|
||||
_manifestPath2 = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath2);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (string.IsNullOrEmpty(_manifestPath1) == false && string.IsNullOrEmpty(_manifestPath2) == false)
|
||||
{
|
||||
if (GUILayout.Button("比对差异", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
ComparePackage(_changeList, _newList);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
using (new EditorGUI.DisabledScope(false))
|
||||
{
|
||||
int totalCount = _changeList.Count;
|
||||
EditorGUILayout.Foldout(true, $"差异列表 ( {totalCount} )");
|
||||
|
||||
EditorGUI.indentLevel = 1;
|
||||
_scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1);
|
||||
{
|
||||
foreach (var bundle in _changeList)
|
||||
{
|
||||
EditorGUILayout.LabelField($"{bundle.BundleName} | {(bundle.FileSize / 1024)}K");
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
EditorGUI.indentLevel = 0;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
using (new EditorGUI.DisabledScope(false))
|
||||
{
|
||||
int totalCount = _newList.Count;
|
||||
EditorGUILayout.Foldout(true, $"新增列表 ( {totalCount} )");
|
||||
|
||||
EditorGUI.indentLevel = 1;
|
||||
_scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2);
|
||||
{
|
||||
foreach (var bundle in _newList)
|
||||
{
|
||||
EditorGUILayout.LabelField($"{bundle.BundleName}");
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
EditorGUI.indentLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ComparePackage(List<PackageBundle> changeList, List<PackageBundle> newList)
|
||||
{
|
||||
changeList.Clear();
|
||||
newList.Clear();
|
||||
|
||||
// 加载补丁清单1
|
||||
byte[] bytesData1 = FileUtility.ReadAllBytes(_manifestPath1);
|
||||
PackageManifest manifest1 = ManifestTools.DeserializeFromBinary(bytesData1);
|
||||
|
||||
// 加载补丁清单1
|
||||
byte[] bytesData2 = FileUtility.ReadAllBytes(_manifestPath2);
|
||||
PackageManifest manifest2 = ManifestTools.DeserializeFromBinary(bytesData2);
|
||||
|
||||
// 拷贝文件列表
|
||||
foreach (var bundle2 in manifest2.BundleList)
|
||||
{
|
||||
if (manifest1.TryGetPackageBundleByBundleName(bundle2.BundleName, out PackageBundle bundle1))
|
||||
{
|
||||
if (bundle2.FileHash != bundle1.FileHash)
|
||||
{
|
||||
changeList.Add(bundle2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newList.Add(bundle2);
|
||||
}
|
||||
}
|
||||
|
||||
// 按字母重新排序
|
||||
changeList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||
newList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||
|
||||
Debug.Log("资源包差异比对完成!");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class PackageImporterWindow : EditorWindow
|
||||
{
|
||||
static PackageImporterWindow _thisInstance;
|
||||
|
||||
[MenuItem("YooAsset/Extension/补丁包导入工具", false, 101)]
|
||||
static void ShowWindow()
|
||||
{
|
||||
if (_thisInstance == null)
|
||||
{
|
||||
_thisInstance = EditorWindow.GetWindow(typeof(PackageImporterWindow), false, "补丁包导入工具", true) as PackageImporterWindow;
|
||||
_thisInstance.minSize = new Vector2(800, 600);
|
||||
}
|
||||
_thisInstance.Show();
|
||||
}
|
||||
|
||||
private string _manifestPath = string.Empty;
|
||||
private string _packageName = "DefaultPackage";
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (string.IsNullOrEmpty(resultPath))
|
||||
return;
|
||||
_manifestPath = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (string.IsNullOrEmpty(_manifestPath) == false)
|
||||
{
|
||||
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string streamingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
EditorTools.ClearFolder(streamingAssetsRoot);
|
||||
CopyPackageFiles(_manifestPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyPackageFiles(string manifestFilePath)
|
||||
{
|
||||
string manifestFileName = Path.GetFileNameWithoutExtension(manifestFilePath);
|
||||
string outputDirectory = Path.GetDirectoryName(manifestFilePath);
|
||||
|
||||
// 加载补丁清单
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||
PackageManifest manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
|
||||
// 拷贝核心文件
|
||||
{
|
||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
{
|
||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
|
||||
string sourcePath = $"{outputDirectory}/{fileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表
|
||||
int fileCount = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
fileCount++;
|
||||
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
Debug.Log($"补丁包拷贝完成,一共拷贝了{fileCount}个资源文件");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93f24a30c5726804b989f2519943af15
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user