init
This commit is contained in:
commit
01160cf00c
558
CHANGELOG.md
Normal file
558
CHANGELOG.md
Normal file
@ -0,0 +1,558 @@
|
||||
# CHANGELOG
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [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
|
||||
|
||||
- (#224) 修复了编辑器模式打包时 SimulateBuild 报错的问题。
|
||||
- (#223) 修复了资源构建界面读取配置导致的报错问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 支持共享资源打包规则,可以定制化独立的构建规则。
|
||||
|
||||
```c#
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否启用共享资源打包
|
||||
/// </summary>
|
||||
public bool EnableSharePackRule = false;
|
||||
}
|
||||
```
|
||||
|
||||
- 微信小游戏平台,资源下载器支持底层缓存查询。
|
||||
|
||||
## [2.1.0] - 2023-12-27
|
||||
|
||||
升级了 Scriptable build pipeline (SBP) 的版本,来解决图集引用的精灵图片冗余问题。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#195) 修复了在EditorPlayMode模式下,AssetHandle.GetDownloadStatus()发生异常的问题。
|
||||
- (#201) 修复了断点续传失效的问题。
|
||||
- (#202) 修复了打包参数FileNameStyle设置为BundleName后,IQueryServices会一直返回true的问题。
|
||||
- (#205) 修复了HybridCLR插件里创建资源下载器触发的异常。
|
||||
- (#210) 修复了DownloaderOperation在未开始下载前,内部的PackageName为空的问题。
|
||||
- (#220) 修复了资源收集界面关闭后,撤回操作还会生效的问题。
|
||||
- 修复了下载器合并后重新计算下载字节数不正确的问题。
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#198) 资源收集界面禁用的分组不再检测合法性。
|
||||
- (#203) 资源构建类容许自定义打包的输出目录。
|
||||
- 资源构建报告增加未依赖的资源信息列表。
|
||||
|
||||
### Changed
|
||||
|
||||
- IBuildinQueryServices和IDeliveryQueryServices查询方法变更。
|
||||
|
||||
```c#
|
||||
public interface IBuildinQueryServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询是否为应用程序内置的资源文件
|
||||
/// </summary>
|
||||
/// <param name="packageName">包裹名称</param>
|
||||
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||
/// <param name="fileCRC">文件哈希值</param>
|
||||
/// <returns>返回查询结果</returns>
|
||||
bool Query(string packageName, string fileName, string fileCRC);
|
||||
}
|
||||
|
||||
public interface IDeliveryQueryServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询是否为开发者分发的资源文件
|
||||
/// </summary>
|
||||
/// <param name="packageName">包裹名称</param>
|
||||
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
|
||||
/// <param name="fileCRC">文件哈希值</param>
|
||||
/// <returns>返回查询结果</returns>
|
||||
bool Query(string packageName, string fileName, string fileCRC);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Removed
|
||||
|
||||
- (#212) 移除了构建报告里的资源冗余信息列表。
|
||||
|
||||
7
CHANGELOG.md.meta
Normal file
7
CHANGELOG.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db680274cf006c548abff57b7e1894b4
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor.meta
Normal file
8
Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac093515ae764b94aa07be91d4ba978b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/AssetBundleBuilder.meta
Normal file
8
Editor/AssetBundleBuilder.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fdecc5500229d44887425ce619352fc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Editor/AssetBundleBuilder/AssetBundleBuilder.cs
Normal file
56
Editor/AssetBundleBuilder/AssetBundleBuilder.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilder
|
||||
{
|
||||
private readonly BuildContext _buildContext = new BuildContext();
|
||||
|
||||
/// <summary>
|
||||
/// 构建资源包
|
||||
/// </summary>
|
||||
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline, bool enableLog)
|
||||
{
|
||||
// 检测构建参数是否为空
|
||||
if (buildParameters == null)
|
||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||
|
||||
// 检测构建参数是否为空
|
||||
if (buildPipeline.Count == 0)
|
||||
throw new Exception($"Build pipeline is empty !");
|
||||
|
||||
// 清空旧数据
|
||||
_buildContext.ClearAllContext();
|
||||
|
||||
// 构建参数
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
|
||||
// 初始化日志
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
|
||||
// 执行构建流程
|
||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log("Resource pipeline build success");
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
|
||||
BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/AssetBundleBuilder.cs.meta
Normal file
11
Editor/AssetBundleBuilder/AssetBundleBuilder.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de7563040250b4e4a835d1fc90238e38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs
Normal file
28
Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的输出根目录
|
||||
/// </summary>
|
||||
public static string GetDefaultBuildOutputRoot()
|
||||
{
|
||||
string projectPath = EditorTools.GetProjectPath();
|
||||
return $"{projectPath}/Bundles";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取流文件夹路径
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs.meta
Normal file
11
Editor/AssetBundleBuilder/AssetBundleBuilderHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f48abdec05f0dbe438a83e181fe6bc93
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs
Normal file
105
Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderSetting
|
||||
{
|
||||
// EBuildPipeline
|
||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||
}
|
||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||
}
|
||||
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||
}
|
||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
EditorPrefs.SetInt(key, (int)compressOption);
|
||||
}
|
||||
|
||||
// EFileNameStyle
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||
}
|
||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionClassName
|
||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs.meta
Normal file
11
Editor/AssetBundleBuilder/AssetBundleBuilderSetting.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09788b4733bab2d4792fdd5d28e7653c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
166
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
Normal file
166
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs
Normal file
@ -0,0 +1,166 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleBuilderWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Builder", false, 102)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private string _buildPackage;
|
||||
private EBuildPipeline _buildPipeline;
|
||||
|
||||
private Toolbar _toolbar;
|
||||
private ToolbarMenu _packageMenu;
|
||||
private ToolbarMenu _pipelineMenu;
|
||||
private VisualElement _container;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleBuilderWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
_toolbar = root.Q<Toolbar>("Toolbar");
|
||||
_container = root.Q("Container");
|
||||
|
||||
// 检测构建包裹
|
||||
var packageNames = GetBuildPackageNames();
|
||||
if (packageNames.Count == 0)
|
||||
{
|
||||
var label = new Label();
|
||||
label.text = "Not found any package";
|
||||
label.style.width = 100;
|
||||
_toolbar.Add(label);
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建包裹
|
||||
{
|
||||
_buildPackage = packageNames[0];
|
||||
_packageMenu = new ToolbarMenu();
|
||||
_packageMenu.style.width = 200;
|
||||
foreach (var packageName in packageNames)
|
||||
{
|
||||
_packageMenu.menu.AppendAction(packageName, PackageMenuAction, PackageMenuFun, packageName);
|
||||
}
|
||||
_toolbar.Add(_packageMenu);
|
||||
}
|
||||
|
||||
// 构建管线
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_pipelineMenu.style.width = 200;
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.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);
|
||||
_toolbar.Add(_pipelineMenu);
|
||||
}
|
||||
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshBuildPipelineView()
|
||||
{
|
||||
// 清空扩展区域
|
||||
_container.Clear();
|
||||
|
||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||
_packageMenu.text = _buildPackage;
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
||||
{
|
||||
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||
{
|
||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||
}
|
||||
}
|
||||
private List<string> GetBuildPackageNames()
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
result.Add(package.PackageName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void PackageMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage != packageName)
|
||||
{
|
||||
_buildPackage = packageName;
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PackageMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var packageName = (string)action.userData;
|
||||
if (_buildPackage == packageName)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
|
||||
private void PipelineMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline != pipelineType)
|
||||
{
|
||||
_buildPipeline = pipelineType;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline == pipelineType)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs.meta
Normal file
11
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66e43420e95cd0b4bae8803a31e9817b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
4
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml
Normal file
4
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml
Normal file
@ -0,0 +1,4 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;" />
|
||||
<ui:VisualElement name="Container" />
|
||||
</ui:UXML>
|
||||
10
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml.meta
Normal file
10
Editor/AssetBundleBuilder/AssetBundleBuilderWindow.uxml.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28ba29adb4949284e8c48893218b0d9a
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
50
Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs
Normal file
50
Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleSimulateBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static EditorSimulateBuildResult SimulateBuild(EditorSimulateBuildParam buildParam)
|
||||
{
|
||||
string packageName = buildParam.PackageName;
|
||||
string buildPipelineName = buildParam.BuildPipelineName;
|
||||
|
||||
if (buildPipelineName == "EditorSimulateBuildPipeline")
|
||||
{
|
||||
var buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
var pipeline = new EditorSimulateBuildPipeline();
|
||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
var reulst = new EditorSimulateBuildResult();
|
||||
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||
return reulst;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(buildResult.ErrorInfo);
|
||||
throw new System.Exception($"{nameof(EditorSimulateBuildPipeline)} build failed !");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(buildPipelineName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs.meta
Normal file
11
Editor/AssetBundleBuilder/AssetBundleSimulateBuilder.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f94918fa1ea63c34fa0e49fdad4119cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
133
Editor/AssetBundleBuilder/BuildAssetInfo.cs
Normal file
133
Editor/AssetBundleBuilder/BuildAssetInfo.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildAssetInfo
|
||||
{
|
||||
private bool _isAddAssetTags = false;
|
||||
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 收集器类型
|
||||
/// </summary>
|
||||
public ECollectorType CollectorType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包完整名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
||||
/// </summary>
|
||||
public string Address { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息
|
||||
/// </summary>
|
||||
public AssetInfo AssetInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源的分类标签
|
||||
/// </summary>
|
||||
public readonly List<string> AssetTags = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的所有资源
|
||||
/// 注意:包括零依赖资源和冗余资源(资源包名无效)
|
||||
/// </summary>
|
||||
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
|
||||
|
||||
|
||||
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo)
|
||||
{
|
||||
CollectorType = collectorType;
|
||||
BundleName = bundleName;
|
||||
Address = address;
|
||||
AssetInfo = assetInfo;
|
||||
}
|
||||
public BuildAssetInfo(AssetInfo assetInfo)
|
||||
{
|
||||
CollectorType = ECollectorType.None;
|
||||
BundleName = string.Empty;
|
||||
Address = string.Empty;
|
||||
AssetInfo = assetInfo;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置所有依赖的资源
|
||||
/// </summary>
|
||||
public void SetDependAssetInfos(List<BuildAssetInfo> dependAssetInfos)
|
||||
{
|
||||
if (AllDependAssetInfos != null)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
AllDependAssetInfos = dependAssetInfos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置资源包名称
|
||||
/// </summary>
|
||||
public void SetBundleName(string bundleName)
|
||||
{
|
||||
if (HasBundleName())
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加资源的分类标签
|
||||
/// 说明:原始定义的资源分类标签
|
||||
/// </summary>
|
||||
public void AddAssetTags(List<string> tags)
|
||||
{
|
||||
if (_isAddAssetTags)
|
||||
throw new Exception("Should never get here !");
|
||||
_isAddAssetTags = true;
|
||||
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (AssetTags.Contains(tag) == false)
|
||||
{
|
||||
AssetTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加关联的资源包名称
|
||||
/// </summary>
|
||||
public void AddReferenceBundleName(string bundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (_referenceBundleNames.Contains(bundleName) == false)
|
||||
_referenceBundleNames.Add(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名是否存在
|
||||
/// </summary>
|
||||
public bool HasBundleName()
|
||||
{
|
||||
if (string.IsNullOrEmpty(BundleName))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取关联资源包的数量
|
||||
/// </summary>
|
||||
public int GetReferenceBundleCount()
|
||||
{
|
||||
return _referenceBundleNames.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/BuildAssetInfo.cs.meta
Normal file
11
Editor/AssetBundleBuilder/BuildAssetInfo.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447008dd110b8d746aafbe88c78bee5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
172
Editor/AssetBundleBuilder/BuildBundleInfo.cs
Normal file
172
Editor/AssetBundleBuilder/BuildBundleInfo.cs
Normal file
@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildBundleInfo
|
||||
{
|
||||
#region 补丁文件的关键信息
|
||||
/// <summary>
|
||||
/// Unity引擎生成的哈希值(构建内容的哈希值)
|
||||
/// </summary>
|
||||
public string PackageUnityHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Unity引擎生成的CRC
|
||||
/// </summary>
|
||||
public uint PackageUnityCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileHash { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public long PackageFileSize { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建输出的文件路径
|
||||
/// </summary>
|
||||
public string BuildOutputFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的源文件路径
|
||||
/// </summary>
|
||||
public string PackageSourceFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 补丁包的目标文件路径
|
||||
/// </summary>
|
||||
public string PackageDestFilePath { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密生成文件的路径
|
||||
/// 注意:如果未加密该路径为空
|
||||
/// </summary>
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public bool Encrypted { set; get; }
|
||||
|
||||
|
||||
public BuildBundleInfo(string bundleName)
|
||||
{
|
||||
BundleName = bundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo buildAsset)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
{
|
||||
return _assetPaths.Contains(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetAllMainAssetPaths()
|
||||
{
|
||||
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||
/// </summary>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(packAssets);
|
||||
foreach (var buildAsset in MainAssets)
|
||||
{
|
||||
if (buildAsset.AllDependAssetInfos == null)
|
||||
continue;
|
||||
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
{
|
||||
// 注意:我们不再支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllMainAssetPaths();
|
||||
return build;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有写入补丁清单的资源
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建PackageBundle类
|
||||
/// </summary>
|
||||
internal PackageBundle CreatePackageBundle()
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCRC = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.Encrypted = Encrypted;
|
||||
return packageBundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/BuildBundleInfo.cs.meta
Normal file
11
Editor/AssetBundleBuilder/BuildBundleInfo.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 826a9d7b4de0eba40b5c39b33747c011
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Editor/AssetBundleBuilder/BuildMapContext.cs
Normal file
110
Editor/AssetBundleBuilder/BuildMapContext.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildMapContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包集合
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 未被依赖的资源列表
|
||||
/// </summary>
|
||||
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
|
||||
/// <summary>
|
||||
/// 资源收集命令
|
||||
/// </summary>
|
||||
public CollectCommand Command { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包信息列表
|
||||
/// </summary>
|
||||
public Dictionary<string, BuildBundleInfo>.ValueCollection Collection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bundleInfoDic.Values;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加一个打包资源
|
||||
/// </summary>
|
||||
public void PackAsset(BuildAssetInfo assetInfo)
|
||||
{
|
||||
string bundleName = assetInfo.BundleName;
|
||||
if (string.IsNullOrEmpty(bundleName))
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo bundleInfo))
|
||||
{
|
||||
bundleInfo.PackAsset(assetInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildBundleInfo newBundleInfo = new BuildBundleInfo(bundleName);
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源包
|
||||
/// </summary>
|
||||
public bool IsContainsBundle(string bundleName)
|
||||
{
|
||||
return _bundleInfoDic.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包信息,如果没找到返回NULL
|
||||
/// </summary>
|
||||
public BuildBundleInfo GetBundleInfo(string bundleName)
|
||||
{
|
||||
if (_bundleInfoDic.TryGetValue(bundleName, out BuildBundleInfo result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建着色器信息类
|
||||
/// </summary>
|
||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||
{
|
||||
if (IsContainsBundle(shadersBundleName) == false)
|
||||
{
|
||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/BuildMapContext.cs.meta
Normal file
11
Editor/AssetBundleBuilder/BuildMapContext.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8229aa3f8a369204db5c368715191e2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
197
Editor/AssetBundleBuilder/BuildParameters.cs
Normal file
197
Editor/AssetBundleBuilder/BuildParameters.cs
Normal file
@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public abstract class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建输出的根目录
|
||||
/// </summary>
|
||||
public string BuildOutputRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的根目录
|
||||
/// </summary>
|
||||
public string BuildinFileRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 构建管线名称
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建资源包类型
|
||||
/// </summary>
|
||||
public int BuildBundleType;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的平台
|
||||
/// </summary>
|
||||
public BuildTarget BuildTarget;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹版本
|
||||
/// </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;
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称样式
|
||||
/// </summary>
|
||||
public EFileNameStyle FileNameStyle;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝选项
|
||||
/// </summary>
|
||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
||||
|
||||
/// <summary>
|
||||
/// 内置文件的拷贝参数
|
||||
/// </summary>
|
||||
public string BuildinFileCopyParams;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包加密服务类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _packageRootDirectory = string.Empty;
|
||||
private string _buildinRootDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public virtual void CheckBuildParameters()
|
||||
{
|
||||
// 检测当前是否正在构建资源包
|
||||
if (UnityEditor.BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 检测构建参数合法性
|
||||
if (BuildTarget == BuildTarget.NoTarget)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageName))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 设置默认备注信息
|
||||
if (string.IsNullOrEmpty(PackageNote))
|
||||
{
|
||||
PackageNote = DateTime.Now.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string GetPipelineOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||
{
|
||||
_pipelineOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{YooAssetSettings.OutputFolderName}";
|
||||
}
|
||||
return _pipelineOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageOutputDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||
{
|
||||
_packageOutputDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}/{PackageVersion}";
|
||||
}
|
||||
return _packageOutputDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public virtual string GetPackageRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageRootDirectory))
|
||||
{
|
||||
_packageRootDirectory = $"{BuildOutputRoot}/{BuildTarget}/{PackageName}";
|
||||
}
|
||||
return _packageRootDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public virtual string GetBuildinRootDirectory()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||
{
|
||||
_buildinRootDirectory = $"{BuildinFileRoot}/{PackageName}";
|
||||
}
|
||||
return _buildinRootDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/BuildParameters.cs.meta
Normal file
11
Editor/AssetBundleBuilder/BuildParameters.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98bb314dc26ba184fbb9e9fdcdb58a1d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Editor/AssetBundleBuilder/BuildParametersContext.cs
Normal file
63
Editor/AssetBundleBuilder/BuildParametersContext.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildParametersContext : IContextObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
Parameters = parameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测构建参数是否合法
|
||||
/// </summary>
|
||||
public void CheckBuildParameters()
|
||||
{
|
||||
Parameters.CheckBuildParameters();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建管线的输出目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetPipelineOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPipelineOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁输出目录
|
||||
/// </summary>
|
||||
public string GetPackageOutputDirectory()
|
||||
{
|
||||
return Parameters.GetPackageOutputDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本次构建的补丁根目录
|
||||
/// </summary>
|
||||
public string GetPackageRootDirectory()
|
||||
{
|
||||
return Parameters.GetPackageRootDirectory();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置资源的根目录
|
||||
/// </summary>
|
||||
public string GetBuildinRootDirectory()
|
||||
{
|
||||
return Parameters.GetBuildinRootDirectory();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Editor/AssetBundleBuilder/BuildParametersContext.cs.meta
Normal file
11
Editor/AssetBundleBuilder/BuildParametersContext.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b84510feab7cbe44a9b6d8ef0b3f559c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/AssetBundleBuilder/BuildPipeline.meta
Normal file
8
Editor/AssetBundleBuilder/BuildPipeline.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 431722e1bca52d448825f603789d7e4b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Editor/AssetBundleBuilder/BuildPipeline/BaseTasks.meta
Normal file
8
Editor/AssetBundleBuilder/BuildPipeline/BaseTasks.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 254f430e0264bd84387878f8d7280e44
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
internal void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PackageManifest manifest)
|
||||
{
|
||||
EBuildinFileCopyOption copyOption = buildParametersContext.Parameters.BuildinFileCopyOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
|
||||
// 清空内置文件的目录
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.ClearAndCopyByTags)
|
||||
{
|
||||
EditorTools.ClearFolder(buildinRootDirectory);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{fileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyAll || copyOption == EBuildinFileCopyOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (copyOption == EBuildinFileCopyOption.ClearAndCopyByTags || copyOption == EBuildinFileCopyOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.BuildinFileCopyParams.Split(';');
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{buildinRootDirectory}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c77e17c3a3a57548a218f1cd26f5a55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,268 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ManifestContext : IContextObject
|
||||
{
|
||||
internal PackageManifest Manifest;
|
||||
}
|
||||
|
||||
public abstract class TaskCreateManifest
|
||||
{
|
||||
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(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;
|
||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
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.PackageNote = buildParameters.PackageNote;
|
||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||
|
||||
// 处理资源清单的ID数据
|
||||
ProcessPacakgeIDs(manifest);
|
||||
|
||||
// 处理资源包的依赖列表
|
||||
if (processBundleDepends)
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
if (processBundleTags)
|
||||
ProcessBundleTags(manifest);
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToJson(filePath, manifest);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, packageHash);
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <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> CreatePackageAssetList(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var assetInfos = bundleInfo.GetAllManifestAssetInfos();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
PackageAsset packageAsset = new PackageAsset();
|
||||
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
|
||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
|
||||
// 按照AssetPath排序
|
||||
result.Sort((a, b) => a.AssetPath.CompareTo(b.AssetPath));
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源包列表
|
||||
/// </summary>
|
||||
private List<PackageBundle> CreatePackageBundleList(BuildMapContext buildMapContext)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
var packageBundle = bundleInfo.CreatePackageBundle();
|
||||
result.Add(packageBundle);
|
||||
}
|
||||
|
||||
// 按照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 = manifest.BundleList[index].BundleName;
|
||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||
}
|
||||
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
string bundleName = packageAsset.BundleNameInEditor;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源包的依赖集合
|
||||
/// </summary>
|
||||
private void ProcessBundleDepends(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
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 = GetCachedBundleIndexID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源包的标签集合
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
if (packageBundle.DependIDs != null)
|
||||
{
|
||||
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.TryGetValue(index, out var value))
|
||||
{
|
||||
packageBundle.Tags = value.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:SBP构建管线会自动剔除一些冗余资源的引用关系,导致游离资源包没有被任何主资源包引用。
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CacheBundleTags(int bundleID, string[] assetTags)
|
||||
{
|
||||
if (_cacheBundleTags.ContainsKey(bundleID) == false)
|
||||
_cacheBundleTags.Add(bundleID, new HashSet<string>());
|
||||
|
||||
foreach (var assetTag in assetTags)
|
||||
{
|
||||
if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
|
||||
_cacheBundleTags[bundleID].Add(assetTag);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存的资源包的索引ID
|
||||
/// </summary>
|
||||
private int GetCachedBundleIndexID(string bundleName)
|
||||
{
|
||||
if (_cachedBundleIndexIDs.TryGetValue(bundleName, out int value) == false)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found bundle index ID : {bundleName}");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 566c37f5a59f2e84397a9527981a7310
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport
|
||||
{
|
||||
protected void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext)
|
||||
{
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
PackageManifest manifest = manifestContext.Manifest;
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildBundleType = buildParameters.BuildBundleType;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||
|
||||
// 收集器配置
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||
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))
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||
{
|
||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||
buildReport.Summary.DisableWriteTypeTree = false;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||
}
|
||||
|
||||
// 构建结果
|
||||
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
|
||||
buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest);
|
||||
buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest);
|
||||
buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest);
|
||||
}
|
||||
|
||||
// 资源对象列表
|
||||
buildReport.AssetInfos = new List<ReportAssetInfo>(manifest.AssetList.Count);
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainBundle = manifest.BundleList[packageAsset.BundleID];
|
||||
ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
|
||||
reportAssetInfo.Address = packageAsset.Address;
|
||||
reportAssetInfo.AssetPath = packageAsset.AssetPath;
|
||||
reportAssetInfo.AssetTags = packageAsset.AssetTags;
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
|
||||
// 资源包列表
|
||||
buildReport.BundleInfos = new List<ReportBundleInfo>(manifest.BundleList.Count);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
ReportBundleInfo reportBundleInfo = new ReportBundleInfo();
|
||||
reportBundleInfo.BundleName = packageBundle.BundleName;
|
||||
reportBundleInfo.FileName = packageBundle.FileName;
|
||||
reportBundleInfo.FileHash = packageBundle.FileHash;
|
||||
reportBundleInfo.FileCRC = packageBundle.FileCRC;
|
||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||
reportBundleInfo.Tags = packageBundle.Tags;
|
||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
// 其它资源列表
|
||||
buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
|
||||
|
||||
// 序列化文件
|
||||
string fileName = YooAssetSettingsData.GetBuildReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildLogger.Log($"Create build report file: {filePath}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
dependBundles.Sort();
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
{
|
||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
}
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源
|
||||
/// </summary>
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
private int GetMainAssetCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.AssetList.Count;
|
||||
}
|
||||
private int GetAllBundleCount(PackageManifest manifest)
|
||||
{
|
||||
return manifest.BundleList.Count;
|
||||
}
|
||||
private long GetAllBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
private int GetEncryptedBundleCount(PackageManifest manifest)
|
||||
{
|
||||
int fileCount = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileCount++;
|
||||
}
|
||||
return fileCount;
|
||||
}
|
||||
private long GetEncryptedBundleSize(PackageManifest manifest)
|
||||
{
|
||||
long fileBytes = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
if (packageBundle.Encrypted)
|
||||
fileBytes += packageBundle.FileSize;
|
||||
}
|
||||
return fileBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd12814185b4c7044b0afd59f9c1c948
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption
|
||||
{
|
||||
/// <summary>
|
||||
/// 加密文件
|
||||
/// </summary>
|
||||
public void EncryptingBundleFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
var encryptionServices = buildParametersContext.Parameters.EncryptionServices;
|
||||
if (encryptionServices == null)
|
||||
return;
|
||||
|
||||
if (encryptionServices.GetType() == typeof(EncryptionNone))
|
||||
return;
|
||||
|
||||
int progressValue = 0;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FileLoadPath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
if (encryptResult.Encrypted)
|
||||
{
|
||||
string filePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}.encrypt";
|
||||
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
|
||||
bundleInfo.EncryptedFilePath = filePath;
|
||||
bundleInfo.Encrypted = true;
|
||||
BuildLogger.Log($"Bundle file encryption complete: {filePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
bundleInfo.Encrypted = false;
|
||||
}
|
||||
|
||||
// 进度条
|
||||
EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c78d471226b9c8d429a2d962370f480b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成资源构建上下文
|
||||
/// </summary>
|
||||
public BuildMapContext CreateBuildMap(bool simulateBuild, BuildParameters buildParameters)
|
||||
{
|
||||
BuildMapContext context = new BuildMapContext();
|
||||
var packageName = buildParameters.PackageName;
|
||||
|
||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||
|
||||
// 1. 获取所有收集器收集的资源
|
||||
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, useAssetDependencyDB, packageName);
|
||||
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
RemoveZeroReferenceAssets(context, allCollectAssets);
|
||||
|
||||
// 3. 录入所有收集器主动收集的资源
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetInfo.AssetPath))
|
||||
{
|
||||
throw new Exception($"Should never get here !");
|
||||
}
|
||||
|
||||
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
|
||||
{
|
||||
if (collectAssetInfo.AssetTags.Count > 0)
|
||||
{
|
||||
collectAssetInfo.AssetTags.Clear();
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetInfo.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
|
||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetInfo);
|
||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||
allBuildAssetInfos.Add(collectAssetInfo.AssetInfo.AssetPath, buildAssetInfo);
|
||||
}
|
||||
|
||||
// 4. 录入所有收集资源依赖的其它资源
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
string bundleName = collectAssetInfo.BundleName;
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out var value))
|
||||
{
|
||||
value.AddReferenceBundleName(bundleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
var buildAssetInfo = new BuildAssetInfo(dependAsset);
|
||||
buildAssetInfo.AddReferenceBundleName(bundleName);
|
||||
allBuildAssetInfos.Add(dependAsset.AssetPath, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 填充所有收集资源的依赖列表
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||
foreach (var dependAsset in collectAssetInfo.DependAssets)
|
||||
{
|
||||
if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out BuildAssetInfo value))
|
||||
dependAssetInfos.Add(value);
|
||||
else
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
allBuildAssetInfos[collectAssetInfo.AssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
|
||||
// 6. 自动收集所有依赖的着色器
|
||||
if (collectResult.Command.AutoCollectShaders)
|
||||
{
|
||||
// 获取着色器打包规则结果
|
||||
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
string shaderBundleName = shaderPackRuleResult.GetBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||
{
|
||||
if (buildAssetInfo.AssetInfo.IsShaderAsset())
|
||||
{
|
||||
buildAssetInfo.SetBundleName(shaderBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 7. 计算共享资源的包名
|
||||
if (buildParameters.EnableSharePackRule)
|
||||
{
|
||||
PreProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||
if (packRuleResult.IsValid())
|
||||
{
|
||||
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
buildAssetInfo.SetBundleName(shareBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
PostProcessPackShareBundle();
|
||||
}
|
||||
|
||||
// 8. 记录关键信息
|
||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||
context.Command = collectResult.Command;
|
||||
|
||||
// 9. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
removeBuildList.Add(buildAssetInfo);
|
||||
}
|
||||
foreach (var removeValue in removeBuildList)
|
||||
{
|
||||
allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
|
||||
}
|
||||
|
||||
// 10. 构建资源列表
|
||||
var allPackAssets = allBuildAssetInfos.Values.ToList();
|
||||
if (allPackAssets.Count == 0)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
foreach (var assetInfo in allPackAssets)
|
||||
{
|
||||
context.PackAsset(assetInfo);
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
private void RemoveZeroReferenceAssets(BuildMapContext context, List<CollectAssetInfo> allCollectAssets)
|
||||
{
|
||||
// 1. 检测依赖资源收集器是否存在
|
||||
if (allCollectAssets.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
|
||||
return;
|
||||
|
||||
// 2. 获取所有主资源的依赖资源集合
|
||||
HashSet<string> allDependAsset = new HashSet<string>();
|
||||
foreach (var collectAsset in allCollectAssets)
|
||||
{
|
||||
var collectorType = collectAsset.CollectorType;
|
||||
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
foreach (var dependAsset in collectAsset.DependAssets)
|
||||
{
|
||||
if (allDependAsset.Contains(dependAsset.AssetPath) == false)
|
||||
allDependAsset.Add(dependAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 找出所有零引用的依赖资源集合
|
||||
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
var collectorType = collectAssetInfo.CollectorType;
|
||||
if (collectorType == ECollectorType.DependAssetCollector)
|
||||
{
|
||||
if (allDependAsset.Contains(collectAssetInfo.AssetInfo.AssetPath) == false)
|
||||
removeList.Add(collectAssetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. 移除所有零引用的依赖资源
|
||||
foreach (var removeValue in removeList)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}");
|
||||
BuildLogger.Warning(warning);
|
||||
|
||||
var independAsset = new ReportIndependAsset();
|
||||
independAsset.AssetPath = removeValue.AssetInfo.AssetPath;
|
||||
independAsset.AssetGUID = removeValue.AssetInfo.AssetGUID;
|
||||
independAsset.AssetType = removeValue.AssetInfo.AssetType.ToString();
|
||||
independAsset.FileSize = FileUtility.GetFileSize(removeValue.AssetInfo.AssetPath);
|
||||
context.IndependAssets.Add(independAsset);
|
||||
|
||||
allCollectAssets.Remove(removeValue);
|
||||
}
|
||||
}
|
||||
|
||||
#region 共享资源打包规则
|
||||
/// <summary>
|
||||
/// 共享资源打包前置处理
|
||||
/// </summary>
|
||||
protected virtual void PreProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 共享资源打包后置处理
|
||||
/// </summary>
|
||||
protected virtual void PostProcessPackShareBundle()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取共享资源包名称
|
||||
/// </summary>
|
||||
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baee18c5c7b76584b90413bf20fdae9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public abstract class TaskUpdateBundleInfo
|
||||
{
|
||||
public void UpdateBundleInfo(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
int outputNameStyle = (int)buildParametersContext.Parameters.FileNameStyle;
|
||||
|
||||
// 1.检测文件名长度
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
// NOTE:检测文件名长度不要超过260字符。
|
||||
string fileName = bundleInfo.BundleName;
|
||||
if (fileName.Length >= 260)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 2.更新构建输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
if (bundleInfo.Encrypted)
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.EncryptedFilePath;
|
||||
else
|
||||
bundleInfo.PackageSourceFilePath = bundleInfo.BuildOutputFilePath;
|
||||
}
|
||||
|
||||
// 3.更新文件其它信息
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||
}
|
||||
|
||||
// 4.更新补丁包输出的文件路径
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string bundleName = bundleInfo.BundleName;
|
||||
string fileHash = bundleInfo.PackageFileHash;
|
||||
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4882f54fbf0bcb04680fb581deae4889
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c0a1b7e213a63047994bbf419867c64
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 950b38743cf6b74419af76ab327206ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskBuilding_BBP : IBuildTask
|
||||
{
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public AssetBundleManifest UnityManifest;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 检测输出目录
|
||||
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success !");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.UnityManifest = unityManifest;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d10c8f8b9937fe848b2cb0cc0836280d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80c30fb9eb35a514daadefa4a2fb4f28
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(true, true, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
if (_buildResultContext == null)
|
||||
_buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
|
||||
return _buildResultContext.UnityManifest.GetAllDependencies(bundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db8a306d84a7b284f9acc8925cfaf812
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreatePackage_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
CreatePackagePatch(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝UnityManifest序列化文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝UnityManifest文本文件
|
||||
{
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
string destPath = $"{packageOutputDirectory}/{YooAssetSettings.OutputFolderName}.manifest";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 509e58fe0b061a54795f60209fbbbb5a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb66f3d5c56a85643a0e009d59079e54
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,13 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskEncryption_BBP : 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: 6e871faedf2401c4c9225eb9815c5aa0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b621fbca3fe162448bda8c817daa101a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
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
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||
BuildLogger.Warning(warning);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dc94501197179048b85b6e959c50e9c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
|
||||
if (hash.isValid)
|
||||
{
|
||||
return hash.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.BuildOutputFilePath;
|
||||
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
|
||||
{
|
||||
return crc;
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26a84c5ae3c1a344883de3f85d48c952
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskVerifyBuildResult_BBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
|
||||
// 验证构建结果
|
||||
if (buildParameters.VerifyBuildingResult)
|
||||
{
|
||||
var buildResultContext = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
|
||||
VerifyingBuildingResult(context, buildResultContext.UnityManifest);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
string[] unityBuildContent = unityManifest.GetAllAssetBundles();
|
||||
|
||||
// 1. 计划内容
|
||||
string[] planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||
|
||||
// 2. 验证差异
|
||||
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||
if (exceptBundleList1.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList1)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
// 3. 验证差异
|
||||
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||
if (exceptBundleList2.Count > 0)
|
||||
{
|
||||
foreach (var exceptBundle in exceptBundleList2)
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
|
||||
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||
throw new Exception(exception);
|
||||
}
|
||||
|
||||
BuildLogger.Log("Build results verify success!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b883ac0c3c25e8143847a9326e2961cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuiltinBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
/// </summary>
|
||||
public BuildAssetBundleOptions GetBundleBuildOptions()
|
||||
{
|
||||
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
|
||||
// 除非设置ForceRebuildAssetBundle标记,否则会进行增量打包
|
||||
|
||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||
|
||||
if (CompressOption == ECompressOption.Uncompressed)
|
||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||
else if (CompressOption == ECompressOption.LZ4)
|
||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||
|
||||
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).
|
||||
if (IgnoreTypeTreeChanges)
|
||||
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
|
||||
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
|
||||
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
|
||||
|
||||
return opt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd05d8038cf42e54e974483bb5da4198
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuiltinBuildPipeline : IBuildPipeline
|
||||
{
|
||||
public BuildResult Run(BuildParameters buildParameters, bool 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>
|
||||
/// 获取默认的构建流程
|
||||
/// </summary>
|
||||
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||
{
|
||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||
{
|
||||
new TaskPrepare_BBP(),
|
||||
new TaskGetBuildMap_BBP(),
|
||||
new TaskBuilding_BBP(),
|
||||
new TaskVerifyBuildResult_BBP(),
|
||||
new TaskEncryption_BBP(),
|
||||
new TaskUpdateBundleInfo_BBP(),
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62d7756143e561843800bc521b5e090f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12f78ad22f0513c44b6037469dbd6363
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1138888cdba447345abb498b0c89affa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 120e126cc10604c4f811c3b6377f7452
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 789c337b5b82f1c438a588982dfca346
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abbe56a7120e34349b10f20956ed51a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 990b41f647b80a34ab666a3b0c1ba3f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a5f30f9c58f36946b2028bddce08c9c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 141f7d1ebdf7cc147801aa711e29ac17
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskBuilding_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝原生文件
|
||||
/// </summary>
|
||||
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
{
|
||||
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3625d4b8b5b79324ebf7ec19a87677e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf10a5495e90b844b8aca1eadf7ed8f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, true, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86bdc7d5ae31fdd409f9dc68d73e2600
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreatePackage_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
CreatePackagePatch(buildParameters, buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝补丁文件到补丁包目录
|
||||
/// </summary>
|
||||
private void CreatePackagePatch(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
||||
{
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
|
||||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
int fileTotalCount = buildMapContext.Collection.Count;
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
|
||||
EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6d813044f843b944b4ec3d6f562c7e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55595ba60c30a634d8921cfc6524e201
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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:
|
||||
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||
context.SetContextObject(buildMapContext);
|
||||
|
||||
// 检测构建结果
|
||||
CheckBuildMapContent(buildMapContext);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测资源构建上下文
|
||||
/// </summary>
|
||||
private void CheckBuildMapContent(BuildMapContext buildMapContext)
|
||||
{
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (bundleInfo.MainAssets.Count != 1)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8bdb5b4ee29e5b48a88689c6519b830
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskPrepare_RFBP : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
|
||||
// 删除包裹目录
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97204fd262bb58449a87e517318905c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
UpdateBundleInfo(context);
|
||||
}
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2c8ae6a3e6ca3b4bba4e1495ea297d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user