Compare commits

...

105 Commits
1.0.8 ... 1.2.0

Author SHA1 Message Date
hevinci
e340af90ed Update CHANGELOG.md 2022-07-18 12:17:21 +08:00
hevinci
7fa7cc4af1 Update package.json 2022-07-18 12:17:02 +08:00
hevinci
ca3c011f34 Update AssetBundleBuilder
增加配置保存按钮。
2022-07-18 12:05:40 +08:00
hevinci
669339d5b4 Update AssetBundleCollector
增加配置保存按钮。
2022-07-18 12:04:46 +08:00
hevinci
c6567650fe Update Update document 2022-07-18 11:25:09 +08:00
hevinci
3ae70412fa Update AssetBundleBuilder 2022-07-18 11:24:47 +08:00
hevinci
d575850f9f Update package.json 2022-07-15 19:47:33 +08:00
hevinci
d1439da54e Update AssetBundleBuilder
支持可编程构建管线
2022-07-15 19:34:59 +08:00
何冠峰
89022d3df4 Merge pull request #24 from LiuOcean/main
Update UniTask.YooAsset README
2022-07-13 17:03:39 +08:00
L
3c38fe6155 Update UniTask.YooAsset README 2022-07-13 15:29:23 +08:00
hevinci
e68ece6925 Update AssetBundleBuilder 2022-07-13 11:59:15 +08:00
hevinci
ea9b8874cc Update decryption services
解密服务接口增加解密文件信息。
2022-07-13 10:48:49 +08:00
hevinci
475efd90fc Update FAQ.md 2022-07-13 10:33:21 +08:00
hevinci
682605d5c2 Update document 2022-07-12 16:06:44 +08:00
hevinci
256844ddf5 Update AssetBundleCollector
打包资源忽略Gizmos资源文件。
2022-07-12 15:38:26 +08:00
何冠峰
96f95bbd99 Merge pull request #21 from axn777/branch_share_ignore
如果依赖的是运行时以外的,不打入 share AssetBundle包
2022-07-12 15:00:56 +08:00
何冠峰
4f7bb945e0 Merge pull request #22 from wqaetly/ForPr
fix:修复ShaderVariantCollection刷新不及时问题
2022-07-12 14:54:26 +08:00
NKG丶MadLife
0d69d779f6 fix:修复ShaderVariantCollection刷新不及时问题 2022-07-10 22:12:09 +08:00
axn777
5df26908fb 如果依赖的是运行时以外的,不打入 share AssetBundle包 2022-07-08 01:41:20 +08:00
hevinci
fb5e289de0 Update patch system
优化代码逻辑结构
2022-07-07 19:10:44 +08:00
hevinci
b238759f61 Update CHANGELOG.md 2022-07-07 10:13:39 +08:00
hevinci
2bb0d18891 Update package.json 2022-07-07 10:13:20 +08:00
hevinci
7d5b6504f4 Update YooAssets.cs
检测原生文件加载方法,预防传入无效文件。
2022-07-05 20:07:32 +08:00
何冠峰
63f90e1537 Merge pull request #19 from LiuOcean/main
Fix Unity 2020 IL2Cpp UniTask Bug
2022-07-02 15:28:12 +08:00
何冠峰
65b43feb38 Merge pull request #18 from Y-way/typo
拼写错误
2022-07-02 15:27:59 +08:00
L
4f00a19344 Fix Unity 2020 IL2Cpp UniTask Bug 2022-07-02 12:33:59 +08:00
hevinci
3bfca7d340 Update AssetBundleBuilder 2022-06-30 14:29:27 +08:00
Y-way
8538d0de28 拼写错误 2022-06-30 14:09:07 +08:00
hevinci
5425e17d6f Update AssetOperationHandle.cs 2022-06-30 12:12:44 +08:00
何冠峰
bb3065d08d Merge pull request #17 from Y-way/OptimizeAssetOperationHandle
AssetOperationHandle类新增便捷方法,便于链式编程
2022-06-30 12:03:57 +08:00
hevinci
1adc3d7ed6 Update document 2022-06-30 12:02:06 +08:00
hevinci
556b23b488 Update OperationHandleBase.cs 2022-06-29 12:41:06 +08:00
hevinci
5b0c189d75 Update InitializationOperation.cs 2022-06-29 11:59:39 +08:00
hevinci
161fdff09a Update document 2022-06-29 10:02:57 +08:00
hevinci
81b3dd57b1 Update document 2022-06-28 20:23:03 +08:00
hevinci
1ab0f447d2 Update document 2022-06-28 20:20:36 +08:00
hevinci
9ac07e94d1 Update UpdateManifestOperation
增加在弱联网环境下的更新支持
2022-06-28 20:13:32 +08:00
Y-way
fee6e8f4dd 增加失败提示 2022-06-28 19:45:37 +08:00
Y-way
1e39b1af6d AssetOperationHandle类新增便捷方法,便于链式编程
TextAsset asset;
                YooAssets.LoadAssetAsync<TextAsset>(name).WaitForAsyncOperationComplete().GetAssetObjet<TextAsset>(out asset).Release();
                YooAssets.LoadAssetAsync<TextAsset>(name).Completed += handler => {
                    handler.GetAssetObjet(out asset).Release();
                };
2022-06-28 19:17:47 +08:00
hevinci
727d841d47 Update document 2022-06-28 17:18:43 +08:00
hevinci
5e0d4d6ee1 Update document 2022-06-27 14:03:14 +08:00
hevinci
32ce99949b Update AssetBundleDebugger
完善调试器窗口,增加帧数控制。
2022-06-25 17:56:49 +08:00
hevinci
fbb9bff3c7 Remove AutoReleaseGameObjectHandle param.
移除自动释放资源对象句柄的功能。
2022-06-25 12:09:20 +08:00
hevinci
6471b237ce Update Patch System
离线模式移除资内置资源解压功能。
2022-06-25 11:42:50 +08:00
hevinci
d452c610c1 Update document 2022-06-25 11:41:13 +08:00
hevinci
009fa88402 Update document 2022-06-25 10:59:51 +08:00
hevinci
6d26276352 Update AssetBundleDebuggerWindow.cs
修复了AssetView和BundleView切换失败的问题。
2022-06-24 17:03:27 +08:00
hevinci
bdca693413 Update CHANGELOG.md 2022-06-23 21:48:09 +08:00
hevinci
a2d30ca99a Update package.json 2022-06-23 21:44:32 +08:00
hevinci
5c02bc2bee Update AssetBundleCollector
增加分组禁用功能。
2022-06-23 20:41:32 +08:00
何冠峰
00ffd55fef Merge pull request #15 from JourneyHans/main
编辑器模式下打包执行成功后自动显示Bundle文件夹
2022-06-23 16:08:11 +08:00
hevinci
32148821a1 Add AutoReleaseGameObjectHandle initialize parameters
支持自动释放游戏对象句柄的功能。
2022-06-23 16:02:53 +08:00
hevinci
60f6483a86 Update AssetBundleCollector window
修复StaticAssetCollector无法预览Main Assets列表的问题。
2022-06-23 14:07:12 +08:00
hevinci
9b80300f19 Update DefaultFilterRule.cs 2022-06-23 13:58:47 +08:00
hevinci
8f02bfa3a6 Update DefaultFilterRule.cs
修复了精灵过滤器无效的问题。
2022-06-23 13:46:31 +08:00
huanghanzhi
93607ad62a 编辑器模式下打包执行成功后自动显示Bundle文件夹 2022-06-22 15:50:56 +08:00
hevinci
3cbf891674 Add GetAssetPath method.
增加YooAssets.GetAssetPath方法
2022-06-21 17:21:37 +08:00
hevinci
00688a65af Add VerifyLevel filed.
增加了下载文件校验等级初始化参数。
2022-06-21 16:04:59 +08:00
hevinci
c0099cb90c Update RawFileOperation.cs
优化原生文件加载逻辑
2022-06-21 14:08:02 +08:00
hevinci
43248408fc Update DownloaderOperation.cs
Add OnStartDownloadFileCallback filed.
Change OnDownloadFileFailedCallback to OnDownloadErrorCallback.
2022-06-21 10:40:16 +08:00
hevinci
d535500b9e Update AssetBundleDebugger 2022-06-20 19:56:19 +08:00
hevinci
9cea3e1ba9 Update YooAssets.cs
Add IsInitialized filed
2022-06-20 15:38:55 +08:00
何冠峰
746fa44ab8 Merge pull request #13 from susices/main
修复资源包收集工具页面 切换EnableAddressable时 未及时刷新收集器UI的问题
2022-06-20 10:21:20 +08:00
hevinci
b23d56f49c Update document 2022-06-20 10:19:17 +08:00
hevinci
3693f1ea98 Update AssetInfo.cs
Add Address filed.
2022-06-20 10:18:51 +08:00
susices
14127e8097 Merge branch 'tuyoogame:main' into main 2022-06-18 18:27:28 +08:00
wenchao
ad0d47bd68 修复资源包收集工具页面 切换EnableAddressable时 未及时刷新收集器UI的问题 2022-06-18 18:26:24 +08:00
hevinci
b59fb0d811 Optimize share bundle pack logic
优化了共享资源的打包逻辑。
2022-06-17 12:05:14 +08:00
hevinci
0b1990f040 Yooasset add destroy methods
增加销毁机制
2022-06-15 18:14:04 +08:00
hevinci
8deb239450 Update remote debugger
Support remote mobie device debugging
2022-06-15 16:52:54 +08:00
hevinci
33387e8d26 Update AssetBundleBuilder 2022-06-10 10:50:27 +08:00
hevinci
9d4656a1f2 Update EditorHelper.cs 2022-06-09 16:09:35 +08:00
hevinci
9c49d8d54a Update manifest operation add FoundNewManifest filed.
补丁清单更新操作,增加了查询发现了新的清单的字段。
2022-05-27 15:17:10 +08:00
hevinci
4ee6b3cdc2 Update CHANGELOG.md 2022-05-22 15:14:27 +08:00
hevinci
d5636a71b1 Update package.json 2022-05-22 15:08:45 +08:00
hevinci
b1ca47fc14 Update EditorHelper.cs 2022-05-22 15:03:40 +08:00
hevinci
ddb35620cb Update document 2022-05-22 00:40:15 +08:00
hevinci
a906a84721 Optimized the loading method of the setting file
优化了配置文件的加载方式和途径。
2022-05-22 00:39:22 +08:00
hevinci
d43d30f72f The collector window supports undo operations
资源收集界面支持撤销操作
2022-05-21 23:41:58 +08:00
hevinci
e9841a65c6 Added pause method and resume method to patch downloader
补丁下载器增加暂停方法和恢复方法
2022-05-21 22:36:06 +08:00
hevinci
2dd3ba847e Bundle build system adds builtin files copy options
资源构建增加内置文件拷贝的选项
2022-05-21 22:24:05 +08:00
hevinci
0dcbe0574c Fixed load sprite issues in editor simulate mode
修复加载精灵图片失败的问题在编辑器模拟模式下。
2022-05-16 20:16:10 +08:00
hevinci
d01dce438c Fixed window opening issues
修复了资源收集配置存在多个的时候,导致后续无法打开窗口的问题。
2022-05-16 15:48:23 +08:00
hevinci
76929cc015 Update CHANGELOG.md 2022-05-14 12:47:16 +08:00
hevinci
cde0f4bcd8 Update package.json 2022-05-14 12:47:12 +08:00
hevinci
8dc0560537 Optimized the loading method of the setting file
优化了配置文件的加载方式和途径。
2022-05-13 23:53:19 +08:00
hevinci
a054740de6 Optimize assetbundle build parameters
优化了资源包的构建参数:始终开启DisableLoadAssetByFileName
2022-05-13 21:58:23 +08:00
hevinci
029b850d6b Update asset system
新增获取所有子资源对象的方法。
2022-05-13 14:57:49 +08:00
hevinci
8260653eae Merge branch 'main' of https://github.com/tuyoogame/YooAsset 2022-05-13 14:29:36 +08:00
hevinci
bd7b9b5c44 Update README.md 2022-05-13 14:29:28 +08:00
hevinci
8f33a391f8 Update document 2022-05-13 14:29:22 +08:00
何冠峰
2f9d3a9f11 Merge pull request #11 from jiangguilong2000/main
feat(AssetSystem): 获取图集下所有的精灵对象集合
2022-05-13 14:23:23 +08:00
Allen Jiang
316294f449 feat(AssetSystem): 获取图集下所有的精灵对象集合 2022-05-13 14:08:36 +08:00
hevinci
09fac3bd64 Add warning when asset path is invalid. 2022-05-12 23:13:21 +08:00
hevinci
2da81212b4 Update document 2022-05-12 12:37:48 +08:00
hevinci
4cad587609 Optimized asset system and patch system framework
优化了资源定位不正确导致的错误报告方式。
YooAssets.ProcessOperation()重命名为YooAssets.StartOperation()
YooAssets.GetBundleInfo()已经移除方法。
YooAssets.IsNeedDownloadFromRemote()新增加方法。
2022-05-11 16:48:17 +08:00
hevinci
67eeae31c7 Update patch manifest
更新资源清单:资源对象增加分类标签。
2022-05-11 16:23:31 +08:00
hevinci
ae465a47a9 Simulate build use default build version.
模拟构建模式使用一个默认的资源版本号。
2022-05-11 16:13:51 +08:00
hevinci
23b59f6ad6 Update document 2022-05-09 22:14:49 +08:00
hevinci
09e3483e0a Update README.md 2022-05-09 22:13:20 +08:00
hevinci
b3f4e9ae6e Update document 2022-05-09 22:13:14 +08:00
hevinci
79efe6237d Update asset system 2022-05-09 21:18:15 +08:00
hevinci
bf0f479234 Update download system 2022-05-09 18:44:49 +08:00
hevinci
ece1dab28b Update README.md 2022-05-08 22:21:17 +08:00
hevinci
b913b5c20c Update document 2022-05-08 22:21:13 +08:00
151 changed files with 4009 additions and 1638 deletions

View File

@@ -71,7 +71,7 @@ namespace Cysharp.Threading.Tasks
result.completed = false; result.completed = false;
TaskTracker.TrackActiveTask(result, 3); TaskTracker.TrackActiveTask(result, 3);
if(progress is not null) if(progress != null)
{ {
PlayerLoopHelper.AddAction(timing, result); PlayerLoopHelper.AddAction(timing, result);
} }

View File

@@ -1,7 +1,13 @@
#if UNITY_2020_1_OR_NEWER && ! UNITY_2021
#define UNITY_2020_BUG
#endif
using System; using System;
using System.Runtime.CompilerServices;
using YooAsset; using YooAsset;
using static Cysharp.Threading.Tasks.Internal.Error; using static Cysharp.Threading.Tasks.Internal.Error;
namespace Cysharp.Threading.Tasks namespace Cysharp.Threading.Tasks
{ {
public static class OperationHandleBaseExtensions public static class OperationHandleBaseExtensions
@@ -71,11 +77,29 @@ namespace Cysharp.Threading.Tasks
result.completed = false; result.completed = false;
TaskTracker.TrackActiveTask(result, 3); TaskTracker.TrackActiveTask(result, 3);
if(progress is not null) if(progress != null)
{ {
PlayerLoopHelper.AddAction(timing, result); PlayerLoopHelper.AddAction(timing, result);
} }
// BUG 在 Unity 2020.3.36 版本测试中, IL2Cpp 会报 如下错误
// BUG ArgumentException: Incompatible Delegate Types. First is System.Action`1[[YooAsset.AssetOperationHandle, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] second is System.Action`1[[YooAsset.OperationHandleBase, YooAsset, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]
// BUG 也可能报的是 Action '1' Action '1' 的 InvalidCastException
// BUG 此处不得不这么修改, 如果后续 Unity 修复了这个问题, 可以恢复之前的写法
#if UNITY_2020_BUG
switch(handle)
{
case AssetOperationHandle asset_handle:
asset_handle.Completed += result.AssetContinuation;
break;
case SceneOperationHandle scene_handle:
scene_handle.Completed += result.SceneContinuation;
break;
case SubAssetsOperationHandle sub_asset_handle:
sub_asset_handle.Completed += result.SubContinuation;
break;
}
#else
switch(handle) switch(handle)
{ {
case AssetOperationHandle asset_handle: case AssetOperationHandle asset_handle:
@@ -88,11 +112,50 @@ namespace Cysharp.Threading.Tasks
sub_asset_handle.Completed += result.continuationAction; sub_asset_handle.Completed += result.continuationAction;
break; break;
} }
#endif
token = result.core.Version; token = result.core.Version;
return result; return result;
} }
#if UNITY_2020_BUG
private void AssetContinuation(AssetOperationHandle handle)
{
handle.Completed -= AssetContinuation;
BaseContinuation();
}
private void SceneContinuation(SceneOperationHandle handle)
{
handle.Completed -= SceneContinuation;
BaseContinuation();
}
private void SubContinuation(SubAssetsOperationHandle handle)
{
handle.Completed -= SubContinuation;
BaseContinuation();
}
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void BaseContinuation()
{
if(completed)
{
TryReturn();
}
else
{
completed = true;
if(handle.Status == EOperationStatus.Failed)
{
core.TrySetException(new Exception(handle.LastError));
}
else
{
core.TrySetResult(AsyncUnit.Default);
}
}
}
private void Continuation(OperationHandleBase _) private void Continuation(OperationHandleBase _)
{ {
@@ -109,22 +172,7 @@ namespace Cysharp.Threading.Tasks
break; break;
} }
if(completed) BaseContinuation();
{
TryReturn();
}
else
{
completed = true;
if(handle.Status == EOperationStatus.Failed)
{
core.TrySetException(new Exception(handle.LastError));
}
else
{
core.TrySetResult(AsyncUnit.Default);
}
}
} }
bool TryReturn() bool TryReturn()

View File

@@ -2,6 +2,7 @@
[仓库链接](https://github.com/Cysharp/UniTask) [仓库链接](https://github.com/Cysharp/UniTask)
- 请去下载对应的源码,并删除此目录最后的波浪线 - 请去下载对应的源码,并删除此目录最后的波浪线
- 在项目的 `asmdef` 文件中添加对 `UniTask.YooAsset` 的引用
- 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用 - 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用
## 代码示例 ## 代码示例

View File

@@ -2,6 +2,176 @@
All notable changes to this package will be documented in this file. All notable changes to this package will be documented in this file.
## [1.2.0] - 2022-07-18
### Fixed
- 修复了ShaderVariantCollection刷新不及时问题。
### Changed
- 资源收集忽略了Gizmos资源文件。
- 解密服务接口增加解密文件信息参数。
- 资源收集窗体增加配置保存按钮。
- 资源构建窗体增加配置保存按钮。
### Added
- 资源构建模块增加了可编程构建管线(SBP)的支持,开发者可以在内置构建管线和可编程构建管线之间自由选择,零修改成本。
## [1.1.1] - 2022-07-07
### Fixed
- 修复了AssetBundleDebugger窗口View下拉页签切换无效的问题。
- 修复了在Unity2020.3版本下UniTask在真机上的一个IL2CPP相关的错误。
### Changed
- 优化了AssetBundleDebugger窗口增加了帧数显示以及回放功能。
- 优化了AssetBundleBuilder的代码结构。
- 增强了YooAssets.GetRawFileAsync()方法的容错。
### Added
- 新增了OperationHandleBase.GetAssetInfo()方法。
````c#
/// <summary>
/// 获取资源信息
/// </summary>
public AssetInfo GetAssetInfo();
````
- 新增了AssetOperationHandle.GetAssetObjet<TAsset>()方法。
````c#
/// <summary>
/// 获取资源对象
/// </summary>
/// <typeparam name="TAsset">资源类型</typeparam>
public TAsset GetAssetObjet<TAsset>()
````
- 新增了弱联网情况下加载补丁清单方法。
````c#
/// <summary>
/// 弱联网情况下加载补丁清单
/// 注意:当指定版本内容验证失败后会返回失败。
/// </summary>
/// <param name="resourceVersion">指定的资源版本</param>
public static UpdateManifestOperation WeaklyUpdateManifestAsync(int resourceVersion)
````
### Removed
- 离线运行模式OfflinePlayMode下移除了资内置资源解压相关逻辑。
- 移除了初始化参数AutoReleaseGameObjectHandle及相关代码逻辑。
## [1.1.0] - 2022-06-23
### Fixed
- 修复了AssetBundleCollector窗口在切换EnableAddressable时未及时刷新界面的问题。
- 修复了AssetBundleCollector窗口资源过滤器CollectSprite无效的问题。
- 修复了AssetBundleCollector窗口无法正常预览StaticAssetCollector的资源列表的问题。
- 修复了在离线模式下原生文件每次都从包内加载的问题。
### Changed
- 变更了共享资源打包机制。
- AssetBundleCollector窗口增加了分组禁用功能。
- AssetBundleDebugger窗口增加了真机远程调试功能。
- AssetBundleBuilder窗口在构建成功后自动显示构建文件夹。
- DownloaderOperation.OnDownloadFileFailedCallback委托变更为OnDownloadErrorCallback委托。
### Added
- 新增UpdateManifestOperation.FoundNewManifest字段。
- 新增DownloaderOperation.OnStartDownloadFileCallback委托。
- 新增AssetInfo.Address字段。
- 新增YooAssets.IsInitialized字段。
- 新增YooAssets初始化参数。
````c#
/// <summary>
/// 下载文件校验等级
/// </summary>
public EVerifyLevel VerifyLevel = EVerifyLevel.High;
````
- 新增YooAssets获取资源完成路径的方法。
````c#
/// <summary>
/// 获取资源路径
/// </summary>
/// <param name="location">资源的定位地址</param>
/// <returns>如果location地址无效则返回空字符串</returns>
public static string GetAssetPath(string location);
````
- 新增YooAssets初始化参数。
```c#
/// <summary>
/// 自动释放游戏对象所属资源句柄
/// 说明:通过资源句柄实例化的游戏对象在销毁之后,会自动释放所属资源句柄。
/// </summary>
public bool AutoReleaseGameObjectHandle = false;
```
## [1.0.10] - 2022-05-22
### Fixed
- 修复了资源收集配置存在多个的时候,导致后续无法打开窗口的问题。
- 修复了在编辑器模拟模式下加载精灵图片失败的问题。
- 修复了在Unity2019版本无法识别配置文件的问题。
### Changed
- 资源构建增加内置资源文件(首包资源文件)拷贝的选项。
- 补丁下载器增加暂停方法和恢复方法。
- 在资源收集界面对Collector的增加和删除支持撤销和恢复操作。
## [1.0.9] - 2022-05-14
### Fixed
- 修复了YooAssets.GetAssetInfos(string Tag)方法返回了无关的资源信息的问题。
### Changed
- 编辑器下的模拟运行模式,不再依赖配置里的构建版本。
- 更新资源清单结构,资源对象类增加分类标签。
- 优化了资源工具相关配置文件的加载方式和途径,这些配置文件可以放置在任何目录下。
- 优化了Location无效后的错误报告方式。
- 优化了资源包的构建参数现在始终开启DisableLoadAssetByFileName帮助减小运行时的内存。
- YooAssets.ProcessOperation()重命名为YooAssets.StartOperation()
### Added
- 新增YooAssets.IsNeedDownloadFromRemote()方法。
````c#
public static bool IsNeedDownloadFromRemote(string location);
````
- 新增获取所有子资源对象的方法。
````c#
class SubAssetsOperationHandle
{
public TObject[] GetSubAssetObjects<TObject>();
}
````
### Removed
- YooAssets.GetBundleInfo()方法已经移除。
## [1.0.8] - 2022-05-08 ## [1.0.8] - 2022-05-08
### Fixed ### Fixed

View File

@@ -8,102 +8,6 @@ namespace YooAsset.Editor
{ {
public class AssetBundleBuilder public class AssetBundleBuilder
{ {
public class BuildParametersContext : IContextObject
{
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
/// <summary>
/// 构建参数
/// </summary>
public BuildParameters Parameters { private set; get; }
/// <summary>
/// 构建管线的输出目录
/// </summary>
public string PipelineOutputDirectory { private set; get; }
public BuildParametersContext(BuildParameters parameters)
{
Parameters = parameters;
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
if (parameters.BuildMode == EBuildMode.DryRunBuild)
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
else if(parameters.BuildMode == EBuildMode.SimulateBuild)
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
}
/// <summary>
/// 获取本次构建的补丁目录
/// </summary>
public string GetPackageDirectory()
{
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
}
/// <summary>
/// 获取构建选项
/// </summary>
public BuildAssetBundleOptions GetPipelineBuildOptions()
{
// 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 (Parameters.BuildMode == EBuildMode.SimulateBuild)
{
throw new Exception("Should never get here !");
}
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
{
opt |= BuildAssetBundleOptions.DryRunBuild;
return opt;
}
if (Parameters.CompressOption == ECompressOption.Uncompressed)
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
else if (Parameters.CompressOption == ECompressOption.LZ4)
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
if (Parameters.AppendHash)
opt |= BuildAssetBundleOptions.AppendHashToAssetBundleName; //Append the hash to the assetBundle name
if (Parameters.DisableWriteTypeTree)
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
if (Parameters.IgnoreTypeTreeChanges)
opt |= BuildAssetBundleOptions.IgnoreTypeTreeChanges; //Ignore the type tree changes when doing the incremental build check.
if (Parameters.DisableLoadAssetByFileName)
{
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileName; //Disables Asset Bundle LoadAsset by file name.
opt |= BuildAssetBundleOptions.DisableLoadAssetByFileNameWithExtension; //Disables Asset Bundle LoadAsset by file name with extension.
}
return opt;
}
/// <summary>
/// 获取构建的耗时(单位:秒)
/// </summary>
public float GetBuildingSeconds()
{
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
return seconds;
}
public void BeginWatch()
{
_buildWatch.Start();
}
public void StopWatch()
{
_buildWatch.Stop();
}
}
private readonly BuildContext _buildContext = new BuildContext(); private readonly BuildContext _buildContext = new BuildContext();
/// <summary> /// <summary>
@@ -114,29 +18,65 @@ namespace YooAsset.Editor
// 清空旧数据 // 清空旧数据
_buildContext.ClearAllContext(); _buildContext.ClearAllContext();
// 检测构建参数是否为空
if (buildParameters == null)
{
throw new Exception($"{nameof(buildParameters)} is null !");
}
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
if (buildParameters.SBPParameters == null)
throw new Exception($"{nameof(BuildParameters.SBPParameters)} is null !");
}
// 构建参数 // 构建参数
var buildParametersContext = new BuildParametersContext(buildParameters); var buildParametersContext = new BuildParametersContext(buildParameters);
_buildContext.SetContextObject(buildParametersContext); _buildContext.SetContextObject(buildParametersContext);
// 执行构建流程 // 是否显示LOG
List<IBuildTask> pipeline = new List<IBuildTask>
{
new TaskPrepare(), //前期准备工作
new TaskGetBuildMap(), //获取构建列表
new TaskBuilding(), //开始执行构建
new TaskVerifyBuildResult(), //验证构建结果
new TaskEncryption(), //加密资源文件
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
if (buildParameters.BuildMode == EBuildMode.SimulateBuild) if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
BuildRunner.EnableLog = false; BuildRunner.EnableLog = false;
else else
BuildRunner.EnableLog = true; BuildRunner.EnableLog = true;
// 创建构建节点
List<IBuildTask> pipeline;
if (buildParameters.BuildPipeline == EBuildPipeline.BuiltinBuildPipeline)
{
pipeline = new List<IBuildTask>
{
new TaskPrepare(), //前期准备工作
new TaskGetBuildMap(), //获取构建列表
new TaskBuilding(), //开始执行构建
new TaskVerifyBuildResult(), //验证构建结果
new TaskEncryption(), //加密资源文件
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
}
else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
pipeline = new List<IBuildTask>
{
new TaskPrepare(), //前期准备工作
new TaskGetBuildMap(), //获取构建列表
new TaskBuilding_SBP(), //开始执行构建
new TaskVerifyBuildResult_SBP(), //验证构建结果
new TaskEncryption(), //加密资源文件
new TaskCreatePatchManifest(), //创建清单文件
new TaskCreateReport(), //创建报告文件
new TaskCreatePatchPackage(), //制作补丁包
new TaskCopyBuildinFiles(), //拷贝内置文件
};
}
else
{
throw new NotImplementedException();
}
// 执行构建流程
bool succeed = BuildRunner.Run(pipeline, _buildContext); bool succeed = BuildRunner.Run(pipeline, _buildContext);
if (succeed) if (succeed)
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !"); Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");

View File

@@ -10,13 +10,18 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public int BuildVersion = 0; public int BuildVersion = 0;
/// <summary>
/// 构建管线
/// </summary>
public EBuildPipeline BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
/// <summary> /// <summary>
/// 构建模式 /// 构建模式
/// </summary> /// </summary>
public EBuildMode BuildMode = EBuildMode.ForceRebuild; public EBuildMode BuildMode = EBuildMode.ForceRebuild;
/// <summary> /// <summary>
/// 内置资源标签 /// 内置资源标签(首包资源标签)
/// </summary> /// </summary>
public string BuildTags = string.Empty; public string BuildTags = string.Empty;

View File

@@ -19,27 +19,17 @@ namespace YooAsset.Editor
} }
} }
/// <summary>
/// 配置数据是否被修改
/// </summary>
public static bool IsDirty { set; get; } = false;
/// <summary> /// <summary>
/// 加载配置文件 /// 加载配置文件
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = EditorHelper.LoadSettingData<AssetBundleBuilderSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleBuilderSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleBuilderSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(AssetBundleBuilderSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<AssetBundleBuilderSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(AssetBundleBuilderSetting)}.asset ok");
}
} }
/// <summary> /// <summary>
@@ -49,6 +39,7 @@ namespace YooAsset.Editor
{ {
if (Setting != null) if (Setting != null)
{ {
IsDirty = false;
EditorUtility.SetDirty(Setting); EditorUtility.SetDirty(Setting);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!"); Debug.Log($"{nameof(AssetBundleBuilderSetting)}.asset is saved!");

View File

@@ -22,32 +22,37 @@ namespace YooAsset.Editor
private List<Type> _encryptionServicesClassTypes; private List<Type> _encryptionServicesClassTypes;
private List<string> _encryptionServicesClassNames; private List<string> _encryptionServicesClassNames;
private Button _saveButton;
private TextField _buildOutputField; private TextField _buildOutputField;
private IntegerField _buildVersionField; private IntegerField _buildVersionField;
private EnumField _buildPipelineField;
private EnumField _buildModeField; private EnumField _buildModeField;
private TextField _buildTagsField; private TextField _buildinTagsField;
private PopupField<string> _encryptionField; private PopupField<string> _encryptionField;
private EnumField _compressionField; private EnumField _compressionField;
private Toggle _appendExtensionToggle; private Toggle _appendExtensionToggle;
public void CreateGUI() public void CreateGUI()
{ {
VisualElement root = this.rootVisualElement;
// 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath();
string uxml = $"{rootPath}/Editor/AssetBundleBuilder/{nameof(AssetBundleBuilderWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null)
{
Debug.LogError($"Not found {nameof(AssetBundleBuilderWindow)}.uxml : {uxml}");
return;
}
visualAsset.CloneTree(root);
try try
{ {
VisualElement root = this.rootVisualElement;
// 加载布局文件
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleBuilderWindow>();
if (visualAsset == null)
return;
visualAsset.CloneTree(root);
// 配置保存按钮
_saveButton = root.Q<Button>("SaveButton");
_saveButton.clicked += SaveBtn_clicked;
// 构建平台
_buildTarget = EditorUserBuildSettings.activeBuildTarget; _buildTarget = EditorUserBuildSettings.activeBuildTarget;
// 加密服务类
_encryptionServicesClassTypes = GetEncryptionServicesClassTypes(); _encryptionServicesClassTypes = GetEncryptionServicesClassTypes();
_encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList(); _encryptionServicesClassNames = _encryptionServicesClassTypes.Select(t => t.FullName).ToList();
@@ -63,9 +68,22 @@ namespace YooAsset.Editor
_buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion); _buildVersionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildVersion);
_buildVersionField.RegisterValueChangedCallback(evt => _buildVersionField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value; AssetBundleBuilderSettingData.Setting.BuildVersion = _buildVersionField.value;
}); });
// 构建管线
_buildPipelineField = root.Q<EnumField>("BuildPipeline");
_buildPipelineField.Init(AssetBundleBuilderSettingData.Setting.BuildPipeline);
_buildPipelineField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildPipeline);
_buildPipelineField.style.width = 300;
_buildPipelineField.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.BuildPipeline = (EBuildPipeline)_buildPipelineField.value;
RefreshWindow();
});
// 构建模式 // 构建模式
_buildModeField = root.Q<EnumField>("BuildMode"); _buildModeField = root.Q<EnumField>("BuildMode");
_buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode); _buildModeField.Init(AssetBundleBuilderSettingData.Setting.BuildMode);
@@ -73,16 +91,18 @@ namespace YooAsset.Editor
_buildModeField.style.width = 300; _buildModeField.style.width = 300;
_buildModeField.RegisterValueChangedCallback(evt => _buildModeField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value; AssetBundleBuilderSettingData.Setting.BuildMode = (EBuildMode)_buildModeField.value;
RefreshWindow(); RefreshWindow();
}); });
// 内置资源标签 // 内置资源标签
_buildTagsField = root.Q<TextField>("BuildinTags"); _buildinTagsField = root.Q<TextField>("BuildinTags");
_buildTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags); _buildinTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.BuildTags);
_buildTagsField.RegisterValueChangedCallback(evt => _buildinTagsField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.Setting.BuildTags = _buildTagsField.value; AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.BuildTags = _buildinTagsField.value;
}); });
// 加密方法 // 加密方法
@@ -95,6 +115,7 @@ namespace YooAsset.Editor
_encryptionField.style.width = 300; _encryptionField.style.width = 300;
_encryptionField.RegisterValueChangedCallback(evt => _encryptionField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value; AssetBundleBuilderSettingData.Setting.EncyptionClassName = _encryptionField.value;
}); });
encryptionContainer.Add(_encryptionField); encryptionContainer.Add(_encryptionField);
@@ -114,6 +135,7 @@ namespace YooAsset.Editor
_compressionField.style.width = 300; _compressionField.style.width = 300;
_compressionField.RegisterValueChangedCallback(evt => _compressionField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value; AssetBundleBuilderSettingData.Setting.CompressOption = (ECompressOption)_compressionField.value;
}); });
@@ -122,6 +144,7 @@ namespace YooAsset.Editor
_appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension); _appendExtensionToggle.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.AppendExtension);
_appendExtensionToggle.RegisterValueChangedCallback(evt => _appendExtensionToggle.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSettingData.IsDirty = true;
AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value; AssetBundleBuilderSettingData.Setting.AppendExtension = _appendExtensionToggle.value;
}); });
@@ -138,17 +161,39 @@ namespace YooAsset.Editor
} }
public void OnDestroy() public void OnDestroy()
{ {
AssetBundleBuilderSettingData.SaveFile(); if(AssetBundleBuilderSettingData.IsDirty)
AssetBundleBuilderSettingData.SaveFile();
}
public void Update()
{
if(_saveButton != null)
{
if(AssetBundleBuilderSettingData.IsDirty)
{
if (_saveButton.enabledSelf == false)
_saveButton.SetEnabled(true);
}
else
{
if(_saveButton.enabledSelf)
_saveButton.SetEnabled(false);
}
}
} }
private void RefreshWindow() private void RefreshWindow()
{ {
bool enableElement = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild; var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
_buildTagsField.SetEnabled(enableElement); bool enableElement = buildMode == EBuildMode.ForceRebuild;
_buildinTagsField.SetEnabled(enableElement);
_encryptionField.SetEnabled(enableElement); _encryptionField.SetEnabled(enableElement);
_compressionField.SetEnabled(enableElement); _compressionField.SetEnabled(enableElement);
_appendExtensionToggle.SetEnabled(enableElement); _appendExtensionToggle.SetEnabled(enableElement);
} }
private void SaveBtn_clicked()
{
AssetBundleBuilderSettingData.SaveFile();
}
private void BuildButton_clicked() private void BuildButton_clicked()
{ {
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode; var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
@@ -172,17 +217,29 @@ namespace YooAsset.Editor
BuildParameters buildParameters = new BuildParameters(); BuildParameters buildParameters = new BuildParameters();
buildParameters.OutputRoot = defaultOutputRoot; buildParameters.OutputRoot = defaultOutputRoot;
buildParameters.BuildTarget = _buildTarget; buildParameters.BuildTarget = _buildTarget;
buildParameters.BuildMode = (EBuildMode)_buildModeField.value; buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
buildParameters.BuildVersion = _buildVersionField.value; buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
buildParameters.BuildinTags = _buildTagsField.value; buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion;
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
buildParameters.VerifyBuildingResult = true; buildParameters.VerifyBuildingResult = true;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable; buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
buildParameters.AppendFileExtension = _appendExtensionToggle.value; buildParameters.AppendFileExtension = AssetBundleBuilderSettingData.Setting.AppendExtension;
buildParameters.CopyBuildinTagFiles = AssetBundleBuilderSettingData.Setting.BuildMode == EBuildMode.ForceRebuild;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.CompressOption = (ECompressOption)_compressionField.value; buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
AssetBundleBuilder builder = new AssetBundleBuilder(); if (AssetBundleBuilderSettingData.Setting.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
builder.Run(buildParameters); {
buildParameters.SBPParameters = new BuildParameters.SBPBuildParameters();
buildParameters.SBPParameters.WriteLinkXML = true;
}
var builder = new AssetBundleBuilder();
bool succeed = builder.Run(buildParameters);
if (succeed)
{
EditorUtility.RevealInFinder($"{buildParameters.OutputRoot}/{buildParameters.BuildTarget}/{buildParameters.BuildVersion}");
}
} }
// 加密类相关 // 加密类相关

View File

@@ -1,8 +1,11 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex;" /> <uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="background-color: rgb(56, 147, 58);" />
</uie:Toolbar>
<ui:VisualElement name="BuildContainer"> <ui:VisualElement name="BuildContainer">
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" /> <ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
<uie:IntegerField label="Build Version" value="0" name="BuildVersion" /> <uie:IntegerField label="Build Version" value="0" name="BuildVersion" />
<uie:EnumField label="Build Pipeline" name="BuildPipeline" />
<uie:EnumField label="Build Mode" name="BuildMode" /> <uie:EnumField label="Build Mode" name="BuildMode" />
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" /> <ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
<uie:EnumField label="Compression" value="Center" name="Compression" /> <uie:EnumField label="Compression" value="Center" name="Compression" />

View File

@@ -16,8 +16,7 @@ namespace YooAsset.Editor
buildParameters.OutputRoot = defaultOutputRoot; buildParameters.OutputRoot = defaultOutputRoot;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget; buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.BuildMode = EBuildMode.SimulateBuild; buildParameters.BuildMode = EBuildMode.SimulateBuild;
buildParameters.BuildVersion = AssetBundleBuilderSettingData.Setting.BuildVersion; buildParameters.BuildVersion = 999;
buildParameters.BuildinTags = AssetBundleBuilderSettingData.Setting.BuildTags;
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable; buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
AssetBundleBuilder builder = new AssetBundleBuilder(); AssetBundleBuilder builder = new AssetBundleBuilder();

View File

@@ -9,6 +9,7 @@ namespace YooAsset.Editor
{ {
private string _mainBundleName; private string _mainBundleName;
private string _shareBundleName; private string _shareBundleName;
private bool _isAddAssetTags = false;
private readonly HashSet<string> _referenceBundleNames = new HashSet<string>(); private readonly HashSet<string> _referenceBundleNames = new HashSet<string>();
/// <summary> /// <summary>
@@ -37,10 +38,15 @@ namespace YooAsset.Editor
public bool IsShaderAsset { private set; get; } public bool IsShaderAsset { private set; get; }
/// <summary> /// <summary>
/// 资源分类标签列表 /// 资源分类标签
/// </summary> /// </summary>
public readonly List<string> AssetTags = new List<string>(); public readonly List<string> AssetTags = new List<string>();
/// <summary>
/// 资源包的分类标签
/// </summary>
public readonly List<string> BundleTags = new List<string>();
/// <summary> /// <summary>
/// 依赖的所有资源 /// 依赖的所有资源
/// 注意:包括零依赖资源和冗余资源(资源包名无效) /// 注意:包括零依赖资源和冗余资源(资源包名无效)
@@ -62,9 +68,9 @@ namespace YooAsset.Editor
else else
IsShaderAsset = false; IsShaderAsset = false;
} }
public BuildAssetInfo(ECollectorType collectorType, string assetPath) public BuildAssetInfo(string assetPath)
{ {
CollectorType = collectorType; CollectorType = ECollectorType.None;
Address = string.Empty; Address = string.Empty;
AssetPath = assetPath; AssetPath = assetPath;
IsRawAsset = false; IsRawAsset = false;
@@ -89,10 +95,15 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 添加资源分类标签 /// 添加资源分类标签
/// 说明:原始定义的资源分类标签
/// </summary> /// </summary>
public void AddAssetTags(List<string> tags) public void AddAssetTags(List<string> tags)
{ {
if (_isAddAssetTags)
throw new Exception("Should never get here !");
_isAddAssetTags = true;
foreach (var tag in tags) foreach (var tag in tags)
{ {
if (AssetTags.Contains(tag) == false) if (AssetTags.Contains(tag) == false)
@@ -102,6 +113,21 @@ namespace YooAsset.Editor
} }
} }
/// <summary>
/// 添加资源包的分类标签
/// 说明:传染算法统计到的分类标签
/// </summary>
public void AddBundleTags(List<string> tags)
{
foreach (var tag in tags)
{
if (BundleTags.Contains(tag) == false)
{
BundleTags.Add(tag);
}
}
}
/// <summary> /// <summary>
/// 资源包名是否存在 /// 资源包名是否存在
/// </summary> /// </summary>
@@ -159,11 +185,9 @@ namespace YooAsset.Editor
if (_referenceBundleNames.Count > 1) if (_referenceBundleNames.Count > 1)
{ {
var bundleNameList = _referenceBundleNames.ToList(); IPackRule packRule = PackDirectory.StaticPackRule;
bundleNameList.Sort(); var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
string combineName = string.Join("|", bundleNameList); var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
var combineNameHash = HashUtility.StringSHA1(combineName);
var shareBundleName = $"share_{combineNameHash}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower(); _shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
} }
} }

View File

@@ -68,14 +68,14 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取资源标签列表 /// 获取资源包的分类标签列表
/// </summary> /// </summary>
public string[] GetAssetTags() public string[] GetBundleTags()
{ {
List<string> result = new List<string>(BuildinAssets.Count); List<string> result = new List<string>(BuildinAssets.Count);
foreach (var assetInfo in BuildinAssets) foreach (var assetInfo in BuildinAssets)
{ {
foreach (var assetTag in assetInfo.AssetTags) foreach (var assetTag in assetInfo.BundleTags)
{ {
if (result.Contains(assetTag) == false) if (result.Contains(assetTag) == false)
result.Add(assetTag); result.Add(assetTag);

View File

@@ -55,13 +55,13 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取AssetBundle内包含的标记列表 /// 获取资源包的分类标签列表
/// </summary> /// </summary>
public string[] GetAssetTags(string bundleName) public string[] GetBundleTags(string bundleName)
{ {
if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo)) if (TryGetBundleInfo(bundleName, out BuildBundleInfo bundleInfo))
{ {
return bundleInfo.GetAssetTags(); return bundleInfo.GetBundleTags();
} }
throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}"); throw new Exception($"Not found {nameof(BuildBundleInfo)} : {bundleName}");
} }

View File

@@ -18,7 +18,7 @@ namespace YooAsset.Editor
// 1. 检测配置合法性 // 1. 检测配置合法性
AssetBundleCollectorSettingData.Setting.CheckConfigError(); AssetBundleCollectorSettingData.Setting.CheckConfigError();
// 2. 获取所有主动收集的资源 // 2. 获取所有收集器收集的资源
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode); List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetAllCollectAssets(buildMode);
// 3. 剔除未被引用的依赖资源 // 3. 剔除未被引用的依赖资源
@@ -36,13 +36,15 @@ namespace YooAsset.Editor
allCollectAssets.Remove(removeValue); allCollectAssets.Remove(removeValue);
} }
// 4. 录入主动收集的资源 // 4. 录入所有收集器收集的资源
foreach (var collectAssetInfo in allCollectAssets) foreach (var collectAssetInfo in allCollectAssets)
{ {
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false) if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
{ {
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset); var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName,
collectAssetInfo.Address, collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset);
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags); buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo); buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
} }
else else
@@ -58,13 +60,13 @@ namespace YooAsset.Editor
{ {
if (buildAssetDic.ContainsKey(dependAssetPath)) if (buildAssetDic.ContainsKey(dependAssetPath))
{ {
buildAssetDic[dependAssetPath].AddAssetTags(collectAssetInfo.AssetTags); buildAssetDic[dependAssetPath].AddBundleTags(collectAssetInfo.AssetTags);
buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName); buildAssetDic[dependAssetPath].AddReferenceBundleName(collectAssetInfo.BundleName);
} }
else else
{ {
var buildAssetInfo = new BuildAssetInfo(ECollectorType.None, dependAssetPath); var buildAssetInfo = new BuildAssetInfo(dependAssetPath);
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags); buildAssetInfo.AddBundleTags(collectAssetInfo.AssetTags);
buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName); buildAssetInfo.AddReferenceBundleName(collectAssetInfo.BundleName);
buildAssetDic.Add(dependAssetPath, buildAssetInfo); buildAssetDic.Add(dependAssetPath, buildAssetInfo);
} }
@@ -92,7 +94,7 @@ namespace YooAsset.Editor
pair.Value.CalculateFullBundleName(); pair.Value.CalculateFullBundleName();
} }
// 8. 移除参与构建的资源 // 8. 移除参与构建的资源
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>(); List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic) foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
{ {

View File

@@ -9,6 +9,23 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public class BuildParameters public class BuildParameters
{ {
/// <summary>
/// SBP构建参数
/// </summary>
public class SBPBuildParameters
{
/// <summary>
/// 生成代码防裁剪配置
/// </summary>
public bool WriteLinkXML = true;
}
/// <summary>
/// 可编程构建管线的参数
/// </summary>
public SBPBuildParameters SBPParameters;
/// <summary> /// <summary>
/// 输出的根目录 /// 输出的根目录
/// </summary> /// </summary>
@@ -19,6 +36,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public BuildTarget BuildTarget; public BuildTarget BuildTarget;
/// <summary>
/// 构建管线
/// </summary>
public EBuildPipeline BuildPipeline;
/// <summary> /// <summary>
/// 构建模式 /// 构建模式
/// </summary> /// </summary>
@@ -30,7 +52,7 @@ namespace YooAsset.Editor
public int BuildVersion; public int BuildVersion;
/// <summary> /// <summary>
/// 内置资源的标记列表 /// 内置资源标签集合(首包资源标签)
/// 注意:分号为分隔符 /// 注意:分号为分隔符
/// </summary> /// </summary>
public string BuildinTags; public string BuildinTags;
@@ -46,17 +68,16 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool EnableAddressable = false; public bool EnableAddressable = false;
/// <summary>
/// 启用自动分包机制
/// 说明:自动分包机制可以实现资源零冗余
/// </summary>
public bool EnableAutoCollect = true;
/// <summary> /// <summary>
/// 追加文件扩展名 /// 追加文件扩展名
/// </summary> /// </summary>
public bool AppendFileExtension = false; public bool AppendFileExtension = false;
/// <summary>
/// 拷贝内置资源文件到StreamingAssets目录首包资源文件
/// </summary>
public bool CopyBuildinTagFiles = false;
/// <summary> /// <summary>
/// 加密类 /// 加密类
@@ -68,11 +89,6 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public ECompressOption CompressOption = ECompressOption.Uncompressed; public ECompressOption CompressOption = ECompressOption.Uncompressed;
/// <summary>
/// 文件名附加上哈希值
/// </summary>
public bool AppendHash = false;
/// <summary> /// <summary>
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率) /// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
/// </summary> /// </summary>
@@ -83,18 +99,15 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool IgnoreTypeTreeChanges = true; public bool IgnoreTypeTreeChanges = true;
/// <summary>
/// 禁用名称查找资源(可以降内存并提高加载效率)
/// </summary>
public bool DisableLoadAssetByFileName = false;
/// <summary> /// <summary>
/// 获取内置标记列表 /// 获取内置资源标签列表(首包资源标签)
/// </summary> /// </summary>
public List<string> GetBuildinTags() public List<string> GetBuildinTags()
{ {
return StringUtility.StringToStringList(BuildinTags, ';'); return StringUtility.StringToStringList(BuildinTags, ';');
} }
} }
} }

View File

@@ -0,0 +1,130 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace YooAsset.Editor
{
public class BuildParametersContext : IContextObject
{
private readonly System.Diagnostics.Stopwatch _buildWatch = new System.Diagnostics.Stopwatch();
/// <summary>
/// 构建参数
/// </summary>
public BuildParameters Parameters { private set; get; }
/// <summary>
/// 构建管线的输出目录
/// </summary>
public string PipelineOutputDirectory { private set; get; }
public BuildParametersContext(BuildParameters parameters)
{
Parameters = parameters;
PipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(parameters.OutputRoot, parameters.BuildTarget);
if (parameters.BuildMode == EBuildMode.DryRunBuild)
PipelineOutputDirectory += $"_{EBuildMode.DryRunBuild}";
else if (parameters.BuildMode == EBuildMode.SimulateBuild)
PipelineOutputDirectory += $"_{EBuildMode.SimulateBuild}";
}
/// <summary>
/// 获取本次构建的补丁目录
/// </summary>
public string GetPackageDirectory()
{
return $"{Parameters.OutputRoot}/{Parameters.BuildTarget}/{Parameters.BuildVersion}";
}
/// <summary>
/// 获取内置构建管线的构建选项
/// </summary>
public BuildAssetBundleOptions GetPipelineBuildOptions()
{
// For the new build system, unity always need BuildAssetBundleOptions.CollectDependencies and BuildAssetBundleOptions.DeterministicAssetBundle
// 除非设置ForceRebuildAssetBundle标记否则会进行增量打包
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
throw new Exception("Should never get here !");
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
{
opt |= BuildAssetBundleOptions.DryRunBuild;
return opt;
}
if (Parameters.CompressOption == ECompressOption.Uncompressed)
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
else if (Parameters.CompressOption == ECompressOption.LZ4)
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
if (Parameters.DisableWriteTypeTree)
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
if (Parameters.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;
}
/// <summary>
/// 获取可编程构建管线的构建参数
/// </summary>
public UnityEditor.Build.Pipeline.BundleBuildParameters GetSBPBuildParameters()
{
if (Parameters.BuildMode == EBuildMode.SimulateBuild)
throw new Exception("Should never get here !");
if (Parameters.BuildMode == EBuildMode.DryRunBuild)
throw new Exception($"SBP not support {nameof(EBuildMode.DryRunBuild)} build mode !");
var targetGroup = BuildPipeline.GetBuildTargetGroup(Parameters.BuildTarget);
var buildParams = new UnityEditor.Build.Pipeline.BundleBuildParameters(Parameters.BuildTarget, targetGroup, PipelineOutputDirectory);
if (Parameters.CompressOption == ECompressOption.Uncompressed)
buildParams.BundleCompression = UnityEngine.BuildCompression.Uncompressed;
else if (Parameters.CompressOption == ECompressOption.LZMA)
buildParams.BundleCompression = UnityEngine.BuildCompression.LZMA;
else if (Parameters.CompressOption == ECompressOption.LZ4)
buildParams.BundleCompression = UnityEngine.BuildCompression.LZ4;
else
throw new System.NotImplementedException(Parameters.CompressOption.ToString());
if (Parameters.BuildMode == EBuildMode.ForceRebuild)
buildParams.UseCache = false;
if (Parameters.DisableWriteTypeTree)
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
buildParams.WriteLinkXML = Parameters.SBPParameters.WriteLinkXML;
return buildParams;
}
/// <summary>
/// 获取构建的耗时(单位:秒)
/// </summary>
public float GetBuildingSeconds()
{
float seconds = _buildWatch.ElapsedMilliseconds / 1000f;
return seconds;
}
public void BeginWatch()
{
_buildWatch.Start();
}
public void StopWatch()
{
_buildWatch.Stop();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b84510feab7cbe44a9b6d8ef0b3f559c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -23,6 +23,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string AssetGUID; public string AssetGUID;
/// <summary>
/// 资源的分类标签
/// </summary>
public string[] AssetTags;
/// <summary> /// <summary>
/// 所属资源包名称 /// 所属资源包名称
/// </summary> /// </summary>

View File

@@ -8,6 +8,11 @@ namespace YooAsset.Editor
[Serializable] [Serializable]
public class ReportSummary public class ReportSummary
{ {
/// <summary>
/// YooAsset版本
/// </summary>
public string YooVersion;
/// <summary> /// <summary>
/// 引擎版本 /// 引擎版本
/// </summary> /// </summary>
@@ -16,7 +21,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 构建时间 /// 构建时间
/// </summary> /// </summary>
public string BuildTime; public string BuildDate;
/// <summary> /// <summary>
/// 构建耗时(单位:秒) /// 构建耗时(单位:秒)
@@ -28,6 +33,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public BuildTarget BuildTarget; public BuildTarget BuildTarget;
/// <summary>
/// 构建管线
/// </summary>
public EBuildPipeline BuildPipeline;
/// <summary> /// <summary>
/// 构建模式 /// 构建模式
/// </summary> /// </summary>
@@ -48,16 +58,16 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool EnableAddressable; public bool EnableAddressable;
/// <summary>
/// 启用自动分包机制
/// </summary>
public bool EnableAutoCollect;
/// <summary> /// <summary>
/// 追加文件扩展名 /// 追加文件扩展名
/// </summary> /// </summary>
public bool AppendFileExtension; public bool AppendFileExtension;
/// <summary>
/// 拷贝内置资源文件
/// </summary>
public bool CopyBuildinTagFiles;
/// <summary> /// <summary>
/// 自动收集着色器 /// 自动收集着色器
/// </summary> /// </summary>
@@ -75,10 +85,8 @@ namespace YooAsset.Editor
// 构建参数 // 构建参数
public ECompressOption CompressOption; public ECompressOption CompressOption;
public bool AppendHash;
public bool DisableWriteTypeTree; public bool DisableWriteTypeTree;
public bool IgnoreTypeTreeChanges; public bool IgnoreTypeTreeChanges;
public bool DisableLoadAssetByFileName;
// 构建结果 // 构建结果
public int AssetFileTotalCount; public int AssetFileTotalCount;

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Linq; using System.Linq;
using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
@@ -18,7 +17,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>(); var buildMapContext = context.GetContextObject<BuildMapContext>();
// 模拟构建模式下跳过引擎构建 // 模拟构建模式下跳过引擎构建
@@ -46,7 +45,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 拷贝原生文件 /// 拷贝原生文件
/// </summary> /// </summary>
private void CopyRawBundle(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParametersContext) private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
{ {
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.BundleInfos)
{ {

View File

@@ -0,0 +1,82 @@
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor
{
[TaskAttribute("资源构建内容打包")]
public class TaskBuilding_SBP : IBuildTask
{
public class SBPBuildResultContext : IContextObject
{
public IBundleBuildResults Results;
}
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
// 模拟构建模式下跳过引擎构建
var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild)
return;
// 构建内容
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
// 开始构建
IBundleBuildResults buildResults;
var buildParameters = buildParametersContext.GetSBPBuildParameters();
var taskList = DefaultBuildTasks.Create(DefaultBuildTasks.Preset.AssetBundleBuiltInShaderExtraction);
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
if (exitCode < 0)
{
throw new Exception($"构建过程中发生错误 : {exitCode}");
}
BuildRunner.Log("Unity引擎打包成功");
SBPBuildResultContext buildResultContext = new SBPBuildResultContext();
buildResultContext.Results = buildResults;
context.SetContextObject(buildResultContext);
// 添加Unity内置资源包信息
if (buildResults.BundleInfos.Keys.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
{
BuildBundleInfo builtInBundleInfo = new BuildBundleInfo(YooAssetSettings.UnityBuiltInShadersBundleName);
buildMapContext.BundleInfos.Add(builtInBundleInfo);
}
// 拷贝原生文件
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{
CopyRawBundle(buildMapContext, buildParametersContext);
}
}
/// <summary>
/// 拷贝原生文件
/// </summary>
private void CopyRawBundle(BuildMapContext buildMapContext, BuildParametersContext buildParametersContext)
{
foreach (var bundleInfo in buildMapContext.BundleInfos)
{
if (bundleInfo.IsRawFile)
{
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
foreach (var buildAsset in bundleInfo.BuildinAssets)
{
if (buildAsset.IsRawAsset)
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1af5fed7e9f83174d868c12b41c4a79e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -12,8 +12,8 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
// 注意:我们只有在强制重建的时候才会拷贝 // 注意:我们只有在强制重建的时候才会拷贝
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
if (buildParameters.Parameters.BuildMode == EBuildMode.ForceRebuild) if (buildParameters.Parameters.CopyBuildinTagFiles)
{ {
// 清空流目录 // 清空流目录
AssetBundleBuilderHelper.ClearStreamingAssetsFolder(); AssetBundleBuilderHelper.ClearStreamingAssetsFolder();

View File

@@ -1,8 +1,11 @@
using System; using System;
using System.IO; using System.Linq;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建补丁清单文件")] [TaskAttribute("创建补丁清单文件")]
@@ -10,18 +13,17 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); CreatePatchManifestFile(context);
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
CreatePatchManifestFile(buildParameters, buildMapContext, encryptionContext);
} }
/// <summary> /// <summary>
/// 创建补丁清单文件到输出目录 /// 创建补丁清单文件到输出目录
/// </summary> /// </summary>
private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters, private void CreatePatchManifestFile(BuildContext context)
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
{ {
var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
var encryptionContext = context.GetContextObject<TaskEncryption.EncryptionContext>();
int resourceVersion = buildParameters.Parameters.BuildVersion; int resourceVersion = buildParameters.Parameters.BuildVersion;
// 创建新补丁清单 // 创建新补丁清单
@@ -32,6 +34,13 @@ namespace YooAsset.Editor
patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext); patchManifest.BundleList = GetAllPatchBundle(buildParameters, buildMapContext, encryptionContext);
patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest); patchManifest.AssetList = GetAllPatchAsset(buildParameters, buildMapContext, patchManifest);
// 更新Unity内置资源包的引用关系
if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.SBPBuildResultContext>();
UpdateBuiltInBundleReference(patchManifest, buildResultContext.Results);
}
// 创建补丁清单文件 // 创建补丁清单文件
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}"; string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}"); BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
@@ -53,14 +62,12 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取资源包列表 /// 获取资源包列表
/// </summary> /// </summary>
private List<PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters, private List<PatchBundle> GetAllPatchBundle(BuildParametersContext buildParameters, BuildMapContext buildMapContext,
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext) TaskEncryption.EncryptionContext encryptionContext)
{ {
List<PatchBundle> result = new List<PatchBundle>(1000); List<PatchBundle> result = new List<PatchBundle>(1000);
// 内置标记列表
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags(); List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild; bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild;
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.BundleInfos)
@@ -70,7 +77,7 @@ namespace YooAsset.Editor
string hash = GetFileHash(filePath, standardBuild); string hash = GetFileHash(filePath, standardBuild);
string crc32 = GetFileCRC(filePath, standardBuild); string crc32 = GetFileCRC(filePath, standardBuild);
long size = GetFileSize(filePath, standardBuild); long size = GetFileSize(filePath, standardBuild);
string[] tags = buildMapContext.GetAssetTags(bundleName); string[] tags = buildMapContext.GetBundleTags(bundleName);
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName); bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
bool isBuildin = IsBuildinBundle(tags, buildinTags); bool isBuildin = IsBuildinBundle(tags, buildinTags);
bool isRawFile = bundleInfo.IsRawFile; bool isRawFile = bundleInfo.IsRawFile;
@@ -90,7 +97,7 @@ namespace YooAsset.Editor
} }
private bool IsBuildinBundle(string[] bundleTags, List<string> buildinTags) private bool IsBuildinBundle(string[] bundleTags, List<string> buildinTags)
{ {
// 注意:没有任何标记的Bundle文件默认为内置文件 // 注意:没有任何分类标签的Bundle文件默认为内置文件
if (bundleTags.Length == 0) if (bundleTags.Length == 0)
return true; return true;
@@ -126,8 +133,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取资源列表 /// 获取资源列表
/// </summary> /// </summary>
private List<PatchAsset> GetAllPatchAsset(AssetBundleBuilder.BuildParametersContext buildParameters, private List<PatchAsset> GetAllPatchAsset(BuildParametersContext buildParameters, BuildMapContext buildMapContext, PatchManifest patchManifest)
BuildMapContext buildMapContext, PatchManifest patchManifest)
{ {
List<PatchAsset> result = new List<PatchAsset>(1000); List<PatchAsset> result = new List<PatchAsset>(1000);
foreach (var bundleInfo in buildMapContext.BundleInfos) foreach (var bundleInfo in buildMapContext.BundleInfos)
@@ -141,6 +147,7 @@ namespace YooAsset.Editor
else else
patchAsset.Address = string.Empty; patchAsset.Address = string.Empty;
patchAsset.AssetPath = assetInfo.AssetPath; patchAsset.AssetPath = assetInfo.AssetPath;
patchAsset.AssetTags = assetInfo.AssetTags.ToArray();
patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest); patchAsset.BundleID = GetAssetBundleID(assetInfo.GetBundleName(), patchManifest);
patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest); patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest);
result.Add(patchAsset); result.Add(patchAsset);
@@ -174,5 +181,45 @@ namespace YooAsset.Editor
} }
throw new Exception($"Not found bundle name : {bundleName}"); throw new Exception($"Not found bundle name : {bundleName}");
} }
/// <summary>
/// 更新Unity内置资源包的引用关系
/// </summary>
private void UpdateBuiltInBundleReference(PatchManifest patchManifest, IBundleBuildResults buildResults)
{
// 获取所有依赖内置资源包的资源包列表
List<string> builtInBundleReferenceList = new List<string>();
foreach (var valuePair in buildResults.BundleInfos)
{
if (valuePair.Value.Dependencies.Any(t => t == YooAssetSettings.UnityBuiltInShadersBundleName))
builtInBundleReferenceList.Add(valuePair.Key);
}
// 检测依赖交集并更新依赖ID
int builtInBundleId = patchManifest.BundleList.Count - 1;
foreach (var patchAsset in patchManifest.AssetList)
{
List<string> dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset);
List<string> conflictAssetPathList = dependBundles.Intersect(builtInBundleReferenceList).ToList();
if (conflictAssetPathList.Count > 0)
{
List<int> newDependIDs = new List<int>(patchAsset.DependIDs);
newDependIDs.Add(builtInBundleId);
patchAsset.DependIDs = newDependIDs.ToArray();
}
}
}
private List<string> GetPatchAssetAllDependBundles(PatchManifest patchManifest, PatchAsset patchAsset)
{
List<string> result = new List<string>();
string mainBundle = patchManifest.BundleList[patchAsset.BundleID].BundleName;
result.Add(mainBundle);
foreach (var dependID in patchAsset.DependIDs)
{
string dependBundle = patchManifest.BundleList[dependID].BundleName;
result.Add(dependBundle);
}
return result;
}
} }
} }

View File

@@ -8,7 +8,7 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{ {
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 拷贝补丁文件到补丁包目录 /// 拷贝补丁文件到补丁包目录
/// </summary> /// </summary>
private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters) private void CopyPatchFiles(BuildParametersContext buildParameters)
{ {
int resourceVersion = buildParameters.Parameters.BuildVersion; int resourceVersion = buildParameters.Parameters.BuildVersion;
string packageDirectory = buildParameters.GetPackageDirectory(); string packageDirectory = buildParameters.GetPackageDirectory();
@@ -54,18 +54,38 @@ namespace YooAsset.Editor
EditorTools.CopyFile(sourcePath, destPath, true); EditorTools.CopyFile(sourcePath, destPath, true);
} }
// 拷贝UnityManifest序列化文件 if (buildParameters.Parameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
{ {
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}"; // 拷贝构建日志
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}"; {
EditorTools.CopyFile(sourcePath, destPath, true); string sourcePath = $"{buildParameters.PipelineOutputDirectory}/buildlogtep.json";
} string destPath = $"{packageDirectory}/buildlogtep.json";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 拷贝UnityManifest文本文件 // 拷贝代码防裁剪配置
if (buildParameters.Parameters.SBPParameters.WriteLinkXML)
{
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/link.xml";
string destPath = $"{packageDirectory}/link.xml";
EditorTools.CopyFile(sourcePath, destPath, true);
}
}
else
{ {
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest"; // 拷贝UnityManifest序列化文件
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest"; {
EditorTools.CopyFile(sourcePath, destPath, true); string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}";
EditorTools.CopyFile(sourcePath, destPath, true);
}
// 拷贝UnityManifest文本文件
{
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.UnityManifestFileName}.manifest";
EditorTools.CopyFile(sourcePath, destPath, true);
}
} }
// 拷贝所有补丁文件 // 拷贝所有补丁文件

View File

@@ -10,7 +10,7 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>(); var buildMapContext = context.GetContextObject<BuildMapContext>();
buildParameters.StopWatch(); buildParameters.StopWatch();
@@ -26,23 +26,29 @@ namespace YooAsset.Editor
} }
} }
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext) private void CreateReportFile(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
{ {
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion); PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
BuildReport buildReport = new BuildReport(); 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.UnityVersion = UnityEngine.Application.unityVersion;
buildReport.Summary.BuildTime = DateTime.Now.ToString(); buildReport.Summary.BuildDate = DateTime.Now.ToString();
buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds(); buildReport.Summary.BuildSeconds = (int)buildParameters.GetBuildingSeconds();
buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget; buildReport.Summary.BuildTarget = buildParameters.Parameters.BuildTarget;
buildReport.Summary.BuildPipeline = buildParameters.Parameters.BuildPipeline;
buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode; buildReport.Summary.BuildMode = buildParameters.Parameters.BuildMode;
buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion; buildReport.Summary.BuildVersion = buildParameters.Parameters.BuildVersion;
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags; buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable; buildReport.Summary.EnableAddressable = buildParameters.Parameters.EnableAddressable;
buildReport.Summary.EnableAutoCollect = buildParameters.Parameters.EnableAutoCollect;
buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension; buildReport.Summary.AppendFileExtension = buildParameters.Parameters.AppendFileExtension;
buildReport.Summary.CopyBuildinTagFiles = buildParameters.Parameters.CopyBuildinTagFiles;
buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders; buildReport.Summary.AutoCollectShaders = AssetBundleCollectorSettingData.Setting.AutoCollectShaders;
buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName; buildReport.Summary.ShadersBundleName = AssetBundleCollectorSettingData.Setting.ShadersBundleName;
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ? buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
@@ -50,10 +56,8 @@ namespace YooAsset.Editor
// 构建参数 // 构建参数
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption; buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
buildReport.Summary.AppendHash = buildParameters.Parameters.AppendHash;
buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree; buildReport.Summary.DisableWriteTypeTree = buildParameters.Parameters.DisableWriteTypeTree;
buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges; buildReport.Summary.IgnoreTypeTreeChanges = buildParameters.Parameters.IgnoreTypeTreeChanges;
buildReport.Summary.DisableLoadAssetByFileName = buildParameters.Parameters.DisableLoadAssetByFileName;
// 构建结果 // 构建结果
buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount; buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount;
@@ -75,6 +79,7 @@ namespace YooAsset.Editor
ReportAssetInfo reportAssetInfo = new ReportAssetInfo(); ReportAssetInfo reportAssetInfo = new ReportAssetInfo();
reportAssetInfo.Address = patchAsset.Address; reportAssetInfo.Address = patchAsset.Address;
reportAssetInfo.AssetPath = patchAsset.AssetPath; reportAssetInfo.AssetPath = patchAsset.AssetPath;
reportAssetInfo.AssetTags = patchAsset.AssetTags;
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath); reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath);
reportAssetInfo.MainBundleName = mainBundle.BundleName; reportAssetInfo.MainBundleName = mainBundle.BundleName;
reportAssetInfo.MainBundleSize = mainBundle.SizeBytes; reportAssetInfo.MainBundleSize = mainBundle.SizeBytes;

View File

@@ -24,7 +24,7 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>(); var buildMapContext = context.GetContextObject<BuildMapContext>();
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
@@ -45,7 +45,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 加密文件 /// 加密文件
/// </summary> /// </summary>
private List<string> EncryptFiles(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext) private List<string> EncryptFiles(BuildParametersContext buildParameters, BuildMapContext buildMapContext)
{ {
var encryptionServices = buildParameters.Parameters.EncryptionServices; var encryptionServices = buildParameters.Parameters.EncryptionServices;

View File

@@ -12,7 +12,7 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode); var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode);
context.SetContextObject(buildMapContext); context.SetContextObject(buildMapContext);
BuildRunner.Log("构建内容准备完毕!"); BuildRunner.Log("构建内容准备完毕!");

View File

@@ -11,7 +11,7 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
buildParameters.BeginWatch(); buildParameters.BeginWatch();
// 检测构建平台是否合法 // 检测构建平台是否合法
@@ -26,6 +26,17 @@ namespace YooAsset.Editor
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory)) if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
throw new Exception("输出目录不能为空"); throw new Exception("输出目录不能为空");
// 检测当前是否正在构建资源包
if (BuildPipeline.isBuildingPlayer)
throw new Exception("当前正在构建资源包,请结束后再试");
// 检测是否有未保存场景
if (EditorTools.HasDirtyScenes())
throw new Exception("检测到未保存的场景文件");
// 保存改动的资源
AssetDatabase.SaveAssets();
// 增量更新时候的必要检测 // 增量更新时候的必要检测
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.IncrementalBuild) if (buildMode == EBuildMode.IncrementalBuild)

View File

@@ -13,7 +13,7 @@ namespace YooAsset.Editor
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
{ {
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParametersContext = context.GetContextObject<BuildParametersContext>();
// 模拟构建模式下跳过验证 // 模拟构建模式下跳过验证
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild) if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
@@ -32,58 +32,26 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest) private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
{ {
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>(); var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>(); var buildMapContext = context.GetContextObject<BuildMapContext>();
string[] buildedBundles = unityManifest.GetAllAssetBundles(); string[] buildedBundles = unityManifest.GetAllAssetBundles();
// 1. 过滤掉原生Bundle // 1. 过滤掉原生Bundle
List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length); string[] expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToArray();
foreach(var bundleInfo in buildMapContext.BundleInfos)
{
if (bundleInfo.IsRawFile == false)
expectBundles.Add(bundleInfo);
}
// 2. 验证数量 // 2. 验证Bundle
if (buildedBundles.Length != expectBundles.Count) List<string> intersectBundleList = buildedBundles.Except(expectBundles).ToList();
if (intersectBundleList.Count > 0)
{ {
Debug.LogWarning($"构建过程中可能存在无效的资源导致和预期构建的Bundle数量不一致"); foreach (var intersectBundle in intersectBundleList)
}
// 3. 正向验证Bundle
foreach (var bundleName in buildedBundles)
{
if (buildMapContext.IsContainsBundle(bundleName) == false)
{ {
throw new Exception($"Should never get here !"); Debug.LogWarning($"差异资源包: {intersectBundle}");
} }
throw new System.Exception("存在差异资源包!请查看警告信息!");
} }
// 4. 反向验证Bundle // 3. 验证Asset
bool isPass = true; bool isPass = true;
foreach (var expectBundle in expectBundles)
{
bool isMatch = false;
foreach (var buildedBundle in buildedBundles)
{
if (buildedBundle == expectBundle.BundleName)
{
isMatch = true;
break;
}
}
if (isMatch == false)
{
isPass = false;
Debug.LogWarning($"没有找到预期构建的Bundle文件 : {expectBundle.BundleName}");
}
}
if(isPass == false)
{
throw new Exception("构建结果验证没有通过,请参考警告日志!");
}
// 5. 验证Asset
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{ {
@@ -137,7 +105,6 @@ namespace YooAsset.Editor
} }
} }
// 卸载所有加载的Bundle
BuildRunner.Log("构建结果验证成功!"); BuildRunner.Log("构建结果验证成功!");
} }

View File

@@ -0,0 +1,60 @@
using System;
using System.Linq;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor
{
[TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult_SBP : IBuildTask
{
void IBuildTask.Run(BuildContext context)
{
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
// 模拟构建模式下跳过验证
if (buildParametersContext.Parameters.BuildMode == EBuildMode.SimulateBuild)
return;
// 验证构建结果
if (buildParametersContext.Parameters.VerifyBuildingResult)
{
var buildResultContext = context.GetContextObject<TaskBuilding_SBP.SBPBuildResultContext>();
VerifyingBuildingResult(context, buildResultContext.Results);
}
}
/// <summary>
/// 验证构建结果
/// </summary>
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
{
var buildParameters = context.GetContextObject<BuildParametersContext>();
var buildMapContext = context.GetContextObject<BuildMapContext>();
// 1. 移除特定Bundle
List<string> buildedBundles = buildResults.BundleInfos.Keys.ToList();
buildedBundles.Remove(YooAssetSettings.UnityBuiltInShadersBundleName);
// 2. 过滤掉原生Bundle
List<string> expectBundles = buildMapContext.BundleInfos.Where(t => t.IsRawFile == false).Select(t => t.BundleName).ToList();
// 3. 验证Bundle
List<string> intersectBundleList = buildedBundles.Except(expectBundles).ToList();
if (intersectBundleList.Count > 0)
{
foreach (var intersectBundle in intersectBundleList)
{
Debug.LogWarning($"差异资源包: {intersectBundle}");
}
throw new System.Exception("存在差异资源包!请查看警告信息!");
}
BuildRunner.Log("构建结果验证成功!");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 16aa7c2c37209a043b4f33d7854047c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@

namespace YooAsset.Editor
{
/// <summary>
/// 构建管线类型
/// </summary>
public enum EBuildPipeline
{
/// <summary>
/// 传统内置构建管线
/// </summary>
BuiltinBuildPipeline,
/// <summary>
/// 可编程构建管线
/// </summary>
ScriptableBuildPipeline,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e53e56a0f6b01dd4c933249d2bda8d78
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -87,10 +87,10 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(AssetBundleCollectorGroup group) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, AssetBundleCollectorGroup group)
{ {
// 注意:模拟构建模式下只收集主资源 // 注意:模拟构建模式下只收集主资源
if (AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
{ {
if (CollectorType != ECollectorType.MainAssetCollector) if (CollectorType != ECollectorType.MainAssetCollector)
return new List<CollectAssetInfo>(); return new List<CollectAssetInfo>();
@@ -117,7 +117,7 @@ namespace YooAsset.Editor
{ {
if (result.ContainsKey(assetPath) == false) if (result.ContainsKey(assetPath) == false)
{ {
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo); result.Add(assetPath, collectAssetInfo);
} }
else else
@@ -132,7 +132,7 @@ namespace YooAsset.Editor
string assetPath = CollectPath; string assetPath = CollectPath;
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath)) if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
{ {
var collectAssetInfo = CreateCollectAssetInfo(group, assetPath, isRawAsset); var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
result.Add(assetPath, collectAssetInfo); result.Add(assetPath, collectAssetInfo);
} }
else else
@@ -162,19 +162,33 @@ namespace YooAsset.Editor
return result.Values.ToList(); return result.Values.ToList();
} }
private CollectAssetInfo CreateCollectAssetInfo(AssetBundleCollectorGroup group, string assetPath, bool isRawAsset) private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
{ {
string address = GetAddress(group, assetPath); string address = GetAddress(group, assetPath);
string bundleName = GetBundleName(group, assetPath); string bundleName = GetBundleName(group, assetPath);
List<string> assetTags = GetAssetTags(group); List<string> assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset); CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
// 注意:模拟构建模式下不需要收集依赖资源
if (buildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List<string>();
else
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
return collectAssetInfo; return collectAssetInfo;
} }
private bool IsValidateAsset(string assetPath) private bool IsValidateAsset(string assetPath)
{ {
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false) if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
{
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
return false; return false;
}
if (assetPath.Contains("/Gizmos/"))
{
UnityEngine.Debug.LogWarning($"Cannot pack gizmos asset : {assetPath}");
return false;
}
if (AssetDatabase.IsValidFolder(assetPath)) if (AssetDatabase.IsValidFolder(assetPath))
return false; return false;
@@ -242,10 +256,6 @@ namespace YooAsset.Editor
} }
private List<string> GetAllDependencies(string mainAssetPath) private List<string> GetAllDependencies(string mainAssetPath)
{ {
// 注意:模拟构建模式下不需要收集依赖资源
if(AssetBundleCollectorSetting.BuildMode == EBuildMode.SimulateBuild)
return new List<string>();
List<string> result = new List<string>(); List<string> result = new List<string>();
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true); string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
foreach (string assetPath in depends) foreach (string assetPath in depends)

View File

@@ -25,6 +25,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string AssetTags = string.Empty; public string AssetTags = string.Empty;
/// <summary>
/// 分组激活规则
/// </summary>
public string ActiveRuleName = nameof(EnableGroup);
/// <summary> /// <summary>
/// 分组的收集器列表 /// 分组的收集器列表
/// </summary> /// </summary>
@@ -36,6 +41,9 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void CheckConfigError() public void CheckConfigError()
{ {
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
collector.CheckConfigError(); collector.CheckConfigError();
@@ -45,14 +53,21 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取打包收集的资源文件 /// 获取打包收集的资源文件
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets() public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
{ {
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
// 检测分组是否激活
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
if (activeRule.IsActiveGroup() == false)
{
return new List<CollectAssetInfo>();
}
// 收集打包资源 // 收集打包资源
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
var temper = collector.GetAllCollectAssets(this); var temper = collector.GetAllCollectAssets(buildMode, this);
foreach (var assetInfo in temper) foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(assetInfo.AssetPath) == false)

View File

@@ -8,8 +8,6 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorSetting : ScriptableObject public class AssetBundleCollectorSetting : ScriptableObject
{ {
public static EBuildMode BuildMode;
/// <summary> /// <summary>
/// 是否启用可寻址资源定位 /// 是否启用可寻址资源定位
/// </summary> /// </summary>
@@ -47,14 +45,12 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode) public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode)
{ {
BuildMode = buildMode;
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
// 收集打包资源 // 收集打包资源
foreach (var group in Groups) foreach (var group in Groups)
{ {
var temper = group.GetAllCollectAssets(); var temper = group.GetAllCollectAssets(buildMode);
foreach (var assetInfo in temper) foreach (var assetInfo in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(assetInfo.AssetPath) == false)

View File

@@ -9,6 +9,9 @@ namespace YooAsset.Editor
{ {
public class AssetBundleCollectorSettingData public class AssetBundleCollectorSettingData
{ {
private static readonly Dictionary<string, System.Type> _cacheActiveRuleTypes = new Dictionary<string, Type>();
private static readonly Dictionary<string, IActiveRule> _cacheActiveRuleInstance = new Dictionary<string, IActiveRule>();
private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>(); private static readonly Dictionary<string, System.Type> _cacheAddressRuleTypes = new Dictionary<string, System.Type>();
private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>(); private static readonly Dictionary<string, IAddressRule> _cacheAddressRuleInstance = new Dictionary<string, IAddressRule>();
@@ -35,6 +38,18 @@ namespace YooAsset.Editor
} }
} }
public static List<string> GetActiveRuleNames()
{
if (_setting == null)
LoadSettingData();
List<string> names = new List<string>();
foreach (var pair in _cacheActiveRuleTypes)
{
names.Add(pair.Key);
}
return names;
}
public static List<string> GetAddressRuleNames() public static List<string> GetAddressRuleNames()
{ {
if (_setting == null) if (_setting == null)
@@ -71,6 +86,15 @@ namespace YooAsset.Editor
} }
return names; return names;
} }
public static bool HasActiveRuleName(string ruleName)
{
foreach (var pair in _cacheActiveRuleTypes)
{
if (pair.Key == ruleName)
return true;
}
return false;
}
public static bool HasAddressRuleName(string ruleName) public static bool HasAddressRuleName(string ruleName)
{ {
foreach (var pair in _cacheAddressRuleTypes) foreach (var pair in _cacheAddressRuleTypes)
@@ -105,22 +129,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = EditorHelper.LoadSettingData<AssetBundleCollectorSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(AssetBundleCollectorSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<AssetBundleCollectorSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<AssetBundleCollectorSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
}
// IPackRule // IPackRule
{ {
@@ -197,6 +206,29 @@ namespace YooAsset.Editor
_cacheAddressRuleTypes.Add(type.Name, type); _cacheAddressRuleTypes.Add(type.Name, type);
} }
} }
// IActiveRule
{
// 清空缓存集合
_cacheActiveRuleTypes.Clear();
_cacheActiveRuleInstance.Clear();
// 获取所有类型
List<Type> types = new List<Type>(100)
{
typeof(EnableGroup),
typeof(DisableGroup),
};
var customTypes = EditorTools.GetAssignableTypes(typeof(IActiveRule));
types.AddRange(customTypes);
for (int i = 0; i < types.Count; i++)
{
Type type = types[i];
if (_cacheActiveRuleTypes.ContainsKey(type.Name) == false)
_cacheActiveRuleTypes.Add(type.Name, type);
}
}
} }
/// <summary> /// <summary>
@@ -225,6 +257,23 @@ namespace YooAsset.Editor
} }
// 实例类相关 // 实例类相关
public static IActiveRule GetActiveRuleInstance(string ruleName)
{
if (_cacheActiveRuleInstance.TryGetValue(ruleName, out IActiveRule instance))
return instance;
// 如果不存在创建类的实例
if (_cacheActiveRuleTypes.TryGetValue(ruleName, out Type type))
{
instance = (IActiveRule)Activator.CreateInstance(type);
_cacheActiveRuleInstance.Add(ruleName, instance);
return instance;
}
else
{
throw new Exception($"{nameof(IActiveRule)}类型无效:{ruleName}");
}
}
public static IAddressRule GetAddressRuleInstance(string ruleName) public static IAddressRule GetAddressRuleInstance(string ruleName)
{ {
if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance)) if (_cacheAddressRuleInstance.TryGetValue(ruleName, out IAddressRule instance))

View File

@@ -18,12 +18,15 @@ namespace YooAsset.Editor
window.minSize = new Vector2(800, 600); window.minSize = new Vector2(800, 600);
} }
private Button _saveButton;
private List<string> _collectorTypeList; private List<string> _collectorTypeList;
private List<string> _activeRuleList;
private List<string> _addressRuleList; private List<string> _addressRuleList;
private List<string> _packRuleList; private List<string> _packRuleList;
private List<string> _filterRuleList; private List<string> _filterRuleList;
private ListView _groupListView; private ListView _groupListView;
private ScrollView _collectorScrollView; private ScrollView _collectorScrollView;
private PopupField<string> _activeRulePopupField;
private Toggle _enableAddressableToogle; private Toggle _enableAddressableToogle;
private Toggle _autoCollectShaderToogle; private Toggle _autoCollectShaderToogle;
private TextField _shaderBundleNameTxt; private TextField _shaderBundleNameTxt;
@@ -31,48 +34,52 @@ namespace YooAsset.Editor
private TextField _groupDescTxt; private TextField _groupDescTxt;
private TextField _groupAssetTagsTxt; private TextField _groupAssetTagsTxt;
private VisualElement _groupContainer; private VisualElement _groupContainer;
private string _lastModifyGroup = string.Empty;
public void CreateGUI() public void CreateGUI()
{ {
Undo.undoRedoPerformed -= RefreshWindow; Undo.undoRedoPerformed -= RefreshWindow;
Undo.undoRedoPerformed += RefreshWindow; Undo.undoRedoPerformed += RefreshWindow;
VisualElement root = this.rootVisualElement;
_collectorTypeList = new List<string>()
{
$"{nameof(ECollectorType.MainAssetCollector)}",
$"{nameof(ECollectorType.StaticAssetCollector)}",
$"{nameof(ECollectorType.DependAssetCollector)}"
};
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
// 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath();
string uxml = $"{rootPath}/Editor/AssetBundleCollector/{nameof(AssetBundleCollectorWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null)
{
Debug.LogError($"Not found {nameof(AssetBundleCollectorWindow)}.uxml : {uxml}");
return;
}
visualAsset.CloneTree(root);
try try
{ {
_collectorTypeList = new List<string>()
{
$"{nameof(ECollectorType.MainAssetCollector)}",
$"{nameof(ECollectorType.StaticAssetCollector)}",
$"{nameof(ECollectorType.DependAssetCollector)}"
};
_activeRuleList = AssetBundleCollectorSettingData.GetActiveRuleNames();
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
VisualElement root = this.rootVisualElement;
// 加载布局文件
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleCollectorWindow>();
if (visualAsset == null)
return;
visualAsset.CloneTree(root);
// 导入导出按钮 // 导入导出按钮
var exportBtn = root.Q<Button>("ExportButton"); var exportBtn = root.Q<Button>("ExportButton");
exportBtn.clicked += ExportBtn_clicked; exportBtn.clicked += ExportBtn_clicked;
var importBtn = root.Q<Button>("ImportButton"); var importBtn = root.Q<Button>("ImportButton");
importBtn.clicked += ImportBtn_clicked; importBtn.clicked += ImportBtn_clicked;
// 配置保存按钮
_saveButton = root.Q<Button>("SaveButton");
_saveButton.clicked += SaveBtn_clicked;
// 公共设置相关 // 公共设置相关
_enableAddressableToogle = root.Q<Toggle>("EnableAddressable"); _enableAddressableToogle = root.Q<Toggle>("EnableAddressable");
_enableAddressableToogle.RegisterValueChangedCallback(evt => _enableAddressableToogle.RegisterValueChangedCallback(evt =>
{ {
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue); AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
RefreshWindow();
}); });
_autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader"); _autoCollectShaderToogle = root.Q<Toggle>("AutoCollectShader");
_autoCollectShaderToogle.RegisterValueChangedCallback(evt => _autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
@@ -156,6 +163,25 @@ namespace YooAsset.Editor
addBtn.clicked += AddCollectorBtn_clicked; addBtn.clicked += AddCollectorBtn_clicked;
} }
// 分组激活规则
var activeRuleContainer = root.Q("ActiveRuleContainer");
{
_activeRulePopupField = new PopupField<string>("Active Rule", _activeRuleList, 0);
_activeRulePopupField.name = "ActiveRuleMaskField";
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
activeRuleContainer.Add(_activeRulePopupField);
_activeRulePopupField.RegisterValueChangedCallback(evt =>
{
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
if (selectGroup != null)
{
selectGroup.ActiveRuleName = evt.newValue;
AssetBundleCollectorSettingData.ModifyGroup(selectGroup);
FillGroupViewData();
}
});
}
// 刷新窗体 // 刷新窗体
RefreshWindow(); RefreshWindow();
} }
@@ -166,9 +192,28 @@ namespace YooAsset.Editor
} }
public void OnDestroy() public void OnDestroy()
{ {
// 注意:清空所有撤销操作
Undo.ClearAll();
if (AssetBundleCollectorSettingData.IsDirty) if (AssetBundleCollectorSettingData.IsDirty)
AssetBundleCollectorSettingData.SaveFile(); AssetBundleCollectorSettingData.SaveFile();
} }
public void Update()
{
if (_saveButton != null)
{
if (AssetBundleCollectorSettingData.IsDirty)
{
if (_saveButton.enabledSelf == false)
_saveButton.SetEnabled(true);
}
else
{
if (_saveButton.enabledSelf)
_saveButton.SetEnabled(false);
}
}
}
private void RefreshWindow() private void RefreshWindow()
{ {
@@ -197,6 +242,10 @@ namespace YooAsset.Editor
RefreshWindow(); RefreshWindow();
} }
} }
private void SaveBtn_clicked()
{
AssetBundleCollectorSettingData.SaveFile();
}
// 分组列表相关 // 分组列表相关
private void FillGroupViewData() private void FillGroupViewData()
@@ -205,6 +254,16 @@ namespace YooAsset.Editor
_groupListView.ClearSelection(); _groupListView.ClearSelection();
_groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups; _groupListView.itemsSource = AssetBundleCollectorSettingData.Setting.Groups;
_groupListView.Rebuild(); _groupListView.Rebuild();
for (int index = 0; index < AssetBundleCollectorSettingData.Setting.Groups.Count; index++)
{
var group = AssetBundleCollectorSettingData.Setting.Groups[index];
if (group.GroupName == _lastModifyGroup)
{
_groupListView.selectedIndex = index;
break;
}
}
} }
private VisualElement MakeGroupListViewItem() private VisualElement MakeGroupListViewItem()
{ {
@@ -231,6 +290,11 @@ namespace YooAsset.Editor
textField1.text = group.GroupName; textField1.text = group.GroupName;
else else
textField1.text = $"{group.GroupName} ({group.GroupDesc})"; textField1.text = $"{group.GroupName} ({group.GroupDesc})";
// 激活状态
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
bool isActive = activeRule.IsActiveGroup();
textField1.SetEnabled(isActive);
} }
private void GroupListView_onSelectionChange(IEnumerable<object> objs) private void GroupListView_onSelectionChange(IEnumerable<object> objs)
{ {
@@ -238,7 +302,7 @@ namespace YooAsset.Editor
} }
private void AddGroupBtn_clicked() private void AddGroupBtn_clicked()
{ {
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset AddGroup"); Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddGroup");
AssetBundleCollectorSettingData.CreateGroup("Default Group"); AssetBundleCollectorSettingData.CreateGroup("Default Group");
FillGroupViewData(); FillGroupViewData();
} }
@@ -248,8 +312,7 @@ namespace YooAsset.Editor
if (selectGroup == null) if (selectGroup == null)
return; return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset RemoveGroup"); Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveGroup");
AssetBundleCollectorSettingData.RemoveGroup(selectGroup); AssetBundleCollectorSettingData.RemoveGroup(selectGroup);
FillGroupViewData(); FillGroupViewData();
} }
@@ -264,7 +327,9 @@ namespace YooAsset.Editor
return; return;
} }
_lastModifyGroup = selectGroup.GroupName;
_groupContainer.visible = true; _groupContainer.visible = true;
_activeRulePopupField.SetValueWithoutNotify(selectGroup.ActiveRuleName);
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName); _groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc); _groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags); _groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
@@ -512,7 +577,7 @@ namespace YooAsset.Editor
try try
{ {
collectAssetInfos = collector.GetAllCollectAssets(group); collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, group);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
@@ -552,6 +617,7 @@ namespace YooAsset.Editor
if (selectGroup == null) if (selectGroup == null)
return; return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow AddCollector");
AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty); AssetBundleCollectorSettingData.CreateCollector(selectGroup, string.Empty);
FillCollectorViewData(); FillCollectorViewData();
} }
@@ -562,6 +628,8 @@ namespace YooAsset.Editor
return; return;
if (selectCollector == null) if (selectCollector == null)
return; return;
Undo.RecordObject(AssetBundleCollectorSettingData.Setting, "YooAsset.AssetBundleCollectorWindow RemoveCollector");
AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector); AssetBundleCollectorSettingData.RemoveCollector(selectGroup, selectCollector);
FillCollectorViewData(); FillCollectorViewData();
} }

View File

@@ -1,5 +1,6 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;"> <uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar> </uie:Toolbar>
@@ -18,6 +19,7 @@
<ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" /> <ui:TextField picking-mode="Ignore" label="Shader Bundle Name" name="ShaderBundleName" style="flex-grow: 1; -unity-text-align: middle-left;" />
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;"> <ui:VisualElement name="GroupContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" /> <ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" /> <ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" /> <ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" />

View File

@@ -0,0 +1,25 @@

namespace YooAsset.Editor
{
/// <summary>
/// 启用分组
/// </summary>
public class EnableGroup : IActiveRule
{
public bool IsActiveGroup()
{
return true;
}
}
/// <summary>
/// 禁用分组
/// </summary>
public class DisableGroup : IActiveRule
{
public bool IsActiveGroup()
{
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2cfd65b3b7663b247b2df16077f4ef17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -44,10 +44,19 @@ namespace YooAsset.Editor
{ {
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
if (AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath) == typeof(Sprite)) var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
return true; if(mainAssetType == typeof(Texture2D))
{
var texImporter = AssetImporter.GetAtPath(data.AssetPath) as TextureImporter;
if (texImporter != null && texImporter.textureType == TextureImporterType.Sprite)
return true;
else
return false;
}
else else
{
return false; return false;
}
} }
} }
} }

View File

@@ -28,6 +28,8 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public class PackDirectory : IPackRule public class PackDirectory : IPackRule
{ {
public static PackDirectory StaticPackRule = new PackDirectory();
string IPackRule.GetBundleName(PackRuleData data) string IPackRule.GetBundleName(PackRuleData data)
{ {
return Path.GetDirectoryName(data.AssetPath); return Path.GetDirectoryName(data.AssetPath);

View File

@@ -0,0 +1,14 @@

namespace YooAsset.Editor
{
/// <summary>
/// 资源分组激活规则接口
/// </summary>
public interface IActiveRule
{
/// <summary>
/// 是否激活分组
/// </summary>
bool IsActiveGroup();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aed5a1a6733b7d44ca4f6149ed5a2bb8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,140 +1,298 @@
#if UNITY_2019_4_OR_NEWER #if UNITY_2019_4_OR_NEWER
using System;
using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using UnityEditor.UIElements; using UnityEditor.UIElements;
using UnityEditor.Networking.PlayerConnection;
using UnityEngine.Networking.PlayerConnection;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
public class AssetBundleDebuggerWindow : EditorWindow public class AssetBundleDebuggerWindow : EditorWindow
{ {
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)] [MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
public static void ShowExample() public static void ShowExample()
{ {
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes); AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, EditorDefine.DockedWindowTypes);
wnd.minSize = new Vector2(800, 600); wnd.minSize = new Vector2(800, 600);
} }
/// <summary> /// <summary>
/// 视图模式 /// 视图模式
/// </summary> /// </summary>
private enum EViewMode private enum EViewMode
{ {
/// <summary> /// <summary>
/// 内存视图 /// 内存视图
/// </summary> /// </summary>
MemoryView, MemoryView,
/// <summary> /// <summary>
/// 资源对象视图 /// 资源对象视图
/// </summary> /// </summary>
AssetView, AssetView,
/// <summary> /// <summary>
/// 资源包视图 /// 资源包视图
/// </summary> /// </summary>
BundleView, BundleView,
} }
private ToolbarMenu _viewModeMenu;
private AssetListDebuggerViewer _assetListViewer;
private BundleListDebuggerViewer _bundleListViewer;
private EViewMode _viewMode;
private readonly DebugReport _debugReport = new DebugReport();
private string _searchKeyWord;
public void CreateGUI() private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
{
VisualElement root = rootVisualElement;
// 加载布局文件 private Label _playerName;
string rootPath = EditorTools.GetYooAssetSourcePath(); private ToolbarMenu _viewModeMenu;
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/{nameof(AssetBundleDebuggerWindow)}.uxml"; private SliderInt _frameSlider;
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml); private DebuggerAssetListViewer _assetListViewer;
if (visualAsset == null) private DebuggerBundleListViewer _bundleListViewer;
{
Debug.LogError($"Not found {nameof(AssetBundleDebuggerWindow)}.uxml : {uxml}");
return;
}
visualAsset.CloneTree(root);
// 采样按钮 private EViewMode _viewMode;
var sampleBtn = root.Q<Button>("SampleButton"); private string _searchKeyWord;
sampleBtn.clicked += SampleBtn_onClick; private DebugReport _currentReport;
private RemotePlayerSession _currentPlayerSession;
private int _rangeIndex = 0;
// 视口模式菜单
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
//_viewModeMenu.menu.AppendAction(EViewMode.MemoryView.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
// 搜索栏 public void CreateGUI()
var searchField = root.Q<ToolbarSearchField>("SearchField"); {
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange); try
{
VisualElement root = rootVisualElement;
// 加载视图 // 加载布局文件
_assetListViewer = new AssetListDebuggerViewer(); var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleDebuggerWindow>();
_assetListViewer.InitViewer(); if (visualAsset == null)
return;
// 加载视图 visualAsset.CloneTree(root);
_bundleListViewer = new BundleListDebuggerViewer();
_bundleListViewer.InitViewer();
// 显示视图 // 采样按钮
_viewMode = EViewMode.AssetView; var sampleBtn = root.Q<Button>("SampleButton");
_viewModeMenu.text = EViewMode.AssetView.ToString(); sampleBtn.clicked += SampleBtn_onClick;
_assetListViewer.AttachParent(root);
} // 用户列表菜单
private void SampleBtn_onClick() _playerName = root.Q<Label>("PlayerName");
{ _playerName.text = "Editor player";
YooAssets.GetDebugReport(_debugReport);
_assetListViewer.FillViewData(_debugReport, _searchKeyWord); // 视口模式菜单
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord); _viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
} _viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
private void OnSearchKeyWordChange(ChangeEvent<string> e) _viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
{ _viewModeMenu.text = EViewMode.AssetView.ToString();
_searchKeyWord = e.newValue;
_assetListViewer.FillViewData(_debugReport, _searchKeyWord); // 搜索栏
_bundleListViewer.FillViewData(_debugReport, _searchKeyWord); var searchField = root.Q<ToolbarSearchField>("SearchField");
} searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
private void ViewModeMenuAction1(DropdownMenuAction action)
{ // 帧数相关
if (_viewMode != EViewMode.AssetView) {
{ _frameSlider = root.Q<SliderInt>("FrameSlider");
_viewMode = EViewMode.AssetView; _frameSlider.label = "Frame:";
VisualElement root = this.rootVisualElement; _frameSlider.highValue = 0;
_viewModeMenu.text = EViewMode.AssetView.ToString(); _frameSlider.lowValue = 0;
_assetListViewer.AttachParent(root); _frameSlider.value = 0;
_bundleListViewer.DetachParent(); _frameSlider.RegisterValueChangedCallback(evt =>
} {
} OnFrameSliderChange(evt.newValue);
private void ViewModeMenuAction2(DropdownMenuAction action) });
{
if (_viewMode != EViewMode.BundleView) var frameLast = root.Q<ToolbarButton>("FrameLast");
{ frameLast.clicked += OnFrameLast_clicked;
_viewMode = EViewMode.BundleView;
VisualElement root = this.rootVisualElement; var frameNext = root.Q<ToolbarButton>("FrameNext");
_viewModeMenu.text = EViewMode.BundleView.ToString(); frameNext.clicked += OnFrameNext_clicked;
_assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root); var frameClear = root.Q<ToolbarButton>("FrameClear");
} frameClear.clicked += OnFrameClear_clicked;
} }
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
{ // 加载视图
if (_viewMode == EViewMode.AssetView) _assetListViewer = new DebuggerAssetListViewer();
return DropdownMenuAction.Status.Checked; _assetListViewer.InitViewer();
else
return DropdownMenuAction.Status.Normal; // 加载视图
} _bundleListViewer = new DebuggerBundleListViewer();
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action) _bundleListViewer.InitViewer();
{
if (_viewMode == EViewMode.BundleView) // 显示视图
return DropdownMenuAction.Status.Checked; _viewMode = EViewMode.AssetView;
else _assetListViewer.AttachParent(root);
return DropdownMenuAction.Status.Normal;
} // 远程调试
} EditorConnection.instance.Initialize();
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
}
public void OnDestroy()
{
// 远程调试
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
_playerSessions.Clear();
}
private void OnHandleConnectionEvent(int playerId)
{
Debug.Log($"Game player connection : {playerId}");
_playerName.text = $"Connected player : {playerId}";
}
private void OnHandleDisconnectionEvent(int playerId)
{
Debug.Log($"Game player disconnection : {playerId}");
_playerName.text = $"Disconneced player : {playerId}";
}
private void OnHandlePlayerMessage(MessageEventArgs args)
{
var debugReport = DebugReport.Deserialize(args.data);
OnHandleDebugReport(args.playerId, debugReport);
}
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
{
Debug.Log($"Handle player {playerId} debug report !");
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
_currentPlayerSession.AddDebugReport(debugReport);
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
UpdateFrameView(_currentPlayerSession);
}
private void OnFrameSliderChange(int sliderValue)
{
if (_currentPlayerSession != null)
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameLast_clicked()
{
if (_currentPlayerSession != null)
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
_frameSlider.value = _rangeIndex;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameNext_clicked()
{
if (_currentPlayerSession != null)
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
_frameSlider.value = _rangeIndex;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
}
}
private void OnFrameClear_clicked()
{
if (_currentPlayerSession != null)
{
_frameSlider.label = $"Frame:";
_frameSlider.value = 0;
_frameSlider.lowValue = 0;
_frameSlider.highValue = 0;
_currentPlayerSession.ClearDebugReport();
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
}
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
{
return session;
}
else
{
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
_playerSessions.Add(playerId, newSession);
return newSession;
}
}
private void UpdateFrameView(RemotePlayerSession playerSession)
{
if (playerSession != null)
{
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
}
}
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
{
if (playerSession == null)
return;
var debugReport = playerSession.GetDebugReport(rangeIndex);
if (debugReport != null)
{
_currentReport = debugReport;
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
}
}
private void SampleBtn_onClick()
{
// 发送采集数据的命令
RemoteCommand command = new RemoteCommand();
command.CommandType = (int)ERemoteCommand.SampleOnce;
command.CommandParam = string.Empty;
byte[] data = RemoteCommand.Serialize(command);
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
RemoteDebuggerInRuntime.EditorRequestDebugReport();
}
private void OnSearchKeyWordChange(ChangeEvent<string> e)
{
_searchKeyWord = e.newValue;
if (_currentReport != null)
{
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
}
}
private void OnViewModeMenuChange(DropdownMenuAction action)
{
var viewMode = (EViewMode)action.userData;
if (_viewMode != viewMode)
{
_viewMode = viewMode;
VisualElement root = this.rootVisualElement;
_viewModeMenu.text = viewMode.ToString();
if (viewMode == EViewMode.AssetView)
{
_assetListViewer.AttachParent(root);
_bundleListViewer.DetachParent();
}
else if (viewMode == EViewMode.BundleView)
{
_assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root);
}
else
{
throw new NotImplementedException(viewMode.ToString());
}
}
}
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
{
var viewMode = (EViewMode)action.userData;
if (_viewMode == viewMode)
return DropdownMenuAction.Status.Checked;
else
return DropdownMenuAction.Status.Normal;
}
}
} }
#endif #endif

View File

@@ -1,7 +1,14 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex;"> <uie:Toolbar name="TopToolbar" style="display: flex;">
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" />
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" /> <uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" /> <uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" /> <uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
</uie:Toolbar> </uie:Toolbar>
<uie:Toolbar name="FrameToolbar">
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />
<uie:ToolbarButton text=" &lt;&lt; " display-tooltip-when-elided="true" name="FrameLast" />
<uie:ToolbarButton text=" &gt;&gt; " display-tooltip-when-elided="true" name="FrameNext" />
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
</uie:Toolbar>
</ui:UXML> </ui:UXML>

View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset.Editor
{
internal class RemotePlayerSession
{
private readonly List<DebugReport> _reportList = new List<DebugReport>();
/// <summary>
/// 用户ID
/// </summary>
public int PlayerId { private set; get; }
/// <summary>
/// 保存的报告最大数量
/// </summary>
public int MaxReportCount { private set; get; }
public int MinRangeValue
{
get
{
return 0;
}
}
public int MaxRangeValue
{
get
{
int index = _reportList.Count - 1;
if (index < 0)
index = 0;
return index;
}
}
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
{
PlayerId = playerId;
MaxReportCount = maxReportCount;
}
/// <summary>
/// 清理缓存数据
/// </summary>
public void ClearDebugReport()
{
_reportList.Clear();
}
/// <summary>
/// 添加一个调试报告
/// </summary>
public void AddDebugReport(DebugReport report)
{
if (report == null)
Debug.LogWarning("Invalid debug report data !");
if (_reportList.Count >= MaxReportCount)
_reportList.RemoveAt(0);
_reportList.Add(report);
}
/// <summary>
/// 获取调试报告
/// </summary>
public DebugReport GetDebugReport(int rangeIndex)
{
if (_reportList.Count == 0)
return null;
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
return null;
return _reportList[rangeIndex];
}
/// <summary>
/// 规范索引值
/// </summary>
public int ClampRangeIndex(int rangeIndex)
{
if (rangeIndex < 0)
return 0;
if (rangeIndex > MaxRangeValue)
return MaxRangeValue;
return rangeIndex;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89b4ea90b9f7e474d9e80077656ef6c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class AssetListDebuggerViewer internal class DebuggerAssetListViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@@ -24,14 +24,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = EditorHelper.LoadWindowUXML<DebuggerAssetListViewer>();
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/VisualViewers/{nameof(AssetListDebuggerViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{
Debug.LogError($"Not found {nameof(AssetListDebuggerViewer)}.uxml : {uxml}");
return; return;
}
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
@@ -51,6 +47,18 @@ namespace YooAsset.Editor
_dependListView.bindItem = BindDependListViewItem; _dependListView.bindItem = BindDependListViewItem;
} }
/// <summary>
/// 清空页面
/// </summary>
public void ClearView()
{
_debugReport = null;
_assetListView.Clear();
_assetListView.ClearSelection();
_assetListView.itemsSource.Clear();
_assetListView.Rebuild();
}
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
@@ -175,7 +183,7 @@ namespace YooAsset.Editor
// Status // Status
StyleColor textColor; StyleColor textColor;
if (providerInfo.Status == ProviderBase.EStatus.Fail) if (providerInfo.Status == (int)ProviderBase.EStatus.Fail)
textColor = new StyleColor(Color.yellow); textColor = new StyleColor(Color.yellow);
else else
textColor = label1.style.color; textColor = label1.style.color;

View File

@@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class BundleListDebuggerViewer internal class DebuggerBundleListViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@@ -24,14 +24,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = EditorHelper.LoadWindowUXML<DebuggerBundleListViewer>();
string uxml = $"{rootPath}/Editor/AssetBundleDebugger/VisualViewers/{nameof(BundleListDebuggerViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{
Debug.LogError($"Not found {nameof(BundleListDebuggerViewer)}.uxml : {uxml}");
return; return;
}
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
@@ -39,18 +35,30 @@ namespace YooAsset.Editor
_bundleListView = _root.Q<ListView>("TopListView"); _bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeAssetListViewItem; _bundleListView.makeItem = MakeAssetListViewItem;
_bundleListView.bindItem = BindAssetListViewItem; _bundleListView.bindItem = BindAssetListViewItem;
#if UNITY_2020_1_OR_NEWER #if UNITY_2020_1_OR_NEWER
_bundleListView.onSelectionChange += BundleListView_onSelectionChange; _bundleListView.onSelectionChange += BundleListView_onSelectionChange;
#else #else
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange; _bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
#endif #endif
// 使用列表 // 使用列表
_usingListView = _root.Q<ListView>("BottomListView"); _usingListView = _root.Q<ListView>("BottomListView");
_usingListView.makeItem = MakeIncludeListViewItem; _usingListView.makeItem = MakeIncludeListViewItem;
_usingListView.bindItem = BindIncludeListViewItem; _usingListView.bindItem = BindIncludeListViewItem;
} }
/// <summary>
/// 清空页面
/// </summary>
public void ClearView()
{
_debugReport = null;
_bundleListView.Clear();
_bundleListView.ClearSelection();
_bundleListView.itemsSource.Clear();
_bundleListView.Rebuild();
}
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
@@ -151,7 +159,7 @@ namespace YooAsset.Editor
// Status // Status
StyleColor textColor; StyleColor textColor;
if (bundleInfo.Status == AssetBundleLoaderBase.EStatus.Failed) if (bundleInfo.Status == (int)AssetBundleLoaderBase.EStatus.Failed)
textColor = new StyleColor(Color.yellow); textColor = new StyleColor(Color.yellow);
else else
textColor = label1.style.color; textColor = label1.style.color;

View File

@@ -1,4 +1,5 @@
#if UNITY_2019_4_OR_NEWER #if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEditor.UIElements; using UnityEditor.UIElements;
@@ -37,9 +38,9 @@ namespace YooAsset.Editor
} }
private ToolbarMenu _viewModeMenu; private ToolbarMenu _viewModeMenu;
private SummaryReporterViewer _summaryViewer; private ReporterSummaryViewer _summaryViewer;
private AssetListReporterViewer _assetListViewer; private ReporterAssetListViewer _assetListViewer;
private BundleListReporterViewer _bundleListViewer; private ReporterBundleListViewer _bundleListViewer;
private EViewMode _viewMode; private EViewMode _viewMode;
private BuildReport _buildReport; private BuildReport _buildReport;
@@ -49,49 +50,52 @@ namespace YooAsset.Editor
public void CreateGUI() public void CreateGUI()
{ {
VisualElement root = this.rootVisualElement; try
// 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath();
string uxml = $"{rootPath}/Editor/AssetBundleReporter/{nameof(AssetBundleReporterWindow)}.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetBundleReporterWindow)}.uxml : {uxml}"); VisualElement root = this.rootVisualElement;
return;
// 加载布局文件
var visualAsset = EditorHelper.LoadWindowUXML<AssetBundleReporterWindow>();
if (visualAsset == null)
return;
visualAsset.CloneTree(root);
// 导入按钮
var importBtn = root.Q<Button>("ImportButton");
importBtn.clicked += ImportBtn_onClick;
// 视图模式菜单
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
// 搜索栏
var searchField = root.Q<ToolbarSearchField>("SearchField");
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 加载视图
_summaryViewer = new ReporterSummaryViewer();
_summaryViewer.InitViewer();
// 加载视图
_assetListViewer = new ReporterAssetListViewer();
_assetListViewer.InitViewer();
// 加载视图
_bundleListViewer = new ReporterBundleListViewer();
_bundleListViewer.InitViewer();
// 显示视图
_viewMode = EViewMode.Summary;
_viewModeMenu.text = EViewMode.Summary.ToString();
_summaryViewer.AttachParent(root);
}
catch (Exception e)
{
Debug.LogError(e.ToString());
} }
visualAsset.CloneTree(root);
// 导入按钮
var importBtn = root.Q<Button>("ImportButton");
importBtn.clicked += ImportBtn_onClick;
// 视图模式菜单
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
// 搜索栏
var searchField = root.Q<ToolbarSearchField>("SearchField");
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 加载视图
_summaryViewer = new SummaryReporterViewer();
_summaryViewer.InitViewer();
// 加载视图
_assetListViewer = new AssetListReporterViewer();
_assetListViewer.InitViewer();
// 加载视图
_bundleListViewer = new BundleListReporterViewer();
_bundleListViewer.InitViewer();
// 显示视图
_viewMode = EViewMode.Summary;
_viewModeMenu.text = EViewMode.Summary.ToString();
_summaryViewer.AttachParent(root);
} }
public void OnDestroy() public void OnDestroy()
{ {

View File

@@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class AssetListReporterViewer internal class ReporterAssetListViewer
{ {
private enum ESortMode private enum ESortMode
{ {
@@ -38,48 +38,36 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = EditorHelper.LoadWindowUXML<ReporterAssetListViewer>();
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(AssetListReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{
Debug.LogError($"Not found {nameof(AssetListReporterViewer)}.uxml : {uxml}");
return; return;
}
try _root = _visualAsset.CloneTree();
{ _root.style.flexGrow = 1f;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 顶部按钮栏 // 顶部按钮栏
_topBar1 = _root.Q<ToolbarButton>("TopBar1"); _topBar1 = _root.Q<ToolbarButton>("TopBar1");
_topBar2 = _root.Q<ToolbarButton>("TopBar2"); _topBar2 = _root.Q<ToolbarButton>("TopBar2");
_topBar1.clicked += TopBar1_clicked; _topBar1.clicked += TopBar1_clicked;
_topBar2.clicked += TopBar2_clicked; _topBar2.clicked += TopBar2_clicked;
// 底部按钮栏 // 底部按钮栏
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1"); _bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
// 资源列表 // 资源列表
_assetListView = _root.Q<ListView>("TopListView"); _assetListView = _root.Q<ListView>("TopListView");
_assetListView.makeItem = MakeAssetListViewItem; _assetListView.makeItem = MakeAssetListViewItem;
_assetListView.bindItem = BindAssetListViewItem; _assetListView.bindItem = BindAssetListViewItem;
#if UNITY_2020_1_OR_NEWER #if UNITY_2020_1_OR_NEWER
_assetListView.onSelectionChange += AssetListView_onSelectionChange; _assetListView.onSelectionChange += AssetListView_onSelectionChange;
#else #else
_assetListView.onSelectionChanged += AssetListView_onSelectionChange; _assetListView.onSelectionChanged += AssetListView_onSelectionChange;
#endif #endif
// 依赖列表 // 依赖列表
_dependListView = _root.Q<ListView>("BottomListView"); _dependListView = _root.Q<ListView>("BottomListView");
_dependListView.makeItem = MakeDependListViewItem; _dependListView.makeItem = MakeDependListViewItem;
_dependListView.bindItem = BindDependListViewItem; _dependListView.bindItem = BindDependListViewItem;
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
} }
/// <summary> /// <summary>

View File

@@ -10,7 +10,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class BundleListReporterViewer internal class ReporterBundleListViewer
{ {
private enum ESortMode private enum ESortMode
{ {
@@ -42,58 +42,46 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = EditorHelper.LoadWindowUXML<ReporterBundleListViewer>();
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(BundleListReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{
Debug.LogError($"Not found {nameof(BundleListReporterViewer)}.uxml : {uxml}");
return; return;
}
try _root = _visualAsset.CloneTree();
{ _root.style.flexGrow = 1f;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 顶部按钮栏 // 顶部按钮栏
_topBar1 = _root.Q<ToolbarButton>("TopBar1"); _topBar1 = _root.Q<ToolbarButton>("TopBar1");
_topBar2 = _root.Q<ToolbarButton>("TopBar2"); _topBar2 = _root.Q<ToolbarButton>("TopBar2");
_topBar3 = _root.Q<ToolbarButton>("TopBar3"); _topBar3 = _root.Q<ToolbarButton>("TopBar3");
_topBar4 = _root.Q<ToolbarButton>("TopBar4"); _topBar4 = _root.Q<ToolbarButton>("TopBar4");
_topBar1.clicked += TopBar1_clicked; _topBar1.clicked += TopBar1_clicked;
_topBar2.clicked += TopBar2_clicked; _topBar2.clicked += TopBar2_clicked;
_topBar3.clicked += TopBar3_clicked; _topBar3.clicked += TopBar3_clicked;
_topBar4.clicked += TopBar4_clicked; _topBar4.clicked += TopBar4_clicked;
// 底部按钮栏 // 底部按钮栏
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1"); _bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
// 资源包列表 // 资源包列表
_bundleListView = _root.Q<ListView>("TopListView"); _bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeBundleListViewItem; _bundleListView.makeItem = MakeBundleListViewItem;
_bundleListView.bindItem = BindBundleListViewItem; _bundleListView.bindItem = BindBundleListViewItem;
#if UNITY_2020_1_OR_NEWER #if UNITY_2020_1_OR_NEWER
_bundleListView.onSelectionChange += BundleListView_onSelectionChange; _bundleListView.onSelectionChange += BundleListView_onSelectionChange;
#else #else
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange; _bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
#endif #endif
// 包含列表 // 包含列表
_includeListView = _root.Q<ListView>("BottomListView"); _includeListView = _root.Q<ListView>("BottomListView");
_includeListView.makeItem = MakeIncludeListViewItem; _includeListView.makeItem = MakeIncludeListViewItem;
_includeListView.bindItem = BindIncludeListViewItem; _includeListView.bindItem = BindIncludeListViewItem;
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
} }
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
public void FillViewData( BuildReport buildReport, string reprotFilePath, string searchKeyWord) public void FillViewData(BuildReport buildReport, string reprotFilePath, string searchKeyWord)
{ {
_buildReport = buildReport; _buildReport = buildReport;
_reportFilePath = reprotFilePath; _reportFilePath = reprotFilePath;

View File

@@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class SummaryReporterViewer internal class ReporterSummaryViewer
{ {
private class ItemWrapper private class ItemWrapper
{ {
@@ -37,14 +37,10 @@ namespace YooAsset.Editor
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string rootPath = EditorTools.GetYooAssetSourcePath(); _visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
string uxml = $"{rootPath}/Editor/AssetBundleReporter/VisualViewers/{nameof(SummaryReporterViewer)}.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{
Debug.LogError($"Not found {nameof(SummaryReporterViewer)}.uxml : {uxml}");
return; return;
}
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
@@ -62,17 +58,20 @@ namespace YooAsset.Editor
_buildReport = buildReport; _buildReport = buildReport;
_items.Clear(); _items.Clear();
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion)); _items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime)); _items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate));
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒")); _items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}")); _items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}")); _items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
_items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}")); _items.Add(new ItemWrapper("构建版本", $"{buildReport.Summary.BuildVersion}"));
_items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}")); _items.Add(new ItemWrapper("内置资源标签", $"{buildReport.Summary.BuildinTags}"));
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}")); _items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("启用自动分包机制", $"{buildReport.Summary.EnableAutoCollect}"));
_items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}")); _items.Add(new ItemWrapper("追加文件扩展名", $"{buildReport.Summary.AppendFileExtension}"));
_items.Add(new ItemWrapper("拷贝内置资源文件", $"{buildReport.Summary.CopyBuildinTagFiles}"));
_items.Add(new ItemWrapper("自动收集着色器", $"{buildReport.Summary.AutoCollectShaders}")); _items.Add(new ItemWrapper("自动收集着色器", $"{buildReport.Summary.AutoCollectShaders}"));
_items.Add(new ItemWrapper("着色器资源包名称", $"{buildReport.Summary.ShadersBundleName}")); _items.Add(new ItemWrapper("着色器资源包名称", $"{buildReport.Summary.ShadersBundleName}"));
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}")); _items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
@@ -80,10 +79,8 @@ namespace YooAsset.Editor
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("构建参数", string.Empty)); _items.Add(new ItemWrapper("构建参数", string.Empty));
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}")); _items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
_items.Add(new ItemWrapper("AppendHash", $"{buildReport.Summary.AppendHash}"));
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}")); _items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}")); _items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
_items.Add(new ItemWrapper("DisableLoadAssetByFileName", $"{buildReport.Summary.DisableLoadAssetByFileName}"));
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("构建结果", string.Empty)); _items.Add(new ItemWrapper("构建结果", string.Empty));

View File

@@ -1,6 +1,7 @@
 
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
#if UNITY_2019 #if UNITY_2019
public static partial class UnityEngine_UIElements_ListView_Extension public static partial class UnityEngine_UIElements_ListView_Extension
{ {
@@ -20,4 +21,5 @@ namespace YooAsset.Editor
} }
} }
#endif #endif
} }

View File

@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
public class EditorHelper
{
#if UNITY_2019_4_OR_NEWER
private readonly static Dictionary<System.Type, string> _uxmlDic = new Dictionary<System.Type, string>();
static EditorHelper()
{
// 资源包收集
_uxmlDic.Add(typeof(AssetBundleCollectorWindow), "355c4ac5cdebddc4c8362bed6f17a79e");
// 资源包构建
_uxmlDic.Add(typeof(AssetBundleBuilderWindow), "28ba29adb4949284e8c48893218b0d9a");
// 资源包调试
_uxmlDic.Add(typeof(AssetBundleDebuggerWindow), "790db12999afd334e8fb6ba70ef0a947");
_uxmlDic.Add(typeof(DebuggerAssetListViewer), "31c6096c1cb29b4469096b7b4942a322");
_uxmlDic.Add(typeof(DebuggerBundleListViewer), "932a25ffd05c13c47994d66e9d73bc37");
// 构建报告
_uxmlDic.Add(typeof(AssetBundleReporterWindow), "9052b72c383e95043a0c7e7f369b1ad7");
_uxmlDic.Add(typeof(ReporterSummaryViewer), "f8929271050855e42a1ccc6b14993a04");
_uxmlDic.Add(typeof(ReporterAssetListViewer), "5f81bc15a55ee0a49a266f9d71e2372b");
_uxmlDic.Add(typeof(ReporterBundleListViewer), "56d6dbe0d65ce334a8996beb19612989");
}
/// <summary>
/// 加载窗口的布局文件
/// </summary>
public static UnityEngine.UIElements.VisualTreeAsset LoadWindowUXML<TWindow>() where TWindow : class
{
var windowType = typeof(TWindow);
if (_uxmlDic.TryGetValue(windowType, out string uxmlGUID))
{
string assetPath = AssetDatabase.GUIDToAssetPath(uxmlGUID);
if (string.IsNullOrEmpty(assetPath))
throw new System.Exception($"Invalid YooAsset uxml guid : {uxmlGUID}");
var visualTreeAsset = AssetDatabase.LoadAssetAtPath<UnityEngine.UIElements.VisualTreeAsset>(assetPath);
if (visualTreeAsset == null)
throw new System.Exception($"Failed to load {windowType}.uxml");
return visualTreeAsset;
}
else
{
throw new System.Exception($"Invalid YooAsset window type : {windowType}");
}
}
#endif
/// <summary>
/// 加载相关的配置文件
/// </summary>
public static TSetting LoadSettingData<TSetting>() where TSetting : ScriptableObject
{
var settingType = typeof(TSetting);
var guids = AssetDatabase.FindAssets($"t:{settingType.Name}");
if (guids.Length == 0)
{
Debug.LogWarning($"Create new {settingType.Name}.asset");
var setting = ScriptableObject.CreateInstance<TSetting>();
string filePath = $"Assets/{settingType.Name}.asset";
AssetDatabase.CreateAsset(setting, filePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
return setting;
}
else
{
if (guids.Length != 1)
{
foreach (var guid in guids)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
Debug.LogWarning($"Found multiple file : {path}");
}
throw new System.Exception($"Found multiple {settingType.Name} files !");
}
string filePath = AssetDatabase.GUIDToAssetPath(guids[0]);
var setting = AssetDatabase.LoadAssetAtPath<TSetting>(filePath);
return setting;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2d701e695ac3fe4cbe25d43dde05944
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,6 +7,7 @@ using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
@@ -265,6 +266,20 @@ namespace YooAsset.Editor
} }
#endregion #endregion
#region SceneUtility
public static bool HasDirtyScenes()
{
var sceneCount = EditorSceneManager.sceneCount;
for (var i = 0; i < sceneCount; ++i)
{
var scene = EditorSceneManager.GetSceneAt(i);
if (scene.isDirty)
return true;
}
return false;
}
#endregion
#region #region
/// <summary> /// <summary>
/// 创建文件所在的目录 /// 创建文件所在的目录
@@ -462,9 +477,6 @@ namespace YooAsset.Editor
#endregion #endregion
#region #region
private static string YooAssetSourcePath;
private static string YooAssetSettingPath;
/// <summary> /// <summary>
/// 获取规范的路径 /// 获取规范的路径
/// </summary> /// </summary>
@@ -473,83 +485,6 @@ namespace YooAsset.Editor
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
} }
/// <summary>
/// 获取资源框架源码路径
/// </summary>
public static string GetYooAssetSourcePath()
{
if (string.IsNullOrEmpty(YooAssetSourcePath) == false)
{
if (Directory.Exists(YooAssetSourcePath))
return YooAssetSourcePath;
}
// 从Pakcages目录下搜索
string packagesPath = "Packages/com.tuyoogame.yooasset/README.md";
var obj = AssetDatabase.LoadAssetAtPath(packagesPath, typeof(TextAsset));
if (obj != null)
{
YooAssetSourcePath = "Packages/com.tuyoogame.yooasset/";
return YooAssetSourcePath;
}
// 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
Debug.LogError("Not found YooAsset package !");
return string.Empty;
}
string targetDirectory = string.Empty;
foreach (var directory in allDirectorys)
{
string asmdefFilePath = $"{directory}/Editor/YooAsset.Editor.asmdef";
if (File.Exists(asmdefFilePath))
{
targetDirectory = directory;
break;
}
}
if (string.IsNullOrEmpty(targetDirectory))
{
Debug.LogError("Should never get here !");
return string.Empty;
}
YooAssetSourcePath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetSourcePath;
}
/// <summary>
/// 获取资源框架配置路径
/// </summary>
public static string GetYooAssetSettingPath()
{
if (string.IsNullOrEmpty(YooAssetSettingPath) == false)
{
if (Directory.Exists(YooAssetSettingPath))
return YooAssetSettingPath;
}
// 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAssetSetting", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
YooAssetSettingPath = "Assets/YooAssetSetting";
return YooAssetSettingPath;
}
string targetDirectory = allDirectorys[0];
if (allDirectorys.Length != 1)
{
Debug.LogError("Found multiple YooAssetSetting folder !");
}
YooAssetSettingPath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetSettingPath;
}
/// <summary> /// <summary>
/// 获取项目工程路径 /// 获取项目工程路径
/// </summary> /// </summary>
@@ -566,7 +501,7 @@ namespace YooAsset.Editor
public static string AbsolutePathToAssetPath(string absolutePath) public static string AbsolutePathToAssetPath(string absolutePath)
{ {
string content = GetRegularPath(absolutePath); string content = GetRegularPath(absolutePath);
return Substring(content, "Assets", true); return Substring(content, "Assets/", true);
} }
/// <summary> /// <summary>
@@ -630,7 +565,6 @@ namespace YooAsset.Editor
else else
return content.Substring(startIndex + key.Length); return content.Substring(startIndex + key.Length);
} }
#endregion #endregion
} }
} }

View File

@@ -25,22 +25,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private static void LoadSettingData() private static void LoadSettingData()
{ {
// 加载配置文件 _setting = EditorHelper.LoadSettingData<ShaderVariantCollectorSetting>();
string settingFilePath = $"{EditorTools.GetYooAssetSettingPath()}/{nameof(ShaderVariantCollectorSetting)}.asset";
_setting = AssetDatabase.LoadAssetAtPath<ShaderVariantCollectorSetting>(settingFilePath);
if (_setting == null)
{
Debug.LogWarning($"Create new {nameof(ShaderVariantCollectorSetting)}.asset : {settingFilePath}");
_setting = ScriptableObject.CreateInstance<ShaderVariantCollectorSetting>();
EditorTools.CreateFileDirectory(settingFilePath);
AssetDatabase.CreateAsset(Setting, settingFilePath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
else
{
Debug.Log($"Load {nameof(ShaderVariantCollectorSetting)}.asset ok");
}
} }
/// <summary> /// <summary>

View File

@@ -34,6 +34,8 @@ namespace YooAsset.Editor
EditorGUILayout.Space(); EditorGUILayout.Space();
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80))) if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
{ {
// 先删除再保存否则ShaderVariantCollection内容将无法及时刷新
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath); ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath);
} }

View File

@@ -2,7 +2,9 @@
"name": "YooAsset.Editor", "name": "YooAsset.Editor",
"rootNamespace": "", "rootNamespace": "",
"references": [ "references": [
"YooAsset" "YooAsset",
"Unity.ScriptableBuildPipeline",
"Unity.ScriptableBuildPipeline.Editor"
], ],
"includePlatforms": [ "includePlatforms": [
"Editor" "Editor"

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@@ -13,34 +12,26 @@ namespace YooAsset
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000); private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100); private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
/// <summary> private static bool _simulationOnEditor;
/// 在编辑器下模拟运行 private static int _loadingMaxNumber;
/// </summary>
public static bool SimulationOnEditor { private set; get; }
/// <summary>
/// 运行时的最大加载个数
/// </summary>
public static int AssetLoadingMaxNumber { private set; get; }
public static IDecryptionServices DecryptionServices { private set; get; } public static IDecryptionServices DecryptionServices { private set; get; }
public static IBundleServices BundleServices { private set; get; } public static IBundleServices BundleServices { private set; get; }
/// <summary> /// <summary>
/// 初始化资源系统 /// 初始化
/// 注意在使用AssetSystem之前需要初始化 /// 注意在使用AssetSystem之前需要初始化
/// </summary> /// </summary>
public static void Initialize(bool simulationOnEditor, int assetLoadingMaxNumber, IDecryptionServices decryptionServices, IBundleServices bundleServices) public static void Initialize(bool simulationOnEditor, int loadingMaxNumber, IDecryptionServices decryptionServices, IBundleServices bundleServices)
{ {
SimulationOnEditor = simulationOnEditor; _simulationOnEditor = simulationOnEditor;
AssetLoadingMaxNumber = assetLoadingMaxNumber; _loadingMaxNumber = loadingMaxNumber;
DecryptionServices = decryptionServices; DecryptionServices = decryptionServices;
BundleServices = bundleServices; BundleServices = bundleServices;
} }
/// <summary> /// <summary>
/// 轮询更新 /// 更新
/// </summary> /// </summary>
public static void Update() public static void Update()
{ {
@@ -63,7 +54,7 @@ namespace YooAsset
} }
else else
{ {
if (loadingCount < AssetLoadingMaxNumber) if (loadingCount < _loadingMaxNumber)
provider.Update(); provider.Update();
if (provider.IsDone == false) if (provider.IsDone == false)
@@ -72,12 +63,25 @@ namespace YooAsset
} }
} }
/// <summary>
/// 销毁
/// </summary>
public static void DestroyAll()
{
_loaders.Clear();
_providers.Clear();
_sceneHandles.Clear();
DecryptionServices = null;
BundleServices = null;
}
/// <summary> /// <summary>
/// 资源回收(卸载引用计数为零的资源) /// 资源回收(卸载引用计数为零的资源)
/// </summary> /// </summary>
public static void UnloadUnusedAssets() public static void UnloadUnusedAssets()
{ {
if (SimulationOnEditor) if (_simulationOnEditor)
{ {
for (int i = _providers.Count - 1; i >= 0; i--) for (int i = _providers.Count - 1; i >= 0; i--)
{ {
@@ -128,15 +132,22 @@ namespace YooAsset
Resources.UnloadUnusedAssets(); Resources.UnloadUnusedAssets();
} }
/// <summary> /// <summary>
/// 加载场景 /// 加载场景
/// </summary> /// </summary>
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority) public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
{ {
if (assetInfo.IsInvalid)
{
YooLogger.Warning(assetInfo.Error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
return completedProvider.CreateHandle<SceneOperationHandle>();
}
// 注意:场景句柄永远保持唯一 // 注意:场景句柄永远保持唯一
if (_sceneHandles.ContainsKey(scenePath)) string providerGUID = assetInfo.ProviderGUID;
return _sceneHandles[scenePath]; if (_sceneHandles.ContainsKey(providerGUID))
return _sceneHandles[providerGUID];
// 如果加载的是主场景,则卸载所有缓存的场景 // 如果加载的是主场景,则卸载所有缓存的场景
if (sceneMode == LoadSceneMode.Single) if (sceneMode == LoadSceneMode.Single)
@@ -144,68 +155,81 @@ namespace YooAsset
UnloadAllScene(); UnloadAllScene();
} }
ProviderBase provider = TryGetProvider(scenePath); ProviderBase provider = TryGetProvider(providerGUID);
if (provider == null) if (provider == null)
{ {
if (SimulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseSceneProvider(scenePath, sceneMode, activateOnLoad, priority); provider = new DatabaseSceneProvider(assetInfo, sceneMode, activateOnLoad, priority);
else else
provider = new BundledSceneProvider(scenePath, sceneMode, activateOnLoad, priority); provider = new BundledSceneProvider(assetInfo, sceneMode, activateOnLoad, priority);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
var handle = provider.CreateHandle() as SceneOperationHandle; var handle = provider.CreateHandle<SceneOperationHandle>();
_sceneHandles.Add(scenePath, handle); _sceneHandles.Add(providerGUID, handle);
return handle; return handle;
} }
/// <summary> /// <summary>
/// 加载资源对象 /// 加载资源对象
/// </summary> /// </summary>
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType) public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
{ {
ProviderBase provider = TryGetProvider(assetPath); if (assetInfo.IsInvalid)
{
YooLogger.Warning(assetInfo.Error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
return completedProvider.CreateHandle<AssetOperationHandle>();
}
ProviderBase provider = TryGetProvider(assetInfo.ProviderGUID);
if (provider == null) if (provider == null)
{ {
if (SimulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseAssetProvider(assetPath, assetType); provider = new DatabaseAssetProvider(assetInfo);
else else
provider = new BundledAssetProvider(assetPath, assetType); provider = new BundledAssetProvider(assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
return provider.CreateHandle() as AssetOperationHandle; return provider.CreateHandle<AssetOperationHandle>();
} }
/// <summary> /// <summary>
/// 加载子资源对象 /// 加载子资源对象
/// </summary> /// </summary>
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType) public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
{ {
ProviderBase provider = TryGetProvider(assetPath); if (assetInfo.IsInvalid)
{
YooLogger.Warning(assetInfo.Error);
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
}
ProviderBase provider = TryGetProvider(assetInfo.ProviderGUID);
if (provider == null) if (provider == null)
{ {
if (SimulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseSubAssetsProvider(assetPath, assetType); provider = new DatabaseSubAssetsProvider(assetInfo);
else else
provider = new BundledSubAssetsProvider(assetPath, assetType); provider = new BundledSubAssetsProvider(assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providers.Add(provider); _providers.Add(provider);
} }
return provider.CreateHandle() as SubAssetsOperationHandle; return provider.CreateHandle<SubAssetsOperationHandle>();
} }
internal static void UnloadSubScene(ProviderBase provider) internal static void UnloadSubScene(ProviderBase provider)
{ {
string scenePath = provider.AssetPath; string providerGUID = provider.MainAssetInfo.ProviderGUID;
if (_sceneHandles.ContainsKey(scenePath) == false) if (_sceneHandles.ContainsKey(providerGUID) == false)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 释放子场景句柄 // 释放子场景句柄
_sceneHandles[scenePath].ReleaseInternal(); _sceneHandles[providerGUID].ReleaseInternal();
_sceneHandles.Remove(scenePath); _sceneHandles.Remove(providerGUID);
// 卸载未被使用的资源(包括场景) // 卸载未被使用的资源(包括场景)
AssetSystem.UnloadUnusedAssets(); AssetSystem.UnloadUnusedAssets();
@@ -239,24 +263,19 @@ namespace YooAsset
} }
} }
internal static AssetBundleLoaderBase CreateOwnerAssetBundleLoader(string assetPath) internal static AssetBundleLoaderBase CreateOwnerAssetBundleLoader(AssetInfo assetInfo)
{ {
string bundleName = BundleServices.GetBundleName(assetPath); BundleInfo bundleInfo = BundleServices.GetBundleInfo(assetInfo);
BundleInfo bundleInfo = BundleServices.GetBundleInfo(bundleName);
return CreateAssetBundleLoaderInternal(bundleInfo); return CreateAssetBundleLoaderInternal(bundleInfo);
} }
internal static List<AssetBundleLoaderBase> CreateDependAssetBundleLoaders(string assetPath) internal static List<AssetBundleLoaderBase> CreateDependAssetBundleLoaders(AssetInfo assetInfo)
{ {
List<AssetBundleLoaderBase> result = new List<AssetBundleLoaderBase>(); BundleInfo[] depends = BundleServices.GetAllDependBundleInfos(assetInfo);
string[] depends = BundleServices.GetAllDependencies(assetPath); List<AssetBundleLoaderBase> result = new List<AssetBundleLoaderBase>(depends.Length);
if (depends != null) foreach (var bundleInfo in depends)
{ {
foreach (var dependBundleName in depends) AssetBundleLoaderBase dependLoader = CreateAssetBundleLoaderInternal(bundleInfo);
{ result.Add(dependLoader);
BundleInfo dependBundleInfo = BundleServices.GetBundleInfo(dependBundleName);
AssetBundleLoaderBase dependLoader = CreateAssetBundleLoaderInternal(dependBundleInfo);
result.Add(dependLoader);
}
} }
return result; return result;
} }
@@ -291,7 +310,7 @@ namespace YooAsset
for (int i = 0; i < _loaders.Count; i++) for (int i = 0; i < _loaders.Count; i++)
{ {
AssetBundleLoaderBase temp = _loaders[i]; AssetBundleLoaderBase temp = _loaders[i];
if (temp.BundleFileInfo.BundleName.Equals(bundleName)) if (temp.MainBundleInfo.BundleName.Equals(bundleName))
{ {
loader = temp; loader = temp;
break; break;
@@ -299,13 +318,13 @@ namespace YooAsset
} }
return loader; return loader;
} }
private static ProviderBase TryGetProvider(string assetPath) private static ProviderBase TryGetProvider(string providerGUID)
{ {
ProviderBase provider = null; ProviderBase provider = null;
for (int i = 0; i < _providers.Count; i++) for (int i = 0; i < _providers.Count; i++)
{ {
ProviderBase temp = _providers[i]; ProviderBase temp = _providers[i];
if (temp.AssetPath.Equals(assetPath)) if (temp.MainAssetInfo.ProviderGUID.Equals(providerGUID))
{ {
provider = temp; provider = temp;
break; break;
@@ -314,23 +333,23 @@ namespace YooAsset
return provider; return provider;
} }
#region #region
internal static void GetDebugReport(DebugReport report) internal static DebugReport GetDebugReport()
{ {
report.ClearAll(); DebugReport report = new DebugReport();
report.FrameCount = Time.frameCount;
report.BundleCount = _loaders.Count; report.BundleCount = _loaders.Count;
report.AssetCount = _providers.Count; report.AssetCount = _providers.Count;
foreach (var provider in _providers) foreach (var provider in _providers)
{ {
DebugProviderInfo providerInfo = new DebugProviderInfo(); DebugProviderInfo providerInfo = new DebugProviderInfo();
providerInfo.AssetPath = provider.AssetPath; providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
providerInfo.SpawnScene = provider.SpawnScene; providerInfo.SpawnScene = provider.SpawnScene;
providerInfo.SpawnTime = provider.SpawnTime; providerInfo.SpawnTime = provider.SpawnTime;
providerInfo.RefCount = provider.RefCount; providerInfo.RefCount = provider.RefCount;
providerInfo.Status = provider.Status; providerInfo.Status = (int)provider.Status;
providerInfo.BundleInfos.Clear(); providerInfo.BundleInfos = new List<DebugBundleInfo>();
report.ProviderInfos.Add(providerInfo); report.ProviderInfos.Add(providerInfo);
if (provider is BundledProvider) if (provider is BundledProvider)
@@ -342,6 +361,7 @@ namespace YooAsset
// 重新排序 // 重新排序
report.ProviderInfos.Sort(); report.ProviderInfos.Sort();
return report;
} }
#endregion #endregion
} }

View File

@@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
@@ -49,6 +50,17 @@ namespace YooAsset
} }
} }
/// <summary>
/// 获取资源对象
/// </summary>
/// <typeparam name="TAsset">资源类型</typeparam>
public TAsset GetAssetObject<TAsset>() where TAsset : UnityEngine.Object
{
if (IsValid == false)
return null;
return Provider.AssetObject as TAsset;
}
/// <summary> /// <summary>
/// 等待异步执行完毕 /// 等待异步执行完毕
/// </summary> /// </summary>
@@ -117,25 +129,27 @@ namespace YooAsset
if (Provider.AssetObject == null) if (Provider.AssetObject == null)
return null; return null;
GameObject result;
if (setPositionRotation) if (setPositionRotation)
{ {
if (parent == null) if (parent == null)
return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation); result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation);
else else
return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent); result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
} }
else else
{ {
if (parent == null) if (parent == null)
return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject); result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject);
else else
return UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent); result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
} }
return result;
} }
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation) private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
{ {
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation); InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation);
OperationSystem.ProcessOperaiton(operation); OperationSystem.StartOperaiton(operation);
return operation; return operation;
} }
} }

View File

@@ -4,16 +4,25 @@ namespace YooAsset
{ {
public abstract class OperationHandleBase : IEnumerator public abstract class OperationHandleBase : IEnumerator
{ {
private readonly string _cachedAssetPath; private readonly AssetInfo _assetInfo;
internal ProviderBase Provider { private set; get; } internal ProviderBase Provider { private set; get; }
internal OperationHandleBase(ProviderBase provider) internal OperationHandleBase(ProviderBase provider)
{ {
Provider = provider; Provider = provider;
_cachedAssetPath = provider.AssetPath; _assetInfo = provider.MainAssetInfo;
} }
internal abstract void InvokeCallback(); internal abstract void InvokeCallback();
/// <summary>
/// 获取资源信息
/// </summary>
public AssetInfo GetAssetInfo()
{
return _assetInfo;
}
/// <summary> /// <summary>
/// 当前状态 /// 当前状态
/// </summary> /// </summary>
@@ -85,14 +94,28 @@ namespace YooAsset
else else
{ {
if (Provider == null) if (Provider == null)
YooLogger.Warning($"Operation handle is released : {_cachedAssetPath}"); YooLogger.Warning($"Operation handle is released : {_assetInfo.AssetPath}");
else if (Provider.IsDestroyed) else if (Provider.IsDestroyed)
YooLogger.Warning($"Provider is destroyed : {_cachedAssetPath}"); YooLogger.Warning($"Provider is destroyed : {_assetInfo.AssetPath}");
return false; return false;
} }
} }
} }
/// <summary>
/// 句柄是否有效
/// </summary>
public bool IsValidNoWarning
{
get
{
if (Provider != null && Provider.IsDestroyed == false)
return true;
else
return false;
}
}
/// <summary> /// <summary>
/// 释放句柄 /// 释放句柄
/// </summary> /// </summary>

View File

@@ -102,7 +102,7 @@ namespace YooAsset
{ {
string error = $"{nameof(SceneOperationHandle)} is invalid."; string error = $"{nameof(SceneOperationHandle)} is invalid.";
var operation = new UnloadSceneOperation(error); var operation = new UnloadSceneOperation(error);
OperationSystem.ProcessOperaiton(operation); OperationSystem.StartOperaiton(operation);
return operation; return operation;
} }
@@ -112,7 +112,7 @@ namespace YooAsset
string error = $"Cannot unload main scene. Use {nameof(YooAssets.LoadSceneAsync)} method to change the main scene !"; string error = $"Cannot unload main scene. Use {nameof(YooAssets.LoadSceneAsync)} method to change the main scene !";
YooLogger.Error(error); YooLogger.Error(error);
var operation = new UnloadSceneOperation(error); var operation = new UnloadSceneOperation(error);
OperationSystem.ProcessOperaiton(operation); OperationSystem.StartOperaiton(operation);
return operation; return operation;
} }
@@ -121,7 +121,7 @@ namespace YooAsset
AssetSystem.UnloadSubScene(Provider); AssetSystem.UnloadSubScene(Provider);
{ {
var operation = new UnloadSceneOperation(sceneObject); var operation = new UnloadSceneOperation(sceneObject);
OperationSystem.ProcessOperaiton(operation); OperationSystem.StartOperaiton(operation);
return operation; return operation;
} }
} }

View File

@@ -1,4 +1,5 @@
 using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
public sealed class SubAssetsOperationHandle : OperationHandleBase public sealed class SubAssetsOperationHandle : OperationHandleBase
@@ -77,14 +78,35 @@ namespace YooAsset
if (IsValid == false) if (IsValid == false)
return null; return null;
foreach (var asset in Provider.AllAssetObjects) foreach (var assetObject in Provider.AllAssetObjects)
{ {
if (asset.name == assetName) if (assetObject.name == assetName)
return asset as TObject; return assetObject as TObject;
} }
YooLogger.Warning($"Not found sub asset object : {assetName}"); YooLogger.Warning($"Not found sub asset object : {assetName}");
return null; return null;
} }
/// <summary>
/// 获取所有的子资源对象集合
/// </summary>
/// <typeparam name="TObject">子资源对象类型</typeparam>
public TObject[] GetSubAssetObjects<TObject>() where TObject : UnityEngine.Object
{
if (IsValid == false)
return null;
List<TObject> ret = new List<TObject>(Provider.AllAssetObjects.Length);
foreach (var assetObject in Provider.AllAssetObjects)
{
var retObject = assetObject as TObject;
if (retObject != null)
ret.Add(retObject);
else
YooLogger.Warning($"The type conversion failed : {assetObject.name}");
}
return ret.ToArray();
}
} }
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.IO;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@@ -39,31 +40,33 @@ namespace YooAsset
if (_steps == ESteps.None) if (_steps == ESteps.None)
{ {
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None) if (MainBundleInfo.IsInvalid)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}"; LastError = $"The bundle info is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
return;
} }
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
{ {
_steps = ESteps.Download; _steps = ESteps.Download;
_fileLoadPath = BundleFileInfo.GetCacheLoadPath(); _fileLoadPath = MainBundleInfo.GetCacheLoadPath();
} }
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
_steps = ESteps.LoadFile; _steps = ESteps.LoadFile;
_fileLoadPath = BundleFileInfo.GetStreamingLoadPath(); _fileLoadPath = MainBundleInfo.GetStreamingLoadPath();
} }
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache) else if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{ {
_steps = ESteps.LoadFile; _steps = ESteps.LoadFile;
_fileLoadPath = BundleFileInfo.GetCacheLoadPath(); _fileLoadPath = MainBundleInfo.GetCacheLoadPath();
} }
else else
{ {
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString()); throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
} }
} }
@@ -71,7 +74,7 @@ namespace YooAsset
if (_steps == ESteps.Download) if (_steps == ESteps.Download)
{ {
int failedTryAgain = int.MaxValue; int failedTryAgain = int.MaxValue;
_downloader = DownloadSystem.BeginDownload(BundleFileInfo, failedTryAgain); _downloader = DownloadSystem.BeginDownload(MainBundleInfo, failedTryAgain);
_steps = ESteps.CheckDownload; _steps = ESteps.CheckDownload;
} }
@@ -109,12 +112,16 @@ namespace YooAsset
#endif #endif
// Load assetBundle file // Load assetBundle file
if (BundleFileInfo.IsEncrypted) if (MainBundleInfo.IsEncrypted)
{ {
if (AssetSystem.DecryptionServices == null) if (AssetSystem.DecryptionServices == null)
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {BundleFileInfo.BundleName}"); throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {MainBundleInfo.BundleName}");
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo); DecryptionFileInfo fileInfo = new DecryptionFileInfo();
fileInfo.BundleName = MainBundleInfo.BundleName;
fileInfo.BundleHash = MainBundleInfo.Hash;
fileInfo.BundleCRC = MainBundleInfo.CRC;
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(fileInfo);
if (_isWaitForAsyncComplete) if (_isWaitForAsyncComplete)
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset); CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
else else
@@ -154,8 +161,23 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = $"Failed to load assetBundle : {BundleFileInfo.BundleName}"; LastError = $"Failed to load assetBundle : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
// 注意当缓存文件的校验等级为Low的时候并不能保证缓存文件的完整性。
// 在AssetBundle文件加载失败的情况下我们需要重新验证文件的完整性
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{
string cacheLoadPath = MainBundleInfo.GetCacheLoadPath();
if (DownloadSystem.CheckContentIntegrity(EVerifyLevel.High, cacheLoadPath, MainBundleInfo.SizeBytes, MainBundleInfo.CRC) == false)
{
if (File.Exists(cacheLoadPath))
{
YooLogger.Error($"Delete the invalid cache file : {cacheLoadPath}");
File.Delete(cacheLoadPath);
}
}
}
} }
else else
{ {
@@ -183,7 +205,7 @@ namespace YooAsset
if (_isShowWaitForAsyncError == false) if (_isShowWaitForAsyncError == false)
{ {
_isShowWaitForAsyncError = true; _isShowWaitForAsyncError = true;
YooLogger.Error($"WaitForAsyncComplete failed ! BundleName : {BundleFileInfo.BundleName} States : {Status}"); YooLogger.Error($"WaitForAsyncComplete failed ! Try load bundle : {MainBundleInfo.BundleName} from remote with sync load method !");
} }
break; break;
} }

View File

@@ -17,7 +17,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 资源包文件信息 /// 资源包文件信息
/// </summary> /// </summary>
public BundleInfo BundleFileInfo { private set; get; } public BundleInfo MainBundleInfo { private set; get; }
/// <summary> /// <summary>
/// 引用计数 /// 引用计数
@@ -45,7 +45,7 @@ namespace YooAsset
public AssetBundleLoaderBase(BundleInfo bundleInfo) public AssetBundleLoaderBase(BundleInfo bundleInfo)
{ {
BundleFileInfo = bundleInfo; MainBundleInfo = bundleInfo;
RefCount = 0; RefCount = 0;
Status = EStatus.None; Status = EStatus.None;
} }
@@ -91,9 +91,9 @@ namespace YooAsset
if (forceDestroy == false) if (forceDestroy == false)
{ {
if (RefCount > 0) if (RefCount > 0)
throw new Exception($"Bundle file loader ref is not zero : {BundleFileInfo.BundleName}"); throw new Exception($"Bundle file loader ref is not zero : {MainBundleInfo.BundleName}");
if (IsDone() == false) if (IsDone() == false)
throw new Exception($"Bundle file loader is not done : {BundleFileInfo.BundleName}"); throw new Exception($"Bundle file loader is not done : {MainBundleInfo.BundleName}");
} }
if (CacheBundle != null) if (CacheBundle != null)

View File

@@ -20,6 +20,7 @@ namespace YooAsset
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private float _tryTimer = 0; private float _tryTimer = 0;
private string _webURL; private string _webURL;
private bool _isShowWaitForAsyncError = false;
private UnityWebRequest _webRequest; private UnityWebRequest _webRequest;
@@ -37,28 +38,30 @@ namespace YooAsset
if (_steps == ESteps.None) if (_steps == ESteps.None)
{ {
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None) if (MainBundleInfo.IsInvalid)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}"; LastError = $"The bundle info is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
return;
} }
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
if (MainBundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
_steps = ESteps.LoadFile; _steps = ESteps.LoadFile;
_webURL = BundleFileInfo.GetStreamingLoadPath(); _webURL = MainBundleInfo.GetStreamingLoadPath();
} }
else else
{ {
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString()); throw new System.NotImplementedException(MainBundleInfo.LoadMode.ToString());
} }
} }
// 1. 从服务器或缓存中获取AssetBundle文件 // 1. 从服务器或缓存中获取AssetBundle文件
if (_steps == ESteps.LoadFile) if (_steps == ESteps.LoadFile)
{ {
string hash = StringUtility.RemoveExtension(BundleFileInfo.Hash); string hash = StringUtility.RemoveExtension(MainBundleInfo.Hash);
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_webURL, Hash128.Parse(hash)); _webRequest = UnityWebRequestAssetBundle.GetAssetBundle(_webURL, Hash128.Parse(hash));
_webRequest.SendWebRequest(); _webRequest.SendWebRequest();
_steps = ESteps.CheckFile; _steps = ESteps.CheckFile;
@@ -87,7 +90,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EStatus.Failed; Status = EStatus.Failed;
LastError = $"AssetBundle file is invalid : {BundleFileInfo.BundleName}"; LastError = $"AssetBundle file is invalid : {MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
else else
@@ -116,7 +119,11 @@ namespace YooAsset
/// </summary> /// </summary>
public override void WaitForAsyncComplete() public override void WaitForAsyncComplete()
{ {
throw new System.NotImplementedException($"WebGL platform not support {nameof(WaitForAsyncComplete)}"); if (_isShowWaitForAsyncError == false)
{
_isShowWaitForAsyncError = true;
YooLogger.Error($"WebGL platform not support {nameof(WaitForAsyncComplete)} ! Use the async load method instead of the sync load method !");
}
} }
} }
} }

View File

@@ -12,9 +12,9 @@ namespace YooAsset
private readonly List<AssetBundleLoaderBase> _dependBundles; private readonly List<AssetBundleLoaderBase> _dependBundles;
public DependAssetBundleGroup(string assetPath) public DependAssetBundleGroup(List<AssetBundleLoaderBase> dpendBundles)
{ {
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath); _dependBundles = dpendBundles;
} }
/// <summary> /// <summary>
@@ -102,9 +102,9 @@ namespace YooAsset
foreach (var loader in _dependBundles) foreach (var loader in _dependBundles)
{ {
var bundleInfo = new DebugBundleInfo(); var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = loader.BundleFileInfo.BundleName; bundleInfo.BundleName = loader.MainBundleInfo.BundleName;
bundleInfo.RefCount = loader.RefCount; bundleInfo.RefCount = loader.RefCount;
bundleInfo.Status = loader.Status; bundleInfo.Status = (int)loader.Status;
output.Add(bundleInfo); output.Add(bundleInfo);
} }
} }

View File

@@ -51,6 +51,9 @@ namespace YooAsset
return; return;
} }
if (_handle.IsDone == false)
return;
if (_handle.AssetObject == null) if (_handle.AssetObject == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;

View File

@@ -7,7 +7,7 @@ namespace YooAsset
/// </summary> /// </summary>
public abstract class RawFileOperation : AsyncOperationBase public abstract class RawFileOperation : AsyncOperationBase
{ {
protected readonly BundleInfo _bundleInfo; internal readonly BundleInfo _bundleInfo;
/// <summary> /// <summary>
/// 原生文件的拷贝路径 /// 原生文件的拷贝路径
@@ -49,6 +49,34 @@ namespace YooAsset
} }
} }
/// <summary>
/// 发生错误的原生文件操作
/// </summary>
internal sealed class CompletedRawFileOperation : RawFileOperation
{
private readonly string _error;
internal CompletedRawFileOperation(string error, string copyPath) : base(null, copyPath)
{
_error = error;
}
internal override void Start()
{
Status = EOperationStatus.Failed;
Error = _error;
}
internal override void Update()
{
}
/// <summary>
/// 原生文件的缓存路径
/// </summary>
public override string GetCachePath()
{
return string.Empty;
}
}
/// <summary> /// <summary>
/// 编辑器下模拟运行的原生文件操作 /// 编辑器下模拟运行的原生文件操作
/// </summary> /// </summary>
@@ -175,7 +203,10 @@ namespace YooAsset
} }
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
_steps = ESteps.DownloadFromApk; if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash))
_steps = ESteps.CheckAndCopyFile;
else
_steps = ESteps.DownloadFromApk;
} }
else else
{ {
@@ -207,7 +238,17 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.CheckAndCopyFile; if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC))
{
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName);
_steps = ESteps.CheckAndCopyFile;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "File content verify failed !";
}
} }
_fileRequester.Dispose(); _fileRequester.Dispose();
} }
@@ -314,7 +355,10 @@ namespace YooAsset
} }
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming) else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
{ {
_steps = ESteps.DownloadFromApk; if (DownloadSystem.ContainsVerifyFile(_bundleInfo.Hash))
_steps = ESteps.CheckAndCopyFile;
else
_steps = ESteps.DownloadFromApk;
} }
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache) else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
{ {
@@ -377,7 +421,17 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.CheckAndCopyFile; if (DownloadSystem.CheckContentIntegrity(GetCachePath(), _bundleInfo.SizeBytes, _bundleInfo.CRC))
{
DownloadSystem.CacheVerifyFile(_bundleInfo.Hash, _bundleInfo.BundleName);
_steps = ESteps.CheckAndCopyFile;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "File content verify failed !";
}
} }
_fileRequester.Dispose(); _fileRequester.Dispose();
} }

View File

@@ -17,8 +17,7 @@ namespace YooAsset
} }
} }
public BundledAssetProvider(string assetPath, System.Type assetType) public BundledAssetProvider(AssetInfo assetInfo) : base(assetInfo)
: base(assetPath, assetType)
{ {
} }
public override void Update() public override void Update()
@@ -36,19 +35,19 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
DependBundles.WaitForAsyncComplete(); DependBundleGroup.WaitForAsyncComplete();
OwnerBundle.WaitForAsyncComplete(); OwnerBundle.WaitForAsyncComplete();
} }
if (DependBundles.IsDone() == false) if (DependBundleGroup.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundles.IsSucceed() == false) if (DependBundleGroup.IsSucceed() == false)
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = DependBundles.GetLastError(); LastError = DependBundleGroup.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }
@@ -69,17 +68,17 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
AssetObject = OwnerBundle.CacheBundle.LoadAsset(AssetName); AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
else else
AssetObject = OwnerBundle.CacheBundle.LoadAsset(AssetName, AssetType); AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
else else
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(AssetName); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath);
else else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(AssetName, AssetType); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
Status = EStatus.Checking; Status = EStatus.Checking;
} }
@@ -106,7 +105,10 @@ namespace YooAsset
Status = AssetObject == null ? EStatus.Fail : EStatus.Success; Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail) if (Status == EStatus.Fail)
{ {
LastError = $"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"; if(MainAssetInfo.AssetType == null)
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
else
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -6,15 +6,17 @@ namespace YooAsset
internal abstract class BundledProvider : ProviderBase internal abstract class BundledProvider : ProviderBase
{ {
protected AssetBundleLoaderBase OwnerBundle { private set; get; } protected AssetBundleLoaderBase OwnerBundle { private set; get; }
protected DependAssetBundleGroup DependBundles { private set; get; } protected DependAssetBundleGroup DependBundleGroup { private set; get; }
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType) public BundledProvider(AssetInfo assetInfo) : base(assetInfo)
{ {
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath); OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetInfo);
OwnerBundle.Reference(); OwnerBundle.Reference();
OwnerBundle.AddProvider(this); OwnerBundle.AddProvider(this);
DependBundles = new DependAssetBundleGroup(assetPath);
DependBundles.Reference(); var dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetInfo);
DependBundleGroup = new DependAssetBundleGroup(dependBundles);
DependBundleGroup.Reference();
} }
public override void Destroy() public override void Destroy()
{ {
@@ -26,10 +28,10 @@ namespace YooAsset
OwnerBundle.Release(); OwnerBundle.Release();
OwnerBundle = null; OwnerBundle = null;
} }
if (DependBundles != null) if (DependBundleGroup != null)
{ {
DependBundles.Release(); DependBundleGroup.Release();
DependBundles = null; DependBundleGroup = null;
} }
} }
@@ -39,12 +41,12 @@ namespace YooAsset
internal void GetBundleDebugInfos(List<DebugBundleInfo> output) internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
{ {
var bundleInfo = new DebugBundleInfo(); var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName; bundleInfo.BundleName = OwnerBundle.MainBundleInfo.BundleName;
bundleInfo.RefCount = OwnerBundle.RefCount; bundleInfo.RefCount = OwnerBundle.RefCount;
bundleInfo.Status = OwnerBundle.Status; bundleInfo.Status = (int)OwnerBundle.Status;
output.Add(bundleInfo); output.Add(bundleInfo);
DependBundles.GetBundleDebugInfos(output); DependBundleGroup.GetBundleDebugInfos(output);
} }
} }
} }

View File

@@ -1,5 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@@ -22,11 +23,10 @@ namespace YooAsset
} }
} }
public BundledSceneProvider(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority) public BundledSceneProvider(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(assetInfo)
: base(scenePath, null)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
_sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePath); _sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
_activateOnLoad = activateOnLoad; _activateOnLoad = activateOnLoad;
_priority = priority; _priority = priority;
} }
@@ -43,15 +43,15 @@ namespace YooAsset
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (Status == EStatus.CheckBundle)
{ {
if (DependBundles.IsDone() == false) if (DependBundleGroup.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundles.IsSucceed() == false) if (DependBundleGroup.IsSucceed() == false)
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = DependBundles.GetLastError(); LastError = DependBundleGroup.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }
@@ -98,7 +98,7 @@ namespace YooAsset
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail; Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
if(Status == EStatus.Fail) if(Status == EStatus.Fail)
{ {
LastError = $"The load scene is invalid : {AssetPath}"; LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -17,8 +17,7 @@ namespace YooAsset
} }
} }
public BundledSubAssetsProvider(string assetPath, System.Type assetType) public BundledSubAssetsProvider(AssetInfo assetInfo) : base(assetInfo)
: base(assetPath, assetType)
{ {
} }
public override void Update() public override void Update()
@@ -36,19 +35,19 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
DependBundles.WaitForAsyncComplete(); DependBundleGroup.WaitForAsyncComplete();
OwnerBundle.WaitForAsyncComplete(); OwnerBundle.WaitForAsyncComplete();
} }
if (DependBundles.IsDone() == false) if (DependBundleGroup.IsDone() == false)
return; return;
if (OwnerBundle.IsDone() == false) if (OwnerBundle.IsDone() == false)
return; return;
if (DependBundles.IsSucceed() == false) if (DependBundleGroup.IsSucceed() == false)
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = DependBundles.GetLastError(); LastError = DependBundleGroup.GetLastError();
InvokeCompletion(); InvokeCompletion();
return; return;
} }
@@ -69,17 +68,17 @@ namespace YooAsset
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName); AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
else else
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(AssetName, AssetType); AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
else else
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(AssetName); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath);
else else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(AssetName, AssetType); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
Status = EStatus.Checking; Status = EStatus.Checking;
} }
@@ -106,7 +105,10 @@ namespace YooAsset
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail) if (Status == EStatus.Fail)
{ {
LastError = $"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}"; if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
else
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -0,0 +1,33 @@

namespace YooAsset
{
internal sealed class CompletedProvider : ProviderBase
{
public override float Progress
{
get
{
if (IsDone)
return 1f;
else
return 0;
}
}
public CompletedProvider(AssetInfo assetInfo) : base(assetInfo)
{
}
public override void Update()
{
if (IsDone)
return;
if (Status == EStatus.None)
{
Status = EStatus.Fail;
LastError = MainAssetInfo.Error;
InvokeCompletion();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8e64fd2ee771f7d498838ebf375a9531
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,8 +17,7 @@ namespace YooAsset
} }
} }
public DatabaseAssetProvider(string assetPath, System.Type assetType) public DatabaseAssetProvider(AssetInfo assetInfo) : base(assetInfo)
: base(assetPath, assetType)
{ {
} }
public override void Update() public override void Update()
@@ -30,11 +29,11 @@ namespace YooAsset
if (Status == EStatus.None) if (Status == EStatus.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = $"Not found asset : {AssetPath}"; LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
InvokeCompletion(); InvokeCompletion();
return; return;
@@ -50,10 +49,10 @@ namespace YooAsset
// 1. 加载资源对象 // 1. 加载资源对象
if (Status == EStatus.Loading) if (Status == EStatus.Loading)
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(AssetPath); AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
else else
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(AssetPath, AssetType); AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
Status = EStatus.Checking; Status = EStatus.Checking;
} }
@@ -63,7 +62,10 @@ namespace YooAsset
Status = AssetObject == null ? EStatus.Fail : EStatus.Success; Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail) if (Status == EStatus.Fail)
{ {
LastError = $"Failed to load asset object : {AssetPath}"; if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
else
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -19,8 +19,7 @@ namespace YooAsset
} }
} }
public DatabaseSceneProvider(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority) public DatabaseSceneProvider(AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(assetInfo)
: base(scenePath, null)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
_activateOnLoad = activateOnLoad; _activateOnLoad = activateOnLoad;
@@ -42,7 +41,7 @@ namespace YooAsset
{ {
LoadSceneParameters loadSceneParameters = new LoadSceneParameters(); LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
loadSceneParameters.loadSceneMode = SceneMode; loadSceneParameters.loadSceneMode = SceneMode;
_asyncOp = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(AssetPath, loadSceneParameters); _asyncOp = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(MainAssetInfo.AssetPath, loadSceneParameters);
if (_asyncOp != null) if (_asyncOp != null)
{ {
_asyncOp.allowSceneActivation = true; _asyncOp.allowSceneActivation = true;
@@ -52,7 +51,7 @@ namespace YooAsset
else else
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = $"Failed to load scene : {AssetPath}"; LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
InvokeCompletion(); InvokeCompletion();
} }
@@ -70,7 +69,7 @@ namespace YooAsset
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail; Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
if (Status == EStatus.Fail) if (Status == EStatus.Fail)
{ {
LastError = $"The loaded scene is invalid : {AssetPath}"; LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -17,8 +17,7 @@ namespace YooAsset
} }
} }
public DatabaseSubAssetsProvider(string assetPath, System.Type assetType) public DatabaseSubAssetsProvider(AssetInfo assetInfo) : base(assetInfo)
: base(assetPath, assetType)
{ {
} }
public override void Update() public override void Update()
@@ -30,11 +29,11 @@ namespace YooAsset
if (Status == EStatus.None) if (Status == EStatus.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Fail; Status = EStatus.Fail;
LastError = $"Not found asset : {AssetPath}"; LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
InvokeCompletion(); InvokeCompletion();
return; return;
@@ -50,17 +49,17 @@ namespace YooAsset
// 1. 加载资源对象 // 1. 加载资源对象
if (Status == EStatus.Loading) if (Status == EStatus.Loading)
{ {
if (AssetType == null) if (MainAssetInfo.AssetType == null)
{ {
AllAssetObjects = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetPath); AllAssetObjects = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(MainAssetInfo.AssetPath);
} }
else else
{ {
UnityEngine.Object[] findAssets = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(AssetPath); UnityEngine.Object[] findAssets = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(MainAssetInfo.AssetPath);
List<UnityEngine.Object> result = new List<Object>(findAssets.Length); List<UnityEngine.Object> result = new List<Object>(findAssets.Length);
foreach (var findAsset in findAssets) foreach (var findAsset in findAssets)
{ {
if (AssetType.IsAssignableFrom(findAsset.GetType())) if (MainAssetInfo.AssetType.IsAssignableFrom(findAsset.GetType()))
result.Add(findAsset); result.Add(findAsset);
} }
AllAssetObjects = result.ToArray(); AllAssetObjects = result.ToArray();
@@ -74,7 +73,10 @@ namespace YooAsset
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success; Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
if (Status == EStatus.Fail) if (Status == EStatus.Fail)
{ {
LastError = $"Failed to load sub assets : {nameof(AssetType)} in {AssetPath}"; if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
else
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
YooLogger.Error(LastError); YooLogger.Error(LastError);
} }
InvokeCompletion(); InvokeCompletion();

View File

@@ -18,19 +18,9 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 资源路径 /// 资源信息
/// </summary> /// </summary>
public string AssetPath { private set; get; } public AssetInfo MainAssetInfo { private set; get; }
/// <summary>
/// 资源对象的名称
/// </summary>
public string AssetName { private set; get; }
/// <summary>
/// 资源对象的类型
/// </summary>
public System.Type AssetType { private set; get; }
/// <summary> /// <summary>
/// 获取的资源对象 /// 获取的资源对象
@@ -95,11 +85,9 @@ namespace YooAsset
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>(); private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
public ProviderBase(string assetPath, System.Type assetType) public ProviderBase(AssetInfo assetInfo)
{ {
AssetPath = assetPath; MainAssetInfo = assetInfo;
AssetName = System.IO.Path.GetFileName(assetPath);
AssetType = assetType;
} }
/// <summary> /// <summary>
@@ -126,25 +114,38 @@ namespace YooAsset
return RefCount <= 0; return RefCount <= 0;
} }
/// <summary>
/// 是否为场景提供者
/// </summary>
public bool IsSceneProvider()
{
if (this is BundledSceneProvider || this is DatabaseSceneProvider)
return true;
else
return false;
}
/// <summary> /// <summary>
/// 创建操作句柄 /// 创建操作句柄
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public OperationHandleBase CreateHandle() public T CreateHandle<T>() where T : OperationHandleBase
{ {
// 引用计数增加 // 引用计数增加
RefCount++; RefCount++;
OperationHandleBase handle; OperationHandleBase handle;
if (IsSceneProvider()) if (typeof(T) == typeof(AssetOperationHandle))
handle = new AssetOperationHandle(this);
else if (typeof(T) == typeof(SceneOperationHandle))
handle = new SceneOperationHandle(this); handle = new SceneOperationHandle(this);
else if (IsSubAssetsProvider()) else if (typeof(T) == typeof(SubAssetsOperationHandle))
handle = new SubAssetsOperationHandle(this); handle = new SubAssetsOperationHandle(this);
else else
handle = new AssetOperationHandle(this); throw new System.NotImplementedException();
_handles.Add(handle); _handles.Add(handle);
return handle; return handle as T;
} }
/// <summary> /// <summary>
@@ -175,7 +176,7 @@ namespace YooAsset
// 验证结果 // 验证结果
if (IsDone == false) if (IsDone == false)
{ {
YooLogger.Warning($"WaitForAsyncComplete failed to loading : {AssetPath}"); YooLogger.Warning($"WaitForAsyncComplete failed to loading : {MainAssetInfo.AssetPath}");
} }
} }
@@ -196,21 +197,6 @@ namespace YooAsset
} }
} }
public bool IsSceneProvider()
{
if (this is BundledSceneProvider || this is DatabaseSceneProvider)
return true;
else
return false;
}
public bool IsSubAssetsProvider()
{
if (this is BundledSubAssetsProvider || this is DatabaseSubAssetsProvider)
return true;
else
return false;
}
#region #region
private TaskCompletionSource<object> _taskCompletionSource; private TaskCompletionSource<object> _taskCompletionSource;
protected void InvokeCompletion() protected void InvokeCompletion()

View File

@@ -1,21 +1,23 @@
using System;
namespace YooAsset namespace YooAsset
{ {
[Serializable]
internal class DebugBundleInfo internal class DebugBundleInfo
{ {
/// <summary> /// <summary>
/// 资源包名称 /// 资源包名称
/// </summary> /// </summary>
public string BundleName { set; get; } public string BundleName;
/// <summary> /// <summary>
/// 引用计数 /// 引用计数
/// </summary> /// </summary>
public int RefCount { set; get; } public int RefCount;
/// <summary> /// <summary>
/// 加载状态 /// 加载状态
/// </summary> /// </summary>
public AssetBundleLoaderBase.EStatus Status { set; get; } public int Status;
} }
} }

Some files were not shown because too many files have changed in this diff Show More