Compare commits

...

32 Commits

Author SHA1 Message Date
何冠峰
b74a44dc36 update UIElements 2025-03-03 20:57:50 +08:00
何冠峰
6b36cdb5ee update AssetBundleDebugger
内置了新的UIElments的TreeViewer组件。
2025-03-03 18:28:02 +08:00
何冠峰
56ae1a8f95 update UIElements 2025-02-28 19:06:17 +08:00
何冠峰
3069b1d1f1 update diagnostic system 2025-02-28 18:38:18 +08:00
何冠峰
e7d346e4e1 update diagnostic system
调试窗口增加异步操作视图
2025-02-27 20:37:28 +08:00
何冠峰
7d9e00a574 update resource package 2025-02-27 18:15:02 +08:00
何冠峰
7382afe535 Update CHANGELOG.md 2025-02-27 17:43:10 +08:00
何冠峰
af7d4774d6 Update package.json 2025-02-27 17:43:02 +08:00
何冠峰
520a8a0623 code style 2025-02-27 17:14:20 +08:00
何冠峰
fbd0d8ec40 code style 2025-02-27 17:14:12 +08:00
何冠峰
3fea98ce4c fix #480 2025-02-27 17:13:49 +08:00
何冠峰
7c561ce254 update resource package 2025-02-27 17:01:26 +08:00
何冠峰
522ddb5115 update resource package
增加CustomPlayMode运行模式
2025-02-27 16:31:56 +08:00
何冠峰
47f5790507 update resource package
CreateBundleDownloader下载器增加参数:recursiveDownload
2025-02-27 10:31:05 +08:00
何冠峰
0cdcfe7f52 update file system 2025-02-26 19:31:06 +08:00
何冠峰
e4d69d869b update resource package
修复2.3.1版本 抖音和微信小游戏 下载器不生效的问题。
2025-02-26 14:22:59 +08:00
何冠峰
61afb70cb9 Update CHANGELOG.md 2025-02-25 14:17:41 +08:00
何冠峰
79580697a1 Update package.json 2025-02-25 14:17:32 +08:00
何冠峰
6cb74760b0 update extension sample 2025-02-25 14:06:36 +08:00
何冠峰
c758aa81ff update runtime code
重构了OperationSystem的机制。从列表模式修改为链模式
2025-02-25 12:18:16 +08:00
何冠峰
400c2ccefe code style 2025-02-22 16:29:25 +08:00
何冠峰
64e9734bbe update sapce shooter 2025-02-22 14:14:18 +08:00
何冠峰
f6244885be update diagnostic system
优化了Debugger窗口的显示页面
2025-02-22 14:14:05 +08:00
何冠峰
82c57c382f update TableView
支持Counter
2025-02-21 16:54:43 +08:00
何冠峰
7eacb46555 update resource package 2025-02-21 15:29:42 +08:00
何冠峰
d9c911d89b update asset bundle reporter 2025-02-20 18:50:26 +08:00
何冠峰
a3ceb3dcb6 update asset bundle builder 2025-02-20 12:04:42 +08:00
何冠峰
a5b68b28b2 update asset bundle builder 2025-02-20 11:27:44 +08:00
何冠峰
bd285faf37 update space shooter 2025-02-20 11:27:30 +08:00
何冠峰
8a4960b560 code style 2025-02-20 11:02:59 +08:00
何冠峰
83c6ae2057 update asset bundle builder
修复怀旧依赖模式下,TAG传染不正确的问题。
2025-02-20 11:01:25 +08:00
何冠峰
b71563e889 Update EBuildBundleType.cs 2025-02-20 10:02:12 +08:00
216 changed files with 3743 additions and 2964 deletions

View File

@@ -2,6 +2,55 @@
All notable changes to this package will be documented in this file. All notable changes to this package will be documented in this file.
## [2.3.2-preview] - 2025-02-27
### Fixed
- (2.3.1) 修复小游戏平台下载器不生效的问题。
- (#480) 修复了Unity工程打包导出时的报错。
### Added
- 下载器新增参数recursiveDownload
```csharp
/// <summary>
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包
public ResourceDownloaderOperation CreateBundleDownloader()
```
- 新增CustomPlayMode模式
```csharp
/// <summary>
/// 自定义运行模式的初始化参数
/// </summary>
public class CustomPlayModeParameters : InitializeParameters
{
/// <summary>
/// 文件系统初始化参数列表
/// 注意:列表最后一个元素作为主文件系统!
/// </summary>
public List<FileSystemParameters> FileSystemParameterList;
}
```
## [2.3.1-preview] - 2025-02-25
**资源加载依赖计算方式还原为了1.5x版本的模式,只加载资源对象实际依赖的资源包,不再以资源对象所在资源包的依赖关系为加载标准**。
### Improvements
- 优化OperationSystem的更新机制异步加载的耗时降低了50%。
- 优化了Debugger窗口的显示页面BundleView页面增加资源包的引用列表。
- 优化了Reporter窗口的显示页面。
### Fixed
- 修复了怀旧依赖模式下TAG传染不正确的问题。
## [2.3.0-preview] - 2025-02-19 ## [2.3.0-preview] - 2025-02-19
### Improvements ### Improvements

View File

@@ -326,7 +326,7 @@ namespace YooAsset.Editor
var column = new TableColumn("眼睛框", string.Empty, columnStyle); var column = new TableColumn("眼睛框", string.Empty, columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var toggle = new DisplayToggle(); var toggle = new ToggleDisplay();
toggle.text = string.Empty; toggle.text = string.Empty;
toggle.style.unityTextAlign = TextAnchor.MiddleCenter; toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); }); toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
@@ -334,11 +334,10 @@ namespace YooAsset.Editor
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{ {
var toggle = element as DisplayToggle; var toggle = element as ToggleDisplay;
toggle.userData = data; toggle.userData = data;
var tableData = data as ElementTableData; var tableData = data as ElementTableData;
toggle.SetValueWithoutNotify(tableData.Element.Hidden); toggle.SetValueWithoutNotify(tableData.Element.Hidden);
toggle.RefreshIcon();
}; };
_elementTableView.AddColumn(column); _elementTableView.AddColumn(column);
var headerElement = _elementTableView.GetHeaderElement("眼睛框"); var headerElement = _elementTableView.GetHeaderElement("眼睛框");
@@ -577,10 +576,8 @@ namespace YooAsset.Editor
// 重绘视图 // 重绘视图
RebuildView(); RebuildView();
} }
private void OnDisplayToggleValueChange(DisplayToggle toggle, ChangeEvent<bool> e) private void OnDisplayToggleValueChange(ToggleDisplay toggle, ChangeEvent<bool> e)
{ {
toggle.RefreshIcon();
// 处理自身 // 处理自身
toggle.SetValueWithoutNotify(e.newValue); toggle.SetValueWithoutNotify(e.newValue);
@@ -593,7 +590,8 @@ namespace YooAsset.Editor
foreach (var selectedItem in selectedItems) foreach (var selectedItem in selectedItems)
{ {
var selectElement = selectedItem as ElementTableData; var selectElement = selectedItem as ElementTableData;
selectElement.Element.Hidden = e.newValue; if (selectElement != null)
selectElement.Element.Hidden = e.newValue;
} }
// 重绘视图 // 重绘视图

View File

@@ -56,13 +56,13 @@ namespace YooAsset.Editor
public string EncryptedFilePath { set; get; } public string EncryptedFilePath { set; get; }
#endregion #endregion
private readonly HashSet<string> _assetPaths = new HashSet<string>(); private readonly Dictionary<string, BuildAssetInfo> _packAssetDic = new Dictionary<string, BuildAssetInfo>(100);
/// <summary> /// <summary>
/// 参与构建的资源列表 /// 参与构建的资源列表
/// 注意:不包含零依赖资源和冗余资源 /// 注意:不包含零依赖资源和冗余资源
/// </summary> /// </summary>
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>(); public readonly List<BuildAssetInfo> AllPackAssets = new List<BuildAssetInfo>(100);
/// <summary> /// <summary>
/// 资源包名称 /// 资源包名称
@@ -86,51 +86,68 @@ namespace YooAsset.Editor
public void PackAsset(BuildAssetInfo buildAsset) public void PackAsset(BuildAssetInfo buildAsset)
{ {
string assetPath = buildAsset.AssetInfo.AssetPath; string assetPath = buildAsset.AssetInfo.AssetPath;
if (_assetPaths.Contains(assetPath)) if (_packAssetDic.ContainsKey(assetPath))
throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}"); throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}");
_assetPaths.Add(assetPath); _packAssetDic.Add(assetPath, buildAsset);
MainAssets.Add(buildAsset); AllPackAssets.Add(buildAsset);
} }
/// <summary> /// <summary>
/// 是否包含指定资源 /// 是否包含指定资源
/// </summary> /// </summary>
public bool IsContainsAsset(string assetPath) public bool IsContainsPackAsset(string assetPath)
{ {
return _assetPaths.Contains(assetPath); return _packAssetDic.ContainsKey(assetPath);
} }
/// <summary> /// <summary>
/// 获取构建的资源路径列表 /// 获取构建的资源路径列表
/// </summary> /// </summary>
public string[] GetAllMainAssetPaths() public string[] GetAllPackAssetPaths()
{ {
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray(); return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
} }
/// <summary> /// <summary>
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源) /// 获取构建的主资源信息
/// </summary> /// </summary>
public List<string> GetAllBuiltinAssetPaths() public BuildAssetInfo GetPackAssetInfo(string assetPath)
{ {
var packAssets = GetAllMainAssetPaths(); if (_packAssetDic.TryGetValue(assetPath, out BuildAssetInfo value))
List<string> result = new List<string>(packAssets);
foreach (var buildAsset in MainAssets)
{ {
if (buildAsset.AllDependAssetInfos == null) return value;
continue; }
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos) else
{
throw new Exception($"Can not found pack asset info {assetPath} in bundle : {BundleName}");
}
}
/// <summary>
/// 获取资源包内部所有资产
/// </summary>
public List<AssetInfo> GetBundleContents()
{
Dictionary<string, AssetInfo> result = new Dictionary<string, AssetInfo>(AllPackAssets.Count);
foreach (var packAsset in AllPackAssets)
{
result.Add(packAsset.AssetInfo.AssetPath, packAsset.AssetInfo);
if (packAsset.AllDependAssetInfos != null)
{ {
// 注意:依赖资源里只添加零依赖资源和冗余资源 foreach (var dependAssetInfo in packAsset.AllDependAssetInfos)
if (dependAssetInfo.HasBundleName() == false)
{ {
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false) // 注意:依赖资源里只添加零依赖资源和冗余资源
result.Add(dependAssetInfo.AssetInfo.AssetPath); if (dependAssetInfo.HasBundleName() == false)
{
string dependAssetPath = dependAssetInfo.AssetInfo.AssetPath;
if (result.ContainsKey(dependAssetPath) == false)
result.Add(dependAssetPath, dependAssetInfo.AssetInfo);
}
} }
} }
} }
return result; return result.Values.ToList();
} }
/// <summary> /// <summary>
@@ -142,7 +159,7 @@ namespace YooAsset.Editor
AssetBundleBuild build = new AssetBundleBuild(); AssetBundleBuild build = new AssetBundleBuild();
build.assetBundleName = BundleName; build.assetBundleName = BundleName;
build.assetBundleVariant = string.Empty; build.assetBundleVariant = string.Empty;
build.assetNames = GetAllMainAssetPaths(); build.assetNames = GetAllPackAssetPaths();
return build; return build;
} }
@@ -151,7 +168,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public BuildAssetInfo[] GetAllManifestAssetInfos() public BuildAssetInfo[] GetAllManifestAssetInfos()
{ {
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
} }
/// <summary> /// <summary>

View File

@@ -51,12 +51,6 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string PackageNote; public string PackageNote;
/// <summary>
/// 旧版依赖模式
/// 说明兼容YooAssets1.5.x版本
/// </summary>
public bool LegacyDependency = false;
/// <summary> /// <summary>
/// 清空构建缓存文件 /// 清空构建缓存文件
/// </summary> /// </summary>

View File

@@ -31,7 +31,6 @@ namespace YooAsset.Editor
// 创建新补丁清单 // 创建新补丁清单
PackageManifest manifest = new PackageManifest(); PackageManifest manifest = new PackageManifest();
manifest.FileVersion = YooAssetSettings.ManifestFileVersion; manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
manifest.LegacyDependency = buildParameters.LegacyDependency;
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable; manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
manifest.LocationToLower = buildMapContext.Command.LocationToLower; manifest.LocationToLower = buildMapContext.Command.LocationToLower;
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID; manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
@@ -44,24 +43,20 @@ namespace YooAsset.Editor
manifest.AssetList = CreatePackageAssetList(buildMapContext); manifest.AssetList = CreatePackageAssetList(buildMapContext);
manifest.BundleList = CreatePackageBundleList(buildMapContext); manifest.BundleList = CreatePackageBundleList(buildMapContext);
// 处理资源清单的资源对象 // 1. 处理资源清单的资源对象
ProcessPacakgeAsset(manifest); ProcessPacakgeAsset(manifest);
// 处理资源包的依赖列表 // 2. 处理资源包的依赖列表
if (processBundleDepends) if (processBundleDepends)
ProcessBundleDepends(context, manifest); ProcessBundleDepends(context, manifest);
// 处理资源包的标签集合 // 3. 处理资源包的标签集合
if (processBundleTags) if (processBundleTags)
ProcessBundleTags(manifest); ProcessBundleTags(manifest);
#region YOOASSET_LEGACY_DEPENDENCY // 4. 处理内置资源包
if (buildParameters.LegacyDependency) if (processBundleDepends)
{ ProcessBuiltinBundleDependency(context, manifest);
if (processBundleDepends)
ProcessLegacyDependency(context, manifest);
}
#endregion
// 创建补丁清单文本文件 // 创建补丁清单文本文件
{ {
@@ -73,17 +68,13 @@ namespace YooAsset.Editor
// 创建补丁清单二进制文件 // 创建补丁清单二进制文件
string packageHash; string packageHash;
string packagePath;
{ {
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string filePath = $"{packageOutputDirectory}/{fileName}"; packagePath = $"{packageOutputDirectory}/{fileName}";
ManifestTools.SerializeToBinary(filePath, manifest); ManifestTools.SerializeToBinary(packagePath, manifest);
packageHash = HashUtility.FileCRC32(filePath); packageHash = HashUtility.FileCRC32(packagePath);
BuildLogger.Log($"Create package manifest file: {filePath}"); BuildLogger.Log($"Create package manifest file: {packagePath}");
ManifestContext manifestContext = new ManifestContext();
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
context.SetContextObject(manifestContext);
} }
// 创建补丁清单哈希文件 // 创建补丁清单哈希文件
@@ -101,6 +92,14 @@ namespace YooAsset.Editor
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion); FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
BuildLogger.Log($"Create package manifest version file: {filePath}"); BuildLogger.Log($"Create package manifest version file: {filePath}");
} }
// 填充上下文
{
ManifestContext manifestContext = new ManifestContext();
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
context.SetContextObject(manifestContext);
}
} }
/// <summary> /// <summary>
@@ -191,6 +190,14 @@ namespace YooAsset.Editor
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo; var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName); packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
} }
// 记录资源对象依赖的资源包ID集合
// 注意:依赖关系非引擎构建结果里查询!
foreach (var packageAsset in manifest.AssetList)
{
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
}
} }
/// <summary> /// <summary>
@@ -202,15 +209,18 @@ namespace YooAsset.Editor
foreach (var packageBundle in manifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName); int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
string[] depends = GetBundleDepends(context, packageBundle.BundleName); string[] dependNames = GetBundleDepends(context, packageBundle.BundleName);
List<int> dependIDs = new List<int>(depends.Length); List<int> dependIDs = new List<int>(dependNames.Length);
foreach (var dependBundleName in depends) foreach (var dependName in dependNames)
{ {
int bundleID = GetCachedBundleIndexID(dependBundleName); int dependBundleID = GetCachedBundleIndexID(dependName);
if (bundleID != mainBundleID) if (dependBundleID != mainBundleID)
dependIDs.Add(bundleID); dependIDs.Add(dependBundleID);
} }
packageBundle.DependIDs = dependIDs.ToArray();
// 排序并填充数据
dependIDs.Sort();
packageBundle.DependBundleIDs = dependIDs.ToArray();
} }
} }
@@ -219,23 +229,27 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private void ProcessBundleTags(PackageManifest manifest) private void ProcessBundleTags(PackageManifest manifest)
{ {
foreach (var packageBundle in manifest.BundleList)
{
packageBundle.Tags = Array.Empty<string>();
}
// 将主资源的标签信息传染给其依赖的资源包集合 // 将主资源的标签信息传染给其依赖的资源包集合
foreach (var packageAsset in manifest.AssetList) foreach (var packageAsset in manifest.AssetList)
{ {
var assetTags = packageAsset.AssetTags; var assetTags = packageAsset.AssetTags;
int bundleID = packageAsset.BundleID; int bundleID = packageAsset.BundleID;
CacheBundleTags(bundleID, assetTags); CacheBundleTags(bundleID, assetTags);
if (packageAsset.DependBundleIDs != null)
var packageBundle = manifest.BundleList[bundleID];
if (packageBundle.DependIDs != null)
{ {
foreach (var dependBundleID in packageBundle.DependIDs) foreach (var dependBundleID in packageAsset.DependBundleIDs)
{ {
CacheBundleTags(dependBundleID, assetTags); CacheBundleTags(dependBundleID, assetTags);
} }
} }
} }
// 将缓存的资源标签赋值给资源包
for (int index = 0; index < manifest.BundleList.Count; index++) for (int index = 0; index < manifest.BundleList.Count; index++)
{ {
var packageBundle = manifest.BundleList[index]; var packageBundle = manifest.BundleList[index];
@@ -284,46 +298,15 @@ namespace YooAsset.Editor
} }
#region YOOASSET_LEGACY_DEPENDENCY #region YOOASSET_LEGACY_DEPENDENCY
private class DependencyQuery private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
{ {
private readonly HashSet<int> _dependIDs;
public DependencyQuery(int[] dependIDs)
{
_dependIDs = new HashSet<int>(dependIDs);
}
public bool Contains(int bundleID)
{
return _dependIDs.Contains(bundleID);
}
}
private void ProcessLegacyDependency(BuildContext context, PackageManifest manifest)
{
foreach (var packageBundle in manifest.BundleList)
{
var dependIDs = packageBundle.DependIDs;
packageBundle.TempDataInEditor = new DependencyQuery(dependIDs);
}
// 记录资源对象依赖的资源包ID集合
// 注意:依赖关系非引擎构建结果里查询!
foreach (var packageAsset in manifest.AssetList)
{
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
}
// 记录引用该资源包的资源包ID集合
foreach (var packageBundle in manifest.BundleList)
{
packageBundle.ReferenceBundleIDs = GetBundleReferenceBundleIDs(manifest, packageBundle);
}
// 注意:如果是可编程构建管线,需要补充内置资源包 // 注意:如果是可编程构建管线,需要补充内置资源包
// 注意:该步骤依赖前面的操作! // 注意:该步骤依赖前面的操作!
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>(); var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (buildResultContext != null) if (buildResultContext != null)
{ {
// 注意:初始化资源清单建立引用关系
ManifestTools.InitManifest(manifest);
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName); ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName); ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
} }
@@ -387,26 +370,11 @@ namespace YooAsset.Editor
} }
} }
} }
return result.ToArray();
}
private int[] GetBundleReferenceBundleIDs(PackageManifest manifest, PackageBundle queryBundle)
{
int queryBundleID = GetCachedBundleIndexID(queryBundle.BundleName);
List<int> result = new List<int>();
foreach (var packageBundle in manifest.BundleList)
{
if (packageBundle == queryBundle)
continue;
var dependencyQuery = packageBundle.TempDataInEditor as DependencyQuery; // 排序并返回数据
if (dependencyQuery.Contains(queryBundleID)) List<int> listResult = new List<int>(result);
{ listResult.Sort();
int referenceBundleID = GetCachedBundleIndexID(packageBundle.BundleName); return listResult.ToArray();
if (result.Contains(referenceBundleID) == false)
result.Add(referenceBundleID);
}
}
return result.ToArray();
} }
#endregion #endregion
} }

View File

@@ -18,11 +18,7 @@ namespace YooAsset.Editor
// 概述信息 // 概述信息
{ {
#if UNITY_2019_4_OR_NEWER buildReport.Summary.YooVersion = EditorTools.GetPackageManagerYooVersion();
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.BuildDate = DateTime.Now.ToString(); buildReport.Summary.BuildDate = DateTime.Now.ToString();
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds; buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
@@ -38,37 +34,34 @@ namespace YooAsset.Editor
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable; buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower; buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID; buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders; buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
// 构建参数 // 构建参数
buildReport.Summary.LegacyDependency = buildParameters.LegacyDependency;
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles; buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB; buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule; buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName; buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline)) if (buildParameters is BuiltinBuildParameters)
{ {
var builtinBuildParameters = buildParameters as BuiltinBuildParameters; var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption; buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree; buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges; buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
} }
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline)) else if (buildParameters is ScriptableBuildParameters)
{ {
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters; var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption; buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree; buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges; buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
} buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
else buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
{ buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; buildReport.Summary.BuiltinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
buildReport.Summary.CompressOption = ECompressOption.Uncompressed; buildReport.Summary.MonoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
buildReport.Summary.DisableWriteTypeTree = false;
buildReport.Summary.IgnoreTypeTreeChanges = false;
} }
// 构建结果 // 构建结果
@@ -92,7 +85,8 @@ namespace YooAsset.Editor
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath); reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
reportAssetInfo.MainBundleName = mainBundle.BundleName; reportAssetInfo.MainBundleName = mainBundle.BundleName;
reportAssetInfo.MainBundleSize = mainBundle.FileSize; reportAssetInfo.MainBundleSize = mainBundle.FileSize;
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath); reportAssetInfo.DependAssets = GetAssetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
reportAssetInfo.DependBundles = GetAssetDependBundles(manifest, packageAsset);
buildReport.AssetInfos.Add(reportAssetInfo); buildReport.AssetInfos.Add(reportAssetInfo);
} }
@@ -108,8 +102,9 @@ namespace YooAsset.Editor
reportBundleInfo.FileSize = packageBundle.FileSize; reportBundleInfo.FileSize = packageBundle.FileSize;
reportBundleInfo.Encrypted = packageBundle.Encrypted; reportBundleInfo.Encrypted = packageBundle.Encrypted;
reportBundleInfo.Tags = packageBundle.Tags; reportBundleInfo.Tags = packageBundle.Tags;
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle); reportBundleInfo.DependBundles = GetBundleDependBundles(manifest, packageBundle);
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName); reportBundleInfo.ReferenceBundles = GetBundleReferenceBundles(manifest, packageBundle);
reportBundleInfo.BundleContents = GetBundleContents(buildMapContext, packageBundle.BundleName);
buildReport.BundleInfos.Add(reportBundleInfo); buildReport.BundleInfos.Add(reportBundleInfo);
} }
@@ -124,12 +119,28 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取资源对象依赖的所有资源 /// 获取资源对象依赖的其它所有资源
/// </summary> /// </summary>
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle) private List<AssetInfo> GetAssetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
{ {
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length); List<AssetInfo> result = new List<AssetInfo>();
foreach (int index in packageBundle.DependIDs) var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
var assetInfo = bundleInfo.GetPackAssetInfo(assetPath);
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
{
result.Add(dependAssetInfo.AssetInfo);
}
result.Sort();
return result;
}
/// <summary>
/// 获取资源对象依赖的资源包集合
/// </summary>
private List<string> GetAssetDependBundles(PackageManifest manifest, PackageAsset packageAsset)
{
List<string> dependBundles = new List<string>(packageAsset.DependBundleIDs.Length);
foreach (int index in packageAsset.DependBundleIDs)
{ {
string dependBundleName = manifest.BundleList[index].BundleName; string dependBundleName = manifest.BundleList[index].BundleName;
dependBundles.Add(dependBundleName); dependBundles.Add(dependBundleName);
@@ -139,42 +150,42 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 获取资源对象依赖的其它所有资源 /// 获取资源依赖的资源包集合
/// </summary> /// </summary>
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath) private List<string> GetBundleDependBundles(PackageManifest manifest, PackageBundle packageBundle)
{ {
List<string> result = new List<string>(); List<string> dependBundles = new List<string>(packageBundle.DependBundleIDs.Length);
var bundleInfo = buildMapContext.GetBundleInfo(bundleName); foreach (int index in packageBundle.DependBundleIDs)
{ {
BuildAssetInfo findAssetInfo = null; string dependBundleName = manifest.BundleList[index].BundleName;
foreach (var buildAsset in bundleInfo.MainAssets) dependBundles.Add(dependBundleName);
{
if (buildAsset.AssetInfo.AssetPath == assetPath)
{
findAssetInfo = buildAsset;
break;
}
}
if (findAssetInfo == null)
{
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
}
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
{
result.Add(dependAssetInfo.AssetInfo.AssetPath);
}
} }
result.Sort(); dependBundles.Sort();
return result; return dependBundles;
} }
/// <summary> /// <summary>
/// 获取该资源包内的所有资源 /// 获取引用该资源包的资源包集合
/// </summary> /// </summary>
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName) private List<string> GetBundleReferenceBundles(PackageManifest manifest, PackageBundle packageBundle)
{
List<string> referenceBundles = new List<string>(packageBundle.ReferenceBundleIDs.Count);
foreach (int index in packageBundle.ReferenceBundleIDs)
{
string dependBundleName = manifest.BundleList[index].BundleName;
referenceBundles.Add(dependBundleName);
}
referenceBundles.Sort();
return referenceBundles;
}
/// <summary>
/// 获取资源包内部所有资产
/// </summary>
private List<AssetInfo> GetBundleContents(BuildMapContext buildMapContext, string bundleName)
{ {
var bundleInfo = buildMapContext.GetBundleInfo(bundleName); var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
List<string> result = bundleInfo.GetAllBuiltinAssetPaths(); List<AssetInfo> result = bundleInfo.GetBundleContents();
result.Sort(); result.Sort();
return result; return result;
} }

View File

@@ -45,7 +45,7 @@ namespace YooAsset.Editor
{ {
long tempSize = 0; long tempSize = 0;
var assetPaths = bundleInfo.GetAllMainAssetPaths(); var assetPaths = bundleInfo.GetAllPackAssetPaths();
foreach (var assetPath in assetPaths) foreach (var assetPath in assetPaths)
{ {
long size = FileUtility.GetFileSize(assetPath); long size = FileUtility.GetFileSize(assetPath);

View File

@@ -23,7 +23,7 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
foreach (var buildAsset in bundleInfo.MainAssets) foreach (var buildAsset in bundleInfo.AllPackAssets)
{ {
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true); EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
} }

View File

@@ -27,7 +27,7 @@ namespace YooAsset.Editor
// 注意:原生文件资源包只能包含一个原生文件 // 注意:原生文件资源包只能包含一个原生文件
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
if (bundleInfo.MainAssets.Count != 1) if (bundleInfo.AllPackAssets.Count != 1)
{ {
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}"); string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
throw new Exception(message); throw new Exception(message);

View File

@@ -37,7 +37,6 @@ namespace YooAsset.Editor
buildParameters.BuildTarget = BuildTarget; buildParameters.BuildTarget = BuildTarget;
buildParameters.PackageName = PackageName; buildParameters.PackageName = PackageName;
buildParameters.PackageVersion = GetPackageVersion(); buildParameters.PackageVersion = GetPackageVersion();
buildParameters.LegacyDependency = false;
buildParameters.EnableSharePackRule = true; buildParameters.EnableSharePackRule = true;
buildParameters.VerifyBuildingResult = true; buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = fileNameStyle; buildParameters.FileNameStyle = fileNameStyle;

View File

@@ -38,7 +38,6 @@ namespace YooAsset.Editor
buildParameters.BuildTarget = BuildTarget; buildParameters.BuildTarget = BuildTarget;
buildParameters.PackageName = PackageName; buildParameters.PackageName = PackageName;
buildParameters.PackageVersion = GetPackageVersion(); buildParameters.PackageVersion = GetPackageVersion();
buildParameters.LegacyDependency = false;
buildParameters.EnableSharePackRule = true; buildParameters.EnableSharePackRule = true;
buildParameters.VerifyBuildingResult = true; buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = fileNameStyle; buildParameters.FileNameStyle = fileNameStyle;

View File

@@ -38,16 +38,22 @@ namespace YooAsset.Editor
/// 资源包视图 /// 资源包视图
/// </summary> /// </summary>
BundleView, BundleView,
/// <summary>
/// 异步操作视图
/// </summary>
OperationView,
} }
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>(); private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
private Label _playerName; private ToolbarButton _playerName;
private ToolbarMenu _viewModeMenu; private ToolbarMenu _viewModeMenu;
private SliderInt _frameSlider; private SliderInt _frameSlider;
private DebuggerAssetListViewer _assetListViewer; private DebuggerAssetListViewer _assetListViewer;
private DebuggerBundleListViewer _bundleListViewer; private DebuggerBundleListViewer _bundleListViewer;
private DebuggerOperationListViewer _operationListViewer;
private EViewMode _viewMode; private EViewMode _viewMode;
private string _searchKeyWord; private string _searchKeyWord;
@@ -78,13 +84,14 @@ namespace YooAsset.Editor
exportBtn.clicked += ExportBtn_clicked; exportBtn.clicked += ExportBtn_clicked;
// 用户列表菜单 // 用户列表菜单
_playerName = root.Q<Label>("PlayerName"); _playerName = root.Q<ToolbarButton>("PlayerName");
_playerName.text = "Editor player"; _playerName.text = "Editor player";
// 视口模式菜单 // 视口模式菜单
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu"); _viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView); _viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView); _viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
_viewModeMenu.menu.AppendAction(EViewMode.OperationView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.OperationView);
_viewModeMenu.text = EViewMode.AssetView.ToString(); _viewModeMenu.text = EViewMode.AssetView.ToString();
// 搜索栏 // 搜索栏
@@ -111,6 +118,9 @@ namespace YooAsset.Editor
var frameClear = root.Q<ToolbarButton>("FrameClear"); var frameClear = root.Q<ToolbarButton>("FrameClear");
frameClear.clicked += OnFrameClear_clicked; frameClear.clicked += OnFrameClear_clicked;
var recorderToggle = root.Q<ToggleRecord>("FrameRecord");
recorderToggle.RegisterValueChangedCallback(OnRecordToggleValueChange);
} }
// 加载视图 // 加载视图
@@ -121,6 +131,10 @@ namespace YooAsset.Editor
_bundleListViewer = new DebuggerBundleListViewer(); _bundleListViewer = new DebuggerBundleListViewer();
_bundleListViewer.InitViewer(); _bundleListViewer.InitViewer();
// 加载视图
_operationListViewer = new DebuggerOperationListViewer();
_operationListViewer.InitViewer();
// 显示视图 // 显示视图
_viewMode = EViewMode.AssetView; _viewMode = EViewMode.AssetView;
_assetListViewer.AttachParent(root); _assetListViewer.AttachParent(root);
@@ -129,8 +143,9 @@ namespace YooAsset.Editor
EditorConnection.instance.Initialize(); EditorConnection.instance.Initialize();
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent); EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent); EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage); EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport; RemoteEditorConnection.Instance.Initialize();
RemoteEditorConnection.Instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
} }
catch (Exception e) catch (Exception e)
{ {
@@ -142,7 +157,8 @@ namespace YooAsset.Editor
// 远程调试 // 远程调试
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent); EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent); EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage); EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor);
_playerSessions.Clear(); _playerSessions.Clear();
} }
@@ -159,10 +175,7 @@ namespace YooAsset.Editor
private void OnHandlePlayerMessage(MessageEventArgs args) private void OnHandlePlayerMessage(MessageEventArgs args)
{ {
var debugReport = DebugReport.Deserialize(args.data); var debugReport = DebugReport.Deserialize(args.data);
OnHandleDebugReport(args.playerId, debugReport); int playerId = args.playerId;
}
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
{
Debug.Log($"Handle player {playerId} debug report !"); Debug.Log($"Handle player {playerId} debug report !");
_currentPlayerSession = GetOrCreatePlayerSession(playerId); _currentPlayerSession = GetOrCreatePlayerSession(playerId);
_currentPlayerSession.AddDebugReport(debugReport); _currentPlayerSession.AddDebugReport(debugReport);
@@ -207,8 +220,19 @@ namespace YooAsset.Editor
_currentPlayerSession.ClearDebugReport(); _currentPlayerSession.ClearDebugReport();
_assetListViewer.ClearView(); _assetListViewer.ClearView();
_bundleListViewer.ClearView(); _bundleListViewer.ClearView();
_operationListViewer.ClearView();
} }
} }
private void OnRecordToggleValueChange(ChangeEvent<bool> evt)
{
// 发送采集数据的命令
RemoteCommand command = new RemoteCommand();
command.CommandType = (int)ERemoteCommand.SampleAuto;
command.CommandParam = evt.newValue ? "open" : "close";
byte[] data = RemoteCommand.Serialize(command);
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId) private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{ {
@@ -242,6 +266,7 @@ namespace YooAsset.Editor
_frameSlider.label = $"Frame: {debugReport.FrameCount}"; _frameSlider.label = $"Frame: {debugReport.FrameCount}";
_assetListViewer.FillViewData(debugReport); _assetListViewer.FillViewData(debugReport);
_bundleListViewer.FillViewData(debugReport); _bundleListViewer.FillViewData(debugReport);
_operationListViewer.FillViewData(debugReport);
} }
} }
@@ -252,8 +277,8 @@ namespace YooAsset.Editor
command.CommandType = (int)ERemoteCommand.SampleOnce; command.CommandType = (int)ERemoteCommand.SampleOnce;
command.CommandParam = string.Empty; command.CommandParam = string.Empty;
byte[] data = RemoteCommand.Serialize(command); byte[] data = RemoteCommand.Serialize(command);
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data); EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
RemoteDebuggerInRuntime.EditorRequestDebugReport(); RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
} }
private void ExportBtn_clicked() private void ExportBtn_clicked()
{ {
@@ -272,7 +297,7 @@ namespace YooAsset.Editor
packageData.ProviderInfos.Sort(); packageData.ProviderInfos.Sort();
foreach (var providerInfo in packageData.ProviderInfos) foreach (var providerInfo in packageData.ProviderInfos)
{ {
providerInfo.DependBundleInfos.Sort(); providerInfo.DependBundles.Sort();
} }
} }
@@ -288,6 +313,7 @@ namespace YooAsset.Editor
{ {
_assetListViewer.RebuildView(_searchKeyWord); _assetListViewer.RebuildView(_searchKeyWord);
_bundleListViewer.RebuildView(_searchKeyWord); _bundleListViewer.RebuildView(_searchKeyWord);
_operationListViewer.RebuildView(_searchKeyWord);
} }
} }
private void OnViewModeMenuChange(DropdownMenuAction action) private void OnViewModeMenuChange(DropdownMenuAction action)
@@ -303,11 +329,19 @@ namespace YooAsset.Editor
{ {
_assetListViewer.AttachParent(root); _assetListViewer.AttachParent(root);
_bundleListViewer.DetachParent(); _bundleListViewer.DetachParent();
_operationListViewer.DetachParent();
} }
else if (viewMode == EViewMode.BundleView) else if (viewMode == EViewMode.BundleView)
{ {
_assetListViewer.DetachParent(); _assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root); _bundleListViewer.AttachParent(root);
_operationListViewer.DetachParent();
}
else if (viewMode == EViewMode.OperationView)
{
_assetListViewer.DetachParent();
_bundleListViewer.DetachParent();
_operationListViewer.AttachParent(root);
} }
else else
{ {

View File

@@ -1,7 +1,7 @@
<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="TopToolbar" 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: lower-left; padding-left: 5px;" /> <uie:ToolbarButton text="IP" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px;" />
<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: 150px; 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="Refresh" 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="Refresh" 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="Export" display-tooltip-when-elided="true" name="ExportButton" 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="Export" display-tooltip-when-elided="true" name="ExportButton" 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;" />
@@ -11,5 +11,6 @@
<uie:ToolbarButton text=" &lt;&lt; " display-tooltip-when-elided="true" name="FrameLast" /> <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=" &gt;&gt; " display-tooltip-when-elided="true" name="FrameNext" />
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" /> <uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
<YooAsset.Editor.ToggleRecord name="FrameRecord" style="width: 20px;" />
</uie:Toolbar> </uie:Toolbar>
</ui:UXML> </ui:UXML>

View File

@@ -13,6 +13,7 @@ namespace YooAsset.Editor
{ {
private class ProviderTableData : DefaultTableData private class ProviderTableData : DefaultTableData
{ {
public DebugPackageData PackageData;
public DebugProviderInfo ProviderInfo; public DebugProviderInfo ProviderInfo;
} }
private class DependTableData : DefaultTableData private class DependTableData : DefaultTableData
@@ -26,7 +27,6 @@ namespace YooAsset.Editor
private TableView _providerTableView; private TableView _providerTableView;
private TableView _dependTableView; private TableView _dependTableView;
private DebugReport _debugReport;
private List<ITableData> _sourceDatas; private List<ITableData> _sourceDatas;
@@ -52,13 +52,12 @@ namespace YooAsset.Editor
_dependTableView = _root.Q<TableView>("BottomTableView"); _dependTableView = _root.Q<TableView>("BottomTableView");
CreateDependTableViewColumns(); CreateDependTableViewColumns();
#if UNITY_2020_3_OR_NEWER // 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup"); var topGroup = _root.Q<VisualElement>("TopGroup");
var bottomGroup = _root.Q<VisualElement>("BottomGroup"); var bottomGroup = _root.Q<VisualElement>("BottomGroup");
topGroup.style.minHeight = 100; topGroup.style.minHeight = 100;
bottomGroup.style.minHeight = 100f; bottomGroup.style.minHeight = 100f;
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup); UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
#endif
} }
private void CreateAssetTableViewColumns() private void CreateAssetTableViewColumns()
{ {
@@ -89,6 +88,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("AssetPath", "Asset Path", columnStyle); var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -125,13 +125,13 @@ namespace YooAsset.Editor
_providerTableView.AddColumn(column); _providerTableView.AddColumn(column);
} }
// SpawnTime // BeginTime
{ {
var columnStyle = new ColumnStyle(100); var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle); var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var label = new Label(); var label = new Label();
@@ -205,7 +205,7 @@ namespace YooAsset.Editor
{ {
StyleColor textColor; StyleColor textColor;
var providerTableData = data as ProviderTableData; var providerTableData = data as ProviderTableData;
if(providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString()) if (providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow); textColor = new StyleColor(Color.yellow);
else else
textColor = new StyleColor(Color.white); textColor = new StyleColor(Color.white);
@@ -225,6 +225,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle); var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -296,8 +297,6 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void FillViewData(DebugReport debugReport) public void FillViewData(DebugReport debugReport)
{ {
_debugReport = debugReport;
// 清空旧数据 // 清空旧数据
_providerTableView.ClearAll(false, true); _providerTableView.ClearAll(false, true);
_dependTableView.ClearAll(false, true); _dependTableView.ClearAll(false, true);
@@ -309,11 +308,12 @@ namespace YooAsset.Editor
foreach (var providerInfo in packageData.ProviderInfos) foreach (var providerInfo in packageData.ProviderInfos)
{ {
var rowData = new ProviderTableData(); var rowData = new ProviderTableData();
rowData.PackageData = packageData;
rowData.ProviderInfo = providerInfo; rowData.ProviderInfo = providerInfo;
rowData.AddAssetPathCell("PackageName", packageData.PackageName); rowData.AddAssetPathCell("PackageName", packageData.PackageName);
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath); rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene); rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime); rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime); rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime);
rowData.AddLongValueCell("RefCount", providerInfo.RefCount); rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
rowData.AddStringValueCell("Status", providerInfo.Status.ToString()); rowData.AddStringValueCell("Status", providerInfo.Status.ToString());
@@ -331,7 +331,6 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void ClearView() public void ClearView()
{ {
_debugReport = null;
_providerTableView.ClearAll(false, true); _providerTableView.ClearAll(false, true);
_dependTableView.ClearAll(false, true); _dependTableView.ClearAll(false, true);
RebuildView(null); RebuildView(null);
@@ -368,12 +367,14 @@ namespace YooAsset.Editor
private void OnProviderTableViewSelectionChanged(ITableData data) private void OnProviderTableViewSelectionChanged(ITableData data)
{ {
var providerTableData = data as ProviderTableData; var providerTableData = data as ProviderTableData;
DebugPackageData packageData = providerTableData.PackageData;
DebugProviderInfo providerInfo = providerTableData.ProviderInfo; DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
// 填充依赖数据 // 填充依赖数据
var sourceDatas = new List<ITableData>(providerInfo.DependBundleInfos.Count); var sourceDatas = new List<ITableData>(providerInfo.DependBundles.Count);
foreach (var dependBundleInfo in providerInfo.DependBundleInfos) foreach (var bundleName in providerInfo.DependBundles)
{ {
var dependBundleInfo = packageData.GetBundleInfo(bundleName);
var rowData = new DependTableData(); var rowData = new DependTableData();
rowData.BundleInfo = dependBundleInfo; rowData.BundleInfo = dependBundleInfo;
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName); rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);

View File

@@ -13,21 +13,25 @@ namespace YooAsset.Editor
{ {
private class BundleTableData : DefaultTableData private class BundleTableData : DefaultTableData
{ {
public string PackageName; public DebugPackageData PackageData;
public DebugBundleInfo BundleInfo; public DebugBundleInfo BundleInfo;
} }
private class UsingTableData : DefaultTableData private class UsingTableData : DefaultTableData
{ {
public DebugProviderInfo ProviderInfo; public DebugProviderInfo ProviderInfo;
} }
private class ReferenceTableData : DefaultTableData
{
public DebugBundleInfo BundleInfo;
}
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
private TableView _bundleTableView; private TableView _bundleTableView;
private TableView _usingTableView; private TableView _usingTableView;
private TableView _referenceTableView;
private DebugReport _debugReport;
private List<ITableData> _sourceDatas; private List<ITableData> _sourceDatas;
/// <summary> /// <summary>
@@ -44,21 +48,25 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
// 资源包列表 // 资源包列表
_bundleTableView = _root.Q<TableView>("TopTableView"); _bundleTableView = _root.Q<TableView>("BundleTableView");
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged; _bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
CreateBundleTableViewColumns(); CreateBundleTableViewColumns();
// 使用列表 // 使用列表
_usingTableView = _root.Q<TableView>("BottomTableView"); _usingTableView = _root.Q<TableView>("UsingTableView");
CreateUsingTableViewColumns(); CreateUsingTableViewColumns();
#if UNITY_2020_3_OR_NEWER // 引用列表
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
CreateReferenceTableViewColumns();
// 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup"); var topGroup = _root.Q<VisualElement>("TopGroup");
var bottomGroup = _root.Q<VisualElement>("BottomGroup"); var bottomGroup = _root.Q<VisualElement>("BottomGroup");
topGroup.style.minHeight = 100; topGroup.style.minHeight = 100;
bottomGroup.style.minHeight = 100f; bottomGroup.style.minHeight = 100f;
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup); UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
#endif UIElementsTools.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
} }
private void CreateBundleTableViewColumns() private void CreateBundleTableViewColumns()
{ {
@@ -89,6 +97,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("BundleName", "Bundle Name", columnStyle); var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -162,6 +171,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("UsingAssets", "Using Assets", columnStyle); var column = new TableColumn("UsingAssets", "Using Assets", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -198,13 +208,13 @@ namespace YooAsset.Editor
_usingTableView.AddColumn(column); _usingTableView.AddColumn(column);
} }
// SpawnTime // BeginTime
{ {
var columnStyle = new ColumnStyle(100); var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle); var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var label = new Label(); var label = new Label();
@@ -269,41 +279,105 @@ namespace YooAsset.Editor
_usingTableView.AddColumn(column); _usingTableView.AddColumn(column);
} }
} }
private void CreateReferenceTableViewColumns()
{
// BundleName
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_referenceTableView.AddColumn(column);
}
// RefCount
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_referenceTableView.AddColumn(column);
}
// Status
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("Status", "Status", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
StyleColor textColor;
var feferenceTableData = data as ReferenceTableData;
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
infoLabel.style.color = textColor;
};
_referenceTableView.AddColumn(column);
}
}
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
public void FillViewData(DebugReport debugReport) public void FillViewData(DebugReport debugReport)
{ {
_debugReport = debugReport;
// 清空旧数据 // 清空旧数据
_bundleTableView.ClearAll(false, true); _bundleTableView.ClearAll(false, true);
_usingTableView.ClearAll(false, true); _usingTableView.ClearAll(false, true);
_referenceTableView.ClearAll(false, true);
// 填充数据源 // 填充数据源
_sourceDatas = new List<ITableData>(1000); _sourceDatas = new List<ITableData>(1000);
foreach (var packageData in debugReport.PackageDatas) foreach (var packageData in debugReport.PackageDatas)
{ {
var tempDic = new HashSet<string>(); foreach (var bundleInfo in packageData.BundleInfos)
foreach (var providerInfo in packageData.ProviderInfos)
{ {
foreach (var bundleInfo in providerInfo.DependBundleInfos) var rowData = new BundleTableData();
{ rowData.PackageData = packageData;
if (tempDic.Contains(bundleInfo.BundleName) == false) rowData.BundleInfo = bundleInfo;
{ rowData.AddAssetPathCell("PackageName", packageData.PackageName);
tempDic.Add(bundleInfo.BundleName); rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
var rowData = new BundleTableData(); rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
rowData.PackageName = packageData.PackageName; _sourceDatas.Add(rowData);
rowData.BundleInfo = bundleInfo;
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
_sourceDatas.Add(rowData);
}
}
} }
} }
_bundleTableView.itemsSource = _sourceDatas; _bundleTableView.itemsSource = _sourceDatas;
@@ -317,11 +391,12 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void ClearView() public void ClearView()
{ {
_debugReport = null;
_bundleTableView.ClearAll(false, true); _bundleTableView.ClearAll(false, true);
_bundleTableView.RebuildView(); _bundleTableView.RebuildView();
_usingTableView.ClearAll(false, true); _usingTableView.ClearAll(false, true);
_usingTableView.RebuildView(); _usingTableView.RebuildView();
_referenceTableView.ClearAll(false, true);
_referenceTableView.RebuildView();
} }
/// <summary> /// <summary>
@@ -355,25 +430,23 @@ namespace YooAsset.Editor
private void OnBundleTableViewSelectionChanged(ITableData data) private void OnBundleTableViewSelectionChanged(ITableData data)
{ {
var bundleTableData = data as BundleTableData; var bundleTableData = data as BundleTableData;
var packageData = bundleTableData.PackageData;
var selectBundleInfo = bundleTableData.BundleInfo;
// 填充依赖数据 // 填充UsingTableView
var sourceDatas = new List<ITableData>(1000);
foreach (var packageData in _debugReport.PackageDatas)
{ {
if (packageData.PackageName != bundleTableData.PackageName) var sourceDatas = new List<ITableData>(1000);
continue;
foreach (var providerInfo in packageData.ProviderInfos) foreach (var providerInfo in packageData.ProviderInfos)
{ {
foreach (var bundleInfo in providerInfo.DependBundleInfos) foreach (var dependBundleName in providerInfo.DependBundles)
{ {
if (bundleInfo.BundleName == bundleTableData.BundleInfo.BundleName) if (dependBundleName == selectBundleInfo.BundleName)
{ {
var rowData = new UsingTableData(); var rowData = new UsingTableData();
rowData.ProviderInfo = providerInfo; rowData.ProviderInfo = providerInfo;
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath); rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene); rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime); rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
rowData.AddLongValueCell("RefCount", providerInfo.RefCount); rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
rowData.AddStringValueCell("Status", providerInfo.Status); rowData.AddStringValueCell("Status", providerInfo.Status);
sourceDatas.Add(rowData); sourceDatas.Add(rowData);
@@ -381,9 +454,26 @@ namespace YooAsset.Editor
} }
} }
} }
_usingTableView.itemsSource = sourceDatas;
_usingTableView.RebuildView();
}
// 填充ReferenceTableView
{
var sourceDatas = new List<ITableData>(1000);
foreach (string referenceBundleName in selectBundleInfo.ReferenceBundles)
{
var bundleInfo = packageData.GetBundleInfo(referenceBundleName);
var rowData = new ReferenceTableData();
rowData.BundleInfo = bundleInfo;
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
sourceDatas.Add(rowData);
}
_referenceTableView.itemsSource = sourceDatas;
_referenceTableView.RebuildView();
} }
_usingTableView.itemsSource = sourceDatas;
_usingTableView.RebuildView();
} }
} }
} }

View File

@@ -1,8 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" /> <YooAsset.Editor.TableView name="BundleTableView" />
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="BottomGroup" style="height: 400px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="BottomTableView" /> <YooAsset.Editor.TableView name="UsingTableView" />
<YooAsset.Editor.TableView name="ReferenceTableView" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -0,0 +1,505 @@
#if UNITY_2019_4_OR_NEWER
using System.IO;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
internal class DebuggerOperationListViewer
{
private class OperationTableData : DefaultTableData
{
public DebugPackageData PackageData;
public DebugOperationInfo OperationInfo;
}
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _operationTableView;
private Toolbar _bottomToolbar;
private TreeViewer _childTreeView;
private List<ITableData> _sourceDatas;
/// <summary>
/// 初始化页面
/// </summary>
public void InitViewer()
{
// 加载布局文件
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerOperationListViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 任务列表
_operationTableView = _root.Q<TableView>("TopTableView");
_operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged;
CreateOperationTableViewColumns();
// 底部标题栏
_bottomToolbar = _root.Q<Toolbar>("BottomToolbar");
CreateBottomToolbarHeaders();
// 子列表
_childTreeView = _root.Q<TreeViewer>("BottomTreeView");
_childTreeView.makeItem = MakeTreeViewItem;
_childTreeView.bindItem = BindTreeViewItem;
// 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup");
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
topGroup.style.minHeight = 100;
bottomGroup.style.minHeight = 100f;
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
}
private void CreateOperationTableViewColumns()
{
// PackageName
{
var columnStyle = new ColumnStyle(200);
columnStyle.Searchable = true;
columnStyle.Sortable = true;
var column = new TableColumn("PackageName", "Package Name", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// OperationName
{
var columnStyle = new ColumnStyle(300, 300, 600);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("OperationName", "Operation Name", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// Priority
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("Priority", "Priority", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// Progress
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
var column = new TableColumn("Progress", "Progress", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// BeginTime
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// ProcessTime
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("ProcessTime", "Process Time", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
// Status
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("Status", "Status", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
StyleColor textColor;
var operationTableData = data as OperationTableData;
if (operationTableData.OperationInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
infoLabel.style.color = textColor;
};
_operationTableView.AddColumn(column);
}
// Desc
{
var columnStyle = new ColumnStyle(500, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
var column = new TableColumn("Desc", "Desc", columnStyle);
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
return label;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var infoLabel = element as Label;
infoLabel.text = (string)cell.GetDisplayObject();
};
_operationTableView.AddColumn(column);
}
}
private void CreateBottomToolbarHeaders()
{
// OperationName
{
ToolbarButton button = new ToolbarButton();
button.text = "OperationName";
button.style.flexGrow = 0;
button.style.width = 315;
_bottomToolbar.Add(button);
}
// Progress
{
ToolbarButton button = new ToolbarButton();
button.text = "Progress";
button.style.flexGrow = 0;
button.style.width = 100;
_bottomToolbar.Add(button);
}
// BeginTime
{
ToolbarButton button = new ToolbarButton();
button.text = "BeginTime";
button.style.flexGrow = 0;
button.style.width = 100;
_bottomToolbar.Add(button);
}
// ProcessTime
{
ToolbarButton button = new ToolbarButton();
button.text = "ProcessTime";
button.style.flexGrow = 0;
button.style.width = 100;
_bottomToolbar.Add(button);
}
// Status
{
ToolbarButton button = new ToolbarButton();
button.text = "Status";
button.style.flexGrow = 0;
button.style.width = 100;
_bottomToolbar.Add(button);
}
// Desc
{
ToolbarButton button = new ToolbarButton();
button.text = "Desc";
button.style.flexGrow = 0;
button.style.width = 500;
_bottomToolbar.Add(button);
}
}
/// <summary>
/// 填充页面数据
/// </summary>
public void FillViewData(DebugReport debugReport)
{
// 清空旧数据
_operationTableView.ClearAll(false, true);
_childTreeView.ClearAll();
_childTreeView.RebuildView();
// 填充数据源
_sourceDatas = new List<ITableData>(1000);
foreach (var packageData in debugReport.PackageDatas)
{
foreach (var operationInfo in packageData.OperationInfos)
{
var rowData = new OperationTableData();
rowData.PackageData = packageData;
rowData.OperationInfo = operationInfo;
rowData.AddStringValueCell("PackageName", packageData.PackageName);
rowData.AddStringValueCell("OperationName", operationInfo.OperationName);
rowData.AddLongValueCell("Priority", operationInfo.Priority);
rowData.AddDoubleValueCell("Progress", operationInfo.Progress);
rowData.AddStringValueCell("BeginTime", operationInfo.BeginTime);
rowData.AddLongValueCell("LoadingTime", operationInfo.ProcessTime);
rowData.AddStringValueCell("Status", operationInfo.Status.ToString());
rowData.AddStringValueCell("Desc", operationInfo.OperationDesc);
_sourceDatas.Add(rowData);
}
}
_operationTableView.itemsSource = _sourceDatas;
// 重建视图
RebuildView(null);
}
/// <summary>
/// 清空页面
/// </summary>
public void ClearView()
{
_operationTableView.ClearAll(false, true);
_childTreeView.ClearAll();
RebuildView(null);
}
/// <summary>
/// 重建视图
/// </summary>
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_operationTableView.RebuildView();
_childTreeView.RebuildView();
}
/// <summary>
/// 挂接到父类页面上
/// </summary>
public void AttachParent(VisualElement parent)
{
parent.Add(_root);
}
/// <summary>
/// 从父类页面脱离开
/// </summary>
public void DetachParent()
{
_root.RemoveFromHierarchy();
}
private void OnOperationTableViewSelectionChanged(ITableData data)
{
var operationTableData = data as OperationTableData;
DebugPackageData packageData = operationTableData.PackageData;
DebugOperationInfo operationInfo = operationTableData.OperationInfo;
TreeNode rootNode = new TreeNode(operationInfo);
FillTreeData(operationInfo, rootNode);
_childTreeView.ClearAll();
_childTreeView.SetRootItem(rootNode);
_childTreeView.RebuildView();
}
private void MakeTreeViewItem(VisualElement container)
{
// OperationName
{
Label label = new Label();
label.name = "OperationName";
label.style.flexGrow = 0f;
label.style.width = 300;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
// Progress
{
var label = new Label();
label.name = "Progress";
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
// BeginTime
{
var label = new Label();
label.name = "BeginTime";
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
// ProcessTime
{
var label = new Label();
label.name = "ProcessTime";
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
// Status
{
var label = new Label();
label.name = "Status";
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
// Desc
{
Label label = new Label();
label.name = "Desc";
label.style.flexGrow = 1f;
label.style.width = 500;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
container.Add(label);
}
}
private void BindTreeViewItem(VisualElement container, object userData)
{
var operationInfo = userData as DebugOperationInfo;
// OperationName
{
var label = container.Q<Label>("OperationName");
label.text = operationInfo.OperationName;
}
// Progress
{
var label = container.Q<Label>("Progress");
label.text = operationInfo.Progress.ToString();
}
// BeginTime
{
var label = container.Q<Label>("BeginTime");
label.text = operationInfo.BeginTime;
}
// ProcessTime
{
var label = container.Q<Label>("ProcessTime");
label.text = operationInfo.ProcessTime.ToString();
}
// Status
{
StyleColor textColor;
if (operationInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
var label = container.Q<Label>("Status");
label.text = operationInfo.Status;
label.style.color = textColor;
}
// Desc
{
var label = container.Q<Label>("Desc");
label.text = operationInfo.OperationDesc;
}
}
private void FillTreeData(DebugOperationInfo parentOperation, TreeNode rootNode)
{
foreach (var childOperation in parentOperation.Childs)
{
var childNode = new TreeNode(childOperation);
rootNode.AddChild(childNode);
FillTreeData(childOperation, childNode);
}
}
}
}
#endif

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 2fb1b9a2a91f1af4a86acfcfac424e0b guid: faabdaf3787cba6438d2300f7f71e26f
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -0,0 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" />
</ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="flex-grow: 1;">
<uie:Toolbar name="BottomToolbar" />
<YooAsset.Editor.TreeViewer name="BottomTreeView" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7147c7108cba1bb4dba3a2cfc758ad43
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -39,8 +39,14 @@ namespace YooAsset.Editor
public long MainBundleSize; public long MainBundleSize;
/// <summary> /// <summary>
/// 依赖的资源路径列表 /// 依赖的资源集合
/// </summary> /// </summary>
public List<string> DependAssets = new List<string>(); public List<AssetInfo> DependAssets = new List<AssetInfo>();
/// <summary>
/// 依赖的资源包集合
/// 说明:框架层收集查询结果
/// </summary>
public List<string> DependBundles = new List<string>();
} }
} }

View File

@@ -44,14 +44,21 @@ namespace YooAsset.Editor
public string[] Tags; public string[] Tags;
/// <summary> /// <summary>
/// 资源包的依赖集合 /// 依赖的资源包集合
/// 说明:引擎层构建查询结果
/// </summary> /// </summary>
public List<string> DependBundles; public List<string> DependBundles = new List<string>();
/// <summary> /// <summary>
/// 该资源包内包含的所有资源 /// 引用该资源包的资源包集合
/// 说明:谁依赖该资源包
/// </summary> /// </summary>
public List<string> AllBuiltinAssets = new List<string>(); public List<string> ReferenceBundles = new List<string>();
/// <summary>
/// 资源包内部所有资产
/// </summary>
public List<AssetInfo> BundleContents = new List<AssetInfo>();
/// <summary> /// <summary>
/// 获取资源分类标签的字符串 /// 获取资源分类标签的字符串

View File

@@ -67,15 +67,22 @@ namespace YooAsset.Editor
public string IgnoreRuleName; public string IgnoreRuleName;
// 构建参数 // 构建参数
public bool LegacyDependency;
public bool ClearBuildCacheFiles; public bool ClearBuildCacheFiles;
public bool UseAssetDependencyDB; public bool UseAssetDependencyDB;
public bool EnableSharePackRule; public bool EnableSharePackRule;
public bool SingleReferencedPackAlone;
public string EncryptionClassName; public string EncryptionClassName;
public EFileNameStyle FileNameStyle; public EFileNameStyle FileNameStyle;
// 引擎参数
public ECompressOption CompressOption; public ECompressOption CompressOption;
public bool DisableWriteTypeTree; public bool DisableWriteTypeTree;
public bool IgnoreTypeTreeChanges; public bool IgnoreTypeTreeChanges;
public bool WriteLinkXML = true;
public string CacheServerHost;
public int CacheServerPort;
public string BuiltinShadersBundleName;
public string MonoScriptsBundleName;
// 构建结果 // 构建结果
public int AssetFileTotalCount; public int AssetFileTotalCount;

View File

@@ -56,13 +56,12 @@ namespace YooAsset.Editor
_dependTableView.ClickTableDataEvent = OnClickBundleTableView; _dependTableView.ClickTableDataEvent = OnClickBundleTableView;
CreateDependTableViewColumns(); CreateDependTableViewColumns();
#if UNITY_2020_3_OR_NEWER // 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup"); var topGroup = _root.Q<VisualElement>("TopGroup");
var bottomGroup = _root.Q<VisualElement>("BottomGroup"); var bottomGroup = _root.Q<VisualElement>("BottomGroup");
topGroup.style.minHeight = 100; topGroup.style.minHeight = 100;
bottomGroup.style.minHeight = 100f; bottomGroup.style.minHeight = 100f;
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup); UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
#endif
} }
private void CreateAssetTableViewColumns() private void CreateAssetTableViewColumns()
{ {
@@ -72,6 +71,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("AssetPath", "Asset Path", columnStyle); var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -116,6 +116,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle); var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {

View File

@@ -61,7 +61,7 @@ namespace YooAsset.Editor
var bottomGroup = _root.Q<VisualElement>("BottomGroup"); var bottomGroup = _root.Q<VisualElement>("BottomGroup");
topGroup.style.minHeight = 100; topGroup.style.minHeight = 100;
bottomGroup.style.minHeight = 100f; bottomGroup.style.minHeight = 100f;
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup); UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
#endif #endif
} }
private void CreateBundleTableViewColumns() private void CreateBundleTableViewColumns()
@@ -72,6 +72,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("BundleName", "Bundle Name", columnStyle); var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -181,6 +182,7 @@ namespace YooAsset.Editor
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("IncludeAssets", "Include Assets", columnStyle); var column = new TableColumn("IncludeAssets", "Include Assets", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -320,15 +322,15 @@ namespace YooAsset.Editor
sourceDatas.Add(rowData); sourceDatas.Add(rowData);
} }
} }
foreach (string assetPath in bundleInfo.AllBuiltinAssets) foreach (var assetInfo in bundleInfo.BundleContents)
{ {
if (mainAssetDic.Contains(assetPath) == false) if (mainAssetDic.Contains(assetInfo.AssetPath) == false)
{ {
var rowData = new IncludeTableData(); var rowData = new IncludeTableData();
rowData.AssetInfo = null; rowData.AssetInfo = null;
rowData.AddAssetPathCell("IncludeAssets", assetPath); rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
rowData.AddStringValueCell("AssetSource", "BuiltinAsset"); rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
rowData.AddStringValueCell("AssetGUID", "--"); rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
sourceDatas.Add(rowData); sourceDatas.Add(rowData);
} }
} }

View File

@@ -11,24 +11,9 @@ namespace YooAsset.Editor
{ {
internal class ReporterSummaryViewer internal class ReporterSummaryViewer
{ {
private class ItemWrapper
{
public string Title { private set; get; }
public string Value { private set; get; }
public ItemWrapper(string title, string value)
{
Title = title;
Value = value;
}
}
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
private ScrollView _scrollView;
private ListView _listView;
private readonly List<ItemWrapper> _items = new List<ItemWrapper>();
/// <summary> /// <summary>
/// 初始化页面 /// 初始化页面
@@ -44,9 +29,7 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
// 概述列表 // 概述列表
_listView = _root.Q<ListView>("ListView"); _scrollView = _root.Q<ScrollView>("ScrollView");
_listView.makeItem = MakeListViewItem;
_listView.bindItem = BindListViewItem;
} }
/// <summary> /// <summary>
@@ -54,53 +37,49 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public void FillViewData(BuildReport buildReport) public void FillViewData(BuildReport buildReport)
{ {
_items.Clear(); _scrollView.Clear();
_items.Add(new ItemWrapper("YooAsset Version", buildReport.Summary.YooVersion)); BindListViewHeader("Build Infos");
_items.Add(new ItemWrapper("UnityEngine Version", buildReport.Summary.UnityVersion)); BindListViewItem("YooAsset Version", buildReport.Summary.YooVersion);
_items.Add(new ItemWrapper("Build Date", buildReport.Summary.BuildDate)); BindListViewItem("UnityEngine Version", buildReport.Summary.UnityVersion);
_items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds))); BindListViewItem("Build Date", buildReport.Summary.BuildDate);
_items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}")); BindListViewItem("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds));
_items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}")); BindListViewItem("Build Target", $"{buildReport.Summary.BuildTarget}");
_items.Add(new ItemWrapper("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString())); BindListViewItem("Build Pipeline", $"{buildReport.Summary.BuildPipeline}");
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName)); BindListViewItem("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString());
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion)); BindListViewItem("Package Name", buildReport.Summary.BuildPackageName);
_items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote)); BindListViewItem("Package Version", buildReport.Summary.BuildPackageVersion);
BindListViewItem("Package Note", buildReport.Summary.BuildPackageNote);
BindListViewItem(string.Empty, string.Empty);
_items.Add(new ItemWrapper(string.Empty, string.Empty)); BindListViewHeader("Collect Settings");
_items.Add(new ItemWrapper("Collect Settings", string.Empty)); BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
_items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}")); BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}")); BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}")); BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}")); BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}")); BindListViewItem("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}");
_items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}")); BindListViewItem(string.Empty, string.Empty);
_items.Add(new ItemWrapper(string.Empty, string.Empty)); BindListViewHeader("Build Params");
_items.Add(new ItemWrapper("Build Params", string.Empty)); BindListViewItem("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}");
_items.Add(new ItemWrapper("Legacy Dependency Mode", $"{buildReport.Summary.LegacyDependency}")); BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
_items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}")); BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
_items.Add(new ItemWrapper("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}")); BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
_items.Add(new ItemWrapper("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}")); BindListViewItem("Encryption Class Name", buildReport.Summary.EncryptionClassName);
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName)); BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}")); BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}")); BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}")); BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}")); BindListViewItem(string.Empty, string.Empty);
_items.Add(new ItemWrapper(string.Empty, string.Empty)); BindListViewHeader("Build Results");
_items.Add(new ItemWrapper("Build Results", string.Empty)); BindListViewItem("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}");
_items.Add(new ItemWrapper("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}")); BindListViewItem("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}");
_items.Add(new ItemWrapper("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}")); BindListViewItem("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}");
_items.Add(new ItemWrapper("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}")); BindListViewItem("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize));
_items.Add(new ItemWrapper("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize))); BindListViewItem("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}");
_items.Add(new ItemWrapper("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}")); BindListViewItem("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize));
_items.Add(new ItemWrapper("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
_listView.Clear();
_listView.ClearSelection();
_listView.itemsSource = _items;
_listView.Rebuild();
} }
/// <summary> /// <summary>
@@ -120,45 +99,60 @@ namespace YooAsset.Editor
} }
// 列表相关 // 列表相关
private void BindListViewHeader(string titile)
{
Toolbar toolbar = new Toolbar();
_scrollView.Add(toolbar);
ToolbarButton titleButton = new ToolbarButton();
titleButton.text = titile;
titleButton.style.unityTextAlign = TextAnchor.MiddleCenter;
titleButton.style.width = 200;
toolbar.Add(titleButton);
ToolbarButton valueButton = new ToolbarButton();
valueButton.style.unityTextAlign = TextAnchor.MiddleCenter;
valueButton.style.width = 150;
valueButton.style.flexShrink = 1;
valueButton.style.flexGrow = 1;
valueButton.SetEnabled(false);
toolbar.Add(valueButton);
}
private void BindListViewItem(string name, string value)
{
VisualElement element = MakeListViewItem();
_scrollView.Add(element);
// Title
var titleLabel = element.Q<Label>("TitleLabel");
titleLabel.text = name;
// Value
var valueLabel = element.Q<Label>("ValueLabel");
valueLabel.text = value;
}
private VisualElement MakeListViewItem() private VisualElement MakeListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();
element.style.flexDirection = FlexDirection.Row; element.style.flexDirection = FlexDirection.Row;
{ var titleLabel = new Label();
var label = new Label(); titleLabel.name = "TitleLabel";
label.name = "Label1"; titleLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.unityTextAlign = TextAnchor.MiddleLeft; titleLabel.style.marginLeft = 3f;
label.style.marginLeft = 3f; titleLabel.style.width = 200;
//label.style.flexGrow = 1f; element.Add(titleLabel);
label.style.width = 200;
element.Add(label);
}
{ var valueLabel = new Label();
var label = new Label(); valueLabel.name = "ValueLabel";
label.name = "Label2"; valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.unityTextAlign = TextAnchor.MiddleLeft; valueLabel.style.marginLeft = 3f;
label.style.marginLeft = 3f; valueLabel.style.flexGrow = 1f;
label.style.flexGrow = 1f; valueLabel.style.width = 150;
label.style.width = 150; element.Add(valueLabel);
element.Add(label);
}
return element; return element;
} }
private void BindListViewItem(VisualElement element, int index)
{
var itemWrapper = _items[index];
// Title
var label1 = element.Q<Label>("Label1");
label1.text = itemWrapper.Title;
// Value
var label2 = element.Q<Label>("Label2");
label2.text = itemWrapper.Value;
}
private string ConvertTime(int time) private string ConvertTime(int time)
{ {

View File

@@ -1,9 +1,5 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <ui:ScrollView name="ScrollView" horizontal-scroller-visibility="Hidden" />
<uie:ToolbarButton text="Info" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
<uie:ToolbarButton text="Param" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
</uie:Toolbar>
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[Serializable] [Serializable]
public class AssetInfo public class AssetInfo : IComparable<AssetInfo>
{ {
private string _fileExtension = null; private string _fileExtension = null;
@@ -37,6 +37,7 @@ namespace YooAsset.Editor
} }
} }
public AssetInfo(string assetPath) public AssetInfo(string assetPath)
{ {
AssetPath = assetPath; AssetPath = assetPath;
@@ -60,5 +61,10 @@ namespace YooAsset.Editor
else else
return false; return false;
} }
public int CompareTo(AssetInfo other)
{
return this.AssetPath.CompareTo(other.AssetPath);
}
} }
} }

View File

@@ -129,6 +129,21 @@ namespace YooAsset.Editor
} }
#endregion #endregion
#region PackageManager
public static string GetPackageManagerYooVersion()
{
#if UNITY_2019_4_OR_NEWER
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(YooAssets).Assembly);
if (packageInfo != null)
return packageInfo.version;
else
return string.Empty;
#else
return string.Empty;
#endif
}
#endregion
#region EditorUtility #region EditorUtility
/// <summary> /// <summary>
/// 搜集资源 /// 搜集资源

View File

@@ -1,41 +0,0 @@
#if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
/// <summary>
/// 显示开关(眼睛图标)
/// </summary>
public class DisplayToggle : Toggle
{
private readonly VisualElement _checkbox;
public DisplayToggle()
{
_checkbox = this.Q<VisualElement>("unity-checkmark");
RefreshIcon();
}
/// <summary>
/// 刷新图标
/// </summary>
public void RefreshIcon()
{
if (this.value)
{
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleoff@2x").image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
else
{
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleon@2x").image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
}
}
}
#endif

View File

@@ -1,36 +0,0 @@
#if UNITY_2020_3_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
/// <summary>
/// 分屏控件
/// </summary>
public class PanelSplitView : TwoPaneSplitView
{
public new class UxmlFactory : UxmlFactory<PanelSplitView, UxmlTraits>
{
}
/// <summary>
/// 竖版分屏
/// </summary>
public static void SplitVerticalPanel(VisualElement root, VisualElement panelA, VisualElement panelB)
{
root.Remove(panelA);
root.Remove(panelB);
var spliteView = new PanelSplitView();
spliteView.fixedPaneInitialDimension = 300;
spliteView.orientation = TwoPaneSplitViewOrientation.Vertical;
spliteView.contentContainer.Add(panelA);
spliteView.contentContainer.Add(panelB);
root.Add(spliteView);
}
}
}
#endif

View File

@@ -0,0 +1,55 @@
#if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
/// <summary>
/// 显示开关(眼睛图标)
/// </summary>
public class ToggleDisplay : Toggle
{
public new class UxmlFactory : UxmlFactory<ToggleDisplay, UxmlTraits>
{
}
private readonly VisualElement _checkbox;
public ToggleDisplay()
{
_checkbox = this.Q<VisualElement>("unity-checkmark");
RefreshIcon();
}
public override void SetValueWithoutNotify(bool newValue)
{
base.SetValueWithoutNotify(newValue);
RefreshIcon();
}
#if UNITY_2021_3_OR_NEWER
protected override void ToggleValue()
{
base.ToggleValue();
RefreshIcon();
}
#endif
private void RefreshIcon()
{
if (this.value)
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.VisibilityToggleOff).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
else
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.VisibilityToggleOn).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
}
}
}
#endif

View File

@@ -0,0 +1,55 @@
#if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
/// <summary>
/// 折叠开关
/// </summary>
public class ToggleFoldout : Toggle
{
public new class UxmlFactory : UxmlFactory<ToggleFoldout, UxmlTraits>
{
}
private readonly VisualElement _checkbox;
public ToggleFoldout()
{
_checkbox = this.Q<VisualElement>("unity-checkmark");
RefreshIcon();
}
public override void SetValueWithoutNotify(bool newValue)
{
base.SetValueWithoutNotify(newValue);
RefreshIcon();
}
#if UNITY_2021_3_OR_NEWER
protected override void ToggleValue()
{
base.ToggleValue();
RefreshIcon();
}
#endif
public void RefreshIcon()
{
if (this.value)
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.FoldoutOn).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
else
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.FoldoutOff).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
}
}
}
#endif

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 84c10fd3507a1c24a9043aebb72db5f5 guid: 2619997e70d98794da26a947f9129e25
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -0,0 +1,55 @@
#if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
/// <summary>
/// 录制开关
/// </summary>
public class ToggleRecord : Toggle
{
public new class UxmlFactory : UxmlFactory<ToggleRecord, UxmlTraits>
{
}
private readonly VisualElement _checkbox;
public ToggleRecord()
{
_checkbox = this.Q<VisualElement>("unity-checkmark");
RefreshIcon();
}
public override void SetValueWithoutNotify(bool newValue)
{
base.SetValueWithoutNotify(newValue);
RefreshIcon();
}
#if UNITY_2021_3_OR_NEWER
protected override void ToggleValue()
{
base.ToggleValue();
RefreshIcon();
}
#endif
private void RefreshIcon()
{
if (this.value)
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.RecordOn).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
else
{
var icon = EditorGUIUtility.IconContent(UIElementsIcon.RecordOff).image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
}
}
}
#endif

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 0c3f4136cf7142346ae33e8a82cbdb27 guid: 4eace285493a0844f8a8b8f4a4ea02d8
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -41,6 +41,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool Sortable = false; public bool Sortable = false;
/// <summary>
/// 统计数量
/// </summary>
public bool Counter = false;
public ColumnStyle(Length width) public ColumnStyle(Length width)
{ {
if (width.value > MaxValue) if (width.value > MaxValue)

View File

@@ -27,7 +27,7 @@ namespace YooAsset.Editor
private List<ITableData> _sortingDatas; private List<ITableData> _sortingDatas;
// 排序相关 // 排序相关
private string _sortingHeaderElement = string.Empty; private string _sortingHeader;
private bool _descendingSort = true; private bool _descendingSort = true;
/// <summary> /// <summary>
@@ -191,6 +191,38 @@ namespace YooAsset.Editor
_listView.ClearSelection(); _listView.ClearSelection();
_listView.itemsSource = itemsSource.ToList(); _listView.itemsSource = itemsSource.ToList();
_listView.Rebuild(); _listView.Rebuild();
// 刷新标题栏
RefreshToobar();
}
private void RefreshToobar()
{
// 设置为原始标题
foreach (var column in _columns)
{
var toobarButton = _toolbar.Q<ToolbarButton>(column.ElementName);
toobarButton.text = column.HeaderTitle;
}
// 设置元素数量
foreach (var column in _columns)
{
if (column.ColumnStyle.Counter)
{
var toobarButton = GetHeaderElement(column.ElementName) as ToolbarButton;
toobarButton.text = $"{toobarButton.text} ({itemsSource.Count()})";
}
}
// 设置升降符号
if (string.IsNullOrEmpty(_sortingHeader) == false)
{
var _toobarButton = _toolbar.Q<ToolbarButton>(_sortingHeader);
if (_descendingSort)
_toobarButton.text = $"{_toobarButton.text} ↓";
else
_toobarButton.text = $"{_toobarButton.text} ↑";
}
} }
/// <summary> /// <summary>
@@ -237,9 +269,9 @@ namespace YooAsset.Editor
if (clickedColumn.ColumnStyle.Sortable == false) if (clickedColumn.ColumnStyle.Sortable == false)
return; return;
if (_sortingHeaderElement != clickedColumn.ElementName) if (_sortingHeader != clickedColumn.ElementName)
{ {
_sortingHeaderElement = clickedColumn.ElementName; _sortingHeader = clickedColumn.ElementName;
_descendingSort = false; _descendingSort = false;
} }
else else
@@ -247,17 +279,6 @@ namespace YooAsset.Editor
_descendingSort = !_descendingSort; _descendingSort = !_descendingSort;
} }
// 升降符号
foreach (var column in _columns)
{
var button = _toolbar.Q<ToolbarButton>(column.ElementName);
button.text = column.HeaderTitle;
}
if (_descendingSort)
toolbarBtn.text = $"{clickedColumn.HeaderTitle} ↓";
else
toolbarBtn.text = $"{clickedColumn.HeaderTitle} ↑";
// 升降排序 // 升降排序
if (_descendingSort) if (_descendingSort)
_sortingDatas = _itemsSource.OrderByDescending(tableData => tableData.Cells[clickedColumn.ColumnIndex]).ToList(); _sortingDatas = _itemsSource.OrderByDescending(tableData => tableData.Cells[clickedColumn.ColumnIndex]).ToList();

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1797f960cdbd5aa41a96bb02d16c4998
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
#if UNITY_2019_4_OR_NEWER
using System.IO;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
public class TreeNode
{
/// <summary>
/// 子节点集合
/// </summary>
public List<TreeNode> Children = new List<TreeNode>(10);
/// <summary>
/// 父节点
/// </summary>
public TreeNode Parent { get; set; }
/// <summary>
/// 用户数据
/// </summary>
public object UserData { get; set; }
/// <summary>
/// 是否展开
/// </summary>
public bool IsExpanded { get; set; } = false;
public TreeNode(object userData)
{
UserData = userData;
}
/// <summary>
/// 添加子节点
/// </summary>
public void AddChild(TreeNode child)
{
child.Parent = this;
Children.Add(child);
}
/// <summary>
/// 清理所有子节点
/// </summary>
public void ClearChildren()
{
foreach(var child in Children)
{
child.Parent = null;
}
Children.Clear();
}
/// <summary>
/// 计算节点的深度
/// </summary>
public int GetDepth()
{
int depth = 0;
TreeNode current = this;
while (current.Parent != null)
{
depth++;
current = current.Parent;
}
return depth;
}
}
}
#endif

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: fc10550f17aaeb14795135a51444de1c guid: 473cdc8e1dd7b0f43938ddb99287a2a8
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -0,0 +1,152 @@
#if UNITY_2019_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
public class TreeViewer : VisualElement
{
public new class UxmlFactory : UxmlFactory<TreeViewer, UxmlTraits>
{
}
private readonly ListView _listView;
private readonly List<TreeNode> _flattenList = new List<TreeNode>(1000);
private readonly List<TreeNode> _rootList = new List<TreeNode>(100);
/// <summary>
/// 制作列表元素
/// </summary>
public Action<VisualElement> makeItem { get; set; }
/// <summary>
/// 绑定列表数据
/// </summary>
public Action<VisualElement, object> bindItem { get; set; }
public TreeViewer()
{
this.style.flexShrink = 1f;
this.style.flexGrow = 1f;
// 创建ListView
_listView = new ListView();
_listView.style.flexShrink = 1f;
_listView.style.flexGrow = 1f;
_listView.itemsSource = _flattenList;
_listView.makeItem = MakeItemInternal;
_listView.bindItem = BindItemInternal;
this.Add(_listView);
}
/// <summary>
/// 设置根节点数据
/// </summary>
public void SetRootItem(TreeNode rootNode)
{
_rootList.Add(rootNode);
}
/// <summary>
/// 设置根节点数据
/// </summary>
public void SetRootItems(List<TreeNode> rootNodes)
{
_rootList.AddRange(rootNodes);
}
/// <summary>
/// 清理数据
/// </summary>
public void ClearAll()
{
_rootList.Clear();
}
/// <summary>
/// 重新绘制视图
/// </summary>
public void RebuildView()
{
_flattenList.Clear();
foreach (var treeRoot in _rootList)
{
FlattenTree(treeRoot, 0);
}
_listView.Rebuild();
}
/// <summary>
/// 将树形结构扁平化为列表
/// </summary>
private void FlattenTree(TreeNode node, int depth)
{
_flattenList.Add(node);
if (node.IsExpanded)
{
foreach (var child in node.Children)
{
FlattenTree(child, depth + 1);
}
}
}
private VisualElement MakeItemInternal()
{
var container = new VisualElement();
container.style.flexDirection = FlexDirection.Row;
// 折叠按钮
var toggle = new ToggleFoldout();
toggle.text = string.Empty;
toggle.name = "foldout";
toggle.style.alignSelf = Align.Center;
toggle.style.width = 15;
toggle.style.height = 15;
toggle.RegisterValueChangedCallback((ChangeEvent<bool> callback) =>
{
var treeNode = toggle.userData as TreeNode;
treeNode.IsExpanded = toggle.value;
RebuildView();
});
container.Add(toggle);
// 用户自定义元素
if (makeItem != null)
{
makeItem.Invoke(container);
}
return container;
}
private void BindItemInternal(VisualElement item, int index)
{
var treeNode = _flattenList[index];
// 设置折叠状态
var toggle = item.Q<ToggleFoldout>("foldout");
toggle.SetValueWithoutNotify(treeNode.IsExpanded);
toggle.userData = treeNode;
toggle.style.marginLeft = treeNode.GetDepth() * 15;
// 隐藏折叠按钮
if (treeNode.Children.Count == 0)
{
toggle.style.visibility = Visibility.Hidden;
}
// 用户自定义元素
if (bindItem != null)
{
bindItem.Invoke(item, treeNode.UserData);
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,25 @@
#if UNITY_2019_4_OR_NEWER
namespace YooAsset.Editor
{
/// <summary>
/// 引擎图标名称
/// </summary>
public class UIElementsIcon
{
public const string RecordOn = "d_Record On@2x";
public const string RecordOff = "d_Record Off@2x";
#if UNITY_2019
public const string FoldoutOn = "IN foldout on";
public const string FoldoutOff = "IN foldout";
#else
public const string FoldoutOn = "d_IN_foldout_on@2x";
public const string FoldoutOff = "d_IN_foldout@2x";
#endif
public const string VisibilityToggleOff = "animationvisibilitytoggleoff@2x";
public const string VisibilityToggleOn = "animationvisibilitytoggleon@2x";
}
}
#endif

View File

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

View File

@@ -32,6 +32,34 @@ namespace YooAsset.Editor
label.style.minWidth = minWidth; label.style.minWidth = minWidth;
} }
} }
/// <summary>
/// 设置按钮图标
/// </summary>
public static void SetToolbarButtonIcon(ToolbarButton element, string iconName)
{
var image = EditorGUIUtility.IconContent(iconName).image as Texture2D;
element.style.backgroundImage = image;
element.text = string.Empty;
}
/// <summary>
/// 竖版分屏
/// </summary>
public static void SplitVerticalPanel(VisualElement root, VisualElement panelA, VisualElement panelB)
{
#if UNITY_2020_3_OR_NEWER
root.Remove(panelA);
root.Remove(panelB);
var spliteView = new TwoPaneSplitView();
spliteView.fixedPaneInitialDimension = 300;
spliteView.orientation = TwoPaneSplitViewOrientation.Vertical;
spliteView.contentContainer.Add(panelA);
spliteView.contentContainer.Add(panelB);
root.Add(spliteView);
#endif
}
} }
} }
#endif #endif

View File

@@ -22,6 +22,11 @@ namespace YooAsset
/// </summary> /// </summary>
public EOperationStatus Status; public EOperationStatus Status;
/// <summary>
/// 谁引用了该资源包
/// </summary>
public List<string> ReferenceBundles;
public int CompareTo(DebugBundleInfo other) public int CompareTo(DebugBundleInfo other)
{ {
return Compare(this, other); return Compare(this, other);

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal class DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
{
/// <summary>
/// 任务名称
/// </summary>
public string OperationName;
/// <summary>
/// 任务说明
/// </summary>
public string OperationDesc;
/// <summary>
/// 优先级
/// </summary>
public uint Priority;
/// <summary>
/// 任务进度
/// </summary>
public float Progress;
/// <summary>
/// 任务开始的时间
/// </summary>
public string BeginTime;
/// <summary>
/// 处理耗时(单位:毫秒)
/// </summary>
public long ProcessTime;
/// <summary>
/// 任务状态
/// </summary>
public string Status;
/// <summary>
/// 子任务列表
/// TODO : Serialization depth limit 10 exceeded
/// </summary>
public List<DebugOperationInfo> Childs;
public int CompareTo(DebugOperationInfo other)
{
return Compare(this, other);
}
public int Compare(DebugOperationInfo a, DebugOperationInfo b)
{
return string.CompareOrdinal(a.OperationName, b.OperationName);
}
}
}

View File

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

View File

@@ -13,9 +13,42 @@ namespace YooAsset
/// </summary> /// </summary>
public string PackageName; public string PackageName;
/// <summary>
/// 调试数据列表
/// </summary>
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000); public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
public List<DebugBundleInfo> BundleInfos = new List<DebugBundleInfo>(1000);
public List<DebugOperationInfo> OperationInfos = new List<DebugOperationInfo>(1000);
[NonSerialized]
public Dictionary<string, DebugBundleInfo> BundleInfoDic = new Dictionary<string, DebugBundleInfo>();
private bool _isParse = false;
/// <summary>
/// 获取调试资源包信息类
/// </summary>
public DebugBundleInfo GetBundleInfo(string bundleName)
{
// 解析数据
if (_isParse == false)
{
_isParse = true;
foreach (var bundleInfo in BundleInfos)
{
if (BundleInfoDic.ContainsKey(bundleInfo.BundleName) == false)
{
BundleInfoDic.Add(bundleInfo.BundleName, bundleInfo);
}
}
}
if (BundleInfoDic.TryGetValue(bundleName, out DebugBundleInfo value))
{
return value;
}
else
{
UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}");
return null;
}
}
} }
} }

View File

@@ -23,9 +23,9 @@ namespace YooAsset
public string SpawnScene; public string SpawnScene;
/// <summary> /// <summary>
/// 资源出生的时间 /// 资源加载开始时间
/// </summary> /// </summary>
public string SpawnTime; public string BeginTime;
/// <summary> /// <summary>
/// 加载耗时(单位:毫秒) /// 加载耗时(单位:毫秒)
@@ -45,7 +45,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 依赖的资源包列表 /// 依赖的资源包列表
/// </summary> /// </summary>
public List<DebugBundleInfo> DependBundleInfos; public List<string> DependBundles;
public int CompareTo(DebugProviderInfo other) public int CompareTo(DebugProviderInfo other)
{ {

View File

@@ -22,7 +22,6 @@ namespace YooAsset
/// </summary> /// </summary>
public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10); public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10);
/// <summary> /// <summary>
/// 序列化 /// 序列化
/// </summary> /// </summary>

View File

@@ -10,6 +10,11 @@ namespace YooAsset
/// 采样一次 /// 采样一次
/// </summary> /// </summary>
SampleOnce = 0, SampleOnce = 0,
/// <summary>
/// 自动采集
/// </summary>
SampleAuto = 1,
} }
[Serializable] [Serializable]

View File

@@ -5,7 +5,7 @@ namespace YooAsset
{ {
internal class RemoteDebuggerDefine internal class RemoteDebuggerDefine
{ {
public static readonly Guid kMsgSendPlayerToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3"); public static readonly Guid kMsgPlayerSendToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3");
public static readonly Guid kMsgSendEditorToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a"); public static readonly Guid kMsgEditorSendToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a");
} }
} }

View File

@@ -7,47 +7,66 @@ namespace YooAsset
{ {
internal class RemoteDebuggerInRuntime : MonoBehaviour internal class RemoteDebuggerInRuntime : MonoBehaviour
{ {
#if UNITY_EDITOR private static bool _sampleOnce = false;
/// <summary> private static bool _autoSample = false;
/// 编辑器下获取报告的回调
/// </summary>
public static Action<int, DebugReport> EditorHandleDebugReportCallback;
/// <summary> private void Awake()
/// 编辑器下请求报告数据
/// </summary>
public static void EditorRequestDebugReport()
{ {
if (UnityEditor.EditorApplication.isPlaying) #if UNITY_EDITOR
{ RemotePlayerConnection.Instance.Initialize();
var report = YooAssets.GetDebugReport(); #endif
EditorHandleDebugReportCallback?.Invoke(0, report);
}
} }
#else
private void OnEnable() private void OnEnable()
{ {
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage); #if UNITY_EDITOR
RemotePlayerConnection.Instance.Register(RemoteDebuggerDefine.kMsgEditorSendToPlayer, OnHandleEditorMessage);
#else
PlayerConnection.instance.Register(RemoteDebuggerDefine.kMsgEditorSendToPlayer, OnHandleEditorMessage);
#endif
} }
private void OnDisable() private void OnDisable()
{ {
PlayerConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendEditorToPlayer, OnHandleEditorMessage); #if UNITY_EDITOR
RemotePlayerConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgEditorSendToPlayer);
#else
PlayerConnection.instance.Unregister(RemoteDebuggerDefine.kMsgEditorSendToPlayer, OnHandleEditorMessage);
#endif
} }
private void OnHandleEditorMessage(MessageEventArgs args) private void LateUpdate()
{
if (_autoSample || _sampleOnce)
{
_sampleOnce = false;
var debugReport = YooAssets.GetDebugReport();
var data = DebugReport.Serialize(debugReport);
#if UNITY_EDITOR
RemotePlayerConnection.Instance.Send(RemoteDebuggerDefine.kMsgPlayerSendToEditor, data);
#else
PlayerConnection.instance.Send(RemoteDebuggerDefine.kMsgPlayerSendToEditor, data);
#endif
}
}
private static void OnHandleEditorMessage(MessageEventArgs args)
{ {
var command = RemoteCommand.Deserialize(args.data); var command = RemoteCommand.Deserialize(args.data);
YooLogger.Log($"On handle remote command : {command.CommandType} Param : {command.CommandParam}"); YooLogger.Log($"On handle remote command : {command.CommandType} Param : {command.CommandParam}");
if (command.CommandType == (int)ERemoteCommand.SampleOnce) if (command.CommandType == (int)ERemoteCommand.SampleOnce)
{ {
var debugReport = YooAssets.GetDebugReport(); _sampleOnce = true;
var data = DebugReport.Serialize(debugReport); }
PlayerConnection.instance.Send(RemoteDebuggerDefine.kMsgSendPlayerToEditor, data); else if (command.CommandType == (int)ERemoteCommand.SampleAuto)
{
if (command.CommandParam == "open")
_autoSample = true;
else
_autoSample = false;
} }
else else
{ {
throw new NotImplementedException(command.CommandType.ToString()); throw new NotImplementedException(command.CommandType.ToString());
} }
} }
#endif
} }
} }

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using UnityEngine.Events;
using UnityEngine.Networking.PlayerConnection;
using UnityEngine;
namespace YooAsset
{
internal class RemoteEditorConnection
{
private static RemoteEditorConnection _instance;
public static RemoteEditorConnection Instance
{
get
{
if (_instance == null)
_instance = new RemoteEditorConnection();
return _instance;
}
}
private readonly Dictionary<Guid, UnityAction<MessageEventArgs>> _messageCallbacks = new Dictionary<Guid, UnityAction<MessageEventArgs>>();
public void Initialize()
{
_messageCallbacks.Clear();
}
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{
if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !");
if (_messageCallbacks.ContainsKey(messageID) == false)
_messageCallbacks.Add(messageID, callback);
}
public void Unregister(Guid messageID)
{
if (_messageCallbacks.ContainsKey(messageID))
_messageCallbacks.Remove(messageID);
}
public void Send(Guid messageID, byte[] data)
{
if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !");
// 接收对方的消息
RemotePlayerConnection.Instance.HandleEditorMessage(messageID, data);
}
internal void HandlePlayerMessage(Guid messageID, byte[] data)
{
if (_messageCallbacks.TryGetValue(messageID, out UnityAction<MessageEventArgs> value))
{
var args = new MessageEventArgs();
args.playerId = 0;
args.data = data;
value?.Invoke(args);
}
}
}
}

View File

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

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using UnityEngine.Events;
using UnityEngine.Networking.PlayerConnection;
using UnityEngine;
namespace YooAsset
{
internal class RemotePlayerConnection
{
private static RemotePlayerConnection _instance;
public static RemotePlayerConnection Instance
{
get
{
if (_instance == null)
_instance = new RemotePlayerConnection();
return _instance;
}
}
private readonly Dictionary<Guid, UnityAction<MessageEventArgs>> _messageCallbacks = new Dictionary<Guid, UnityAction<MessageEventArgs>>();
public void Initialize()
{
_messageCallbacks.Clear();
}
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{
if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !");
if (_messageCallbacks.ContainsKey(messageID) == false)
_messageCallbacks.Add(messageID, callback);
}
public void Unregister(Guid messageID)
{
if (_messageCallbacks.ContainsKey(messageID))
_messageCallbacks.Remove(messageID);
}
public void Send(Guid messageID, byte[] data)
{
if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !");
// 接收对方的消息
RemoteEditorConnection.Instance.HandlePlayerMessage(messageID, data);
}
internal void HandleEditorMessage(Guid messageID, byte[] data)
{
if (_messageCallbacks.TryGetValue(messageID, out UnityAction<MessageEventArgs> value))
{
var args = new MessageEventArgs();
args.playerId = 0;
args.data = data;
value?.Invoke(args);
}
}
}
}

View File

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

View File

@@ -16,11 +16,11 @@ namespace YooAsset
internal UnityWebDataRequestOperation(string url, int timeout = 60) : base(url, timeout) internal UnityWebDataRequestOperation(string url, int timeout = 60) : base(url, timeout)
{ {
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CreateRequest; _steps = ESteps.CreateRequest;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -59,7 +59,7 @@ namespace YooAsset
DisposeRequest(); DisposeRequest();
} }
} }
internal override void InternalOnAbort() internal override void InternalAbort()
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
DisposeRequest(); DisposeRequest();

View File

@@ -12,11 +12,11 @@ namespace YooAsset
{ {
_fileSavePath = fileSavePath; _fileSavePath = fileSavePath;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CreateRequest; _steps = ESteps.CreateRequest;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -54,7 +54,7 @@ namespace YooAsset
DisposeRequest(); DisposeRequest();
} }
} }
internal override void InternalOnAbort() internal override void InternalAbort()
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
DisposeRequest(); DisposeRequest();

View File

@@ -16,11 +16,11 @@ namespace YooAsset
internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout) internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout)
{ {
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CreateRequest; _steps = ESteps.CreateRequest;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -59,7 +59,7 @@ namespace YooAsset
DisposeRequest(); DisposeRequest();
} }
} }
internal override void InternalOnAbort() internal override void InternalAbort()
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
DisposeRequest(); DisposeRequest();

View File

@@ -48,25 +48,21 @@ namespace YooAsset
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo) public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{ {
var operation = new AssetBundleLoadAssetOperation(_packageBundle, _assetBundle, assetInfo); var operation = new AssetBundleLoadAssetOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo) public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new AssetBundleLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo); var operation = new AssetBundleLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo) public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new AssetBundleLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo); var operation = new AssetBundleLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad) public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{ {
var operation = new AssetBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad); var operation = new AssetBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
} }

View File

@@ -25,11 +25,11 @@ namespace YooAsset
_assetBundle = assetBundle; _assetBundle = assetBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -25,11 +25,11 @@ namespace YooAsset
_assetBundle = assetBundle; _assetBundle = assetBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -25,11 +25,11 @@ namespace YooAsset
_loadParams = loadParams; _loadParams = loadParams;
_suspendLoad = suspendLoad; _suspendLoad = suspendLoad;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.LoadScene; _steps = ESteps.LoadScene;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -107,7 +107,7 @@ namespace YooAsset
internal override void InternalWaitForAsyncComplete() internal override void InternalWaitForAsyncComplete()
{ {
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法! //TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
InternalOnUpdate(); InternalUpdate();
} }
public override void UnSuspendLoad() public override void UnSuspendLoad()
{ {

View File

@@ -25,11 +25,11 @@ namespace YooAsset
_assetBundle = assetBundle; _assetBundle = assetBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -3,12 +3,12 @@ namespace YooAsset
{ {
internal class RawBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation internal class RawBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation
{ {
internal override void InternalOnStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets !"; Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets !";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
} }
} }

View File

@@ -3,12 +3,12 @@ namespace YooAsset
{ {
internal class RawBundleLoadAssetOperation : FSLoadAssetOperation internal class RawBundleLoadAssetOperation : FSLoadAssetOperation
{ {
internal override void InternalOnStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset !"; Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset !";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
} }
} }

View File

@@ -3,12 +3,12 @@ namespace YooAsset
{ {
internal class RawBundleLoadSceneOperation : FSLoadSceneOperation internal class RawBundleLoadSceneOperation : FSLoadSceneOperation
{ {
internal override void InternalOnStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene !"; Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene !";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
} }
public override void UnSuspendLoad() public override void UnSuspendLoad()

View File

@@ -3,12 +3,12 @@ namespace YooAsset
{ {
internal class RawBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation internal class RawBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation
{ {
internal override void InternalOnStart() internal override void InternalStart()
{ {
Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets !"; Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets !";
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
} }
} }

View File

@@ -32,25 +32,21 @@ namespace YooAsset
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo) public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{ {
var operation = new RawBundleLoadAssetOperation(); var operation = new RawBundleLoadAssetOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo) public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new RawBundleLoadAllAssetsOperation(); var operation = new RawBundleLoadAllAssetsOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo) public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new RawBundleLoadSubAssetsOperation(); var operation = new RawBundleLoadSubAssetsOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad) public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{ {
var operation = new RawBundleLoadSceneOperation(); var operation = new RawBundleLoadSceneOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
} }

View File

@@ -22,7 +22,7 @@ namespace YooAsset
_packageBundle = packageBundle; _packageBundle = packageBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
@@ -32,7 +32,7 @@ namespace YooAsset
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)

View File

@@ -21,7 +21,7 @@ namespace YooAsset
_packageBundle = packageBundle; _packageBundle = packageBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
@@ -31,7 +31,7 @@ namespace YooAsset
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)

View File

@@ -25,7 +25,7 @@ namespace YooAsset
_loadParams = loadParams; _loadParams = loadParams;
_suspendLoad = suspendLoad; _suspendLoad = suspendLoad;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
_steps = ESteps.LoadScene; _steps = ESteps.LoadScene;
@@ -35,7 +35,7 @@ namespace YooAsset
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
@@ -113,7 +113,7 @@ namespace YooAsset
internal override void InternalWaitForAsyncComplete() internal override void InternalWaitForAsyncComplete()
{ {
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法! //TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
InternalOnUpdate(); InternalUpdate();
} }
public override void UnSuspendLoad() public override void UnSuspendLoad()
{ {

View File

@@ -22,7 +22,7 @@ namespace YooAsset
_packageBundle = packageBundle; _packageBundle = packageBundle;
_assetInfo = assetInfo; _assetInfo = assetInfo;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
_steps = ESteps.CheckBundle; _steps = ESteps.CheckBundle;
@@ -32,7 +32,7 @@ namespace YooAsset
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)

View File

@@ -32,25 +32,21 @@ namespace YooAsset
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo) public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{ {
var operation = new VirtualBundleLoadAssetOperation(_packageBundle, assetInfo); var operation = new VirtualBundleLoadAssetOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo) public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new VirtualBundleLoadAllAssetsOperation(_packageBundle, assetInfo); var operation = new VirtualBundleLoadAllAssetsOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo) public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{ {
var operation = new VirtualBundleLoadSubAssetsOperation(_packageBundle, assetInfo); var operation = new VirtualBundleLoadSubAssetsOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad) public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{ {
var operation = new VirtualBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad); var operation = new VirtualBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation; return operation;
} }
} }

View File

@@ -92,19 +92,16 @@ namespace YooAsset
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync() public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
{ {
var operation = new DBFSInitializeOperation(this); var operation = new DBFSInitializeOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout) public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
{ {
var operation = new DBFSLoadPackageManifestOperation(this, packageVersion); var operation = new DBFSLoadPackageManifestOperation(this, packageVersion);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout) public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
{ {
var operation = new DBFSRequestPackageVersionOperation(this); var operation = new DBFSRequestPackageVersionOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
@@ -127,20 +124,17 @@ namespace YooAsset
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle) if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{ {
var operation = new DBFSLoadAssetBundleOperation(this, bundle); var operation = new DBFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle) else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
{ {
var operation = new DBFSLoadRawBundleOperation(this, bundle); var operation = new DBFSLoadRawBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else else
{ {
string error = $"{nameof(DefaultBuildinFileSystem)} not support load bundle type : {bundle.BundleType}"; string error = $"{nameof(DefaultBuildinFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error); var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
} }
@@ -194,9 +188,8 @@ namespace YooAsset
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices); _unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
_unpackFileSystem.OnCreate(packageName, null); _unpackFileSystem.OnCreate(packageName, null);
} }
public virtual void OnUpdate() public virtual void OnDestroy()
{ {
_unpackFileSystem.OnUpdate();
} }
public virtual bool Belong(PackageBundle bundle) public virtual bool Belong(PackageBundle bundle)
@@ -346,10 +339,13 @@ namespace YooAsset
return false; return false;
#if UNITY_ANDROID #if UNITY_ANDROID
if (bundle.BundleType == (int)EBuildBundleType.RawBundle || bundle.Encrypted) if (bundle.Encrypted)
return true; return true;
else
return false; if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
return true;
return false;
#else #else
return false; return false;
#endif #endif

View File

@@ -18,9 +18,8 @@ namespace YooAsset
YooLogger.Log("Begin to create catalog file !"); YooLogger.Log("Begin to create catalog file !");
string savePath = YooAssetSettingsData.GetYooResourcesFullPath(); string savePath = YooAssetSettingsData.GetYooResourcesFullPath();
DirectoryInfo saveDirectory = new DirectoryInfo(savePath); if (UnityEditor.AssetDatabase.DeleteAsset(savePath))
if (saveDirectory.Exists) UnityEditor.AssetDatabase.Refresh();
saveDirectory.Delete(true);
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot(); string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);

View File

@@ -24,7 +24,7 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_WEBGL #if UNITY_WEBGL
_steps = ESteps.Done; _steps = ESteps.Done;
@@ -37,7 +37,7 @@ namespace YooAsset
_steps = ESteps.InitUnpackFileSystem; _steps = ESteps.InitUnpackFileSystem;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -47,9 +47,11 @@ namespace YooAsset
if (_copyBuildinPackageManifestOp == null) if (_copyBuildinPackageManifestOp == null)
{ {
_copyBuildinPackageManifestOp = new CopyBuildinPackageManifestOperation(_fileSystem); _copyBuildinPackageManifestOp = new CopyBuildinPackageManifestOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _copyBuildinPackageManifestOp); _copyBuildinPackageManifestOp.StartOperation();
AddChildOperation(_copyBuildinPackageManifestOp);
} }
_copyBuildinPackageManifestOp.UpdateOperation();
if (_copyBuildinPackageManifestOp.IsDone == false) if (_copyBuildinPackageManifestOp.IsDone == false)
return; return;
@@ -68,8 +70,13 @@ namespace YooAsset
if (_steps == ESteps.InitUnpackFileSystem) if (_steps == ESteps.InitUnpackFileSystem)
{ {
if (_initUnpackFIleSystemOp == null) if (_initUnpackFIleSystemOp == null)
{
_initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem(); _initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem();
_initUnpackFIleSystemOp.StartOperation();
AddChildOperation(_initUnpackFIleSystemOp);
}
_initUnpackFIleSystemOp.UpdateOperation();
Progress = _initUnpackFIleSystemOp.Progress; Progress = _initUnpackFIleSystemOp.Progress;
if (_initUnpackFIleSystemOp.IsDone == false) if (_initUnpackFIleSystemOp.IsDone == false)
return; return;
@@ -113,9 +120,11 @@ namespace YooAsset
#endif #endif
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem); _loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp); _loadCatalogFileOp.StartOperation();
AddChildOperation(_loadCatalogFileOp);
} }
_loadCatalogFileOp.UpdateOperation();
if (_loadCatalogFileOp.IsDone == false) if (_loadCatalogFileOp.IsDone == false)
return; return;

View File

@@ -29,13 +29,13 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_bundle = bundle; _bundle = bundle;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
DownloadProgress = 1f; DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize; DownloadedBytes = _bundle.FileSize;
_steps = ESteps.LoadAssetBundle; _steps = ESteps.LoadAssetBundle;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -139,9 +139,6 @@ namespace YooAsset
} }
} }
} }
public override void AbortDownloadOperation()
{
}
} }
/// <summary> /// <summary>
@@ -166,13 +163,13 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_bundle = bundle; _bundle = bundle;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
DownloadProgress = 1f; DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize; DownloadedBytes = _bundle.FileSize;
_steps = ESteps.LoadBuildinRawBundle; _steps = ESteps.LoadBuildinRawBundle;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -206,8 +203,5 @@ namespace YooAsset
} }
} }
} }
public override void AbortDownloadOperation()
{
}
} }
} }

View File

@@ -23,11 +23,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_packageVersion = packageVersion; _packageVersion = packageVersion;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestBuildinPackageHash; _steps = ESteps.RequestBuildinPackageHash;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -37,9 +37,11 @@ namespace YooAsset
if (_requestBuildinPackageHashOp == null) if (_requestBuildinPackageHashOp == null)
{ {
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion); _requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion);
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageHashOp); _requestBuildinPackageHashOp.StartOperation();
AddChildOperation(_requestBuildinPackageHashOp);
} }
_requestBuildinPackageHashOp.UpdateOperation();
if (_requestBuildinPackageHashOp.IsDone == false) if (_requestBuildinPackageHashOp.IsDone == false)
return; return;
@@ -61,9 +63,11 @@ namespace YooAsset
{ {
string packageHash = _requestBuildinPackageHashOp.PackageHash; string packageHash = _requestBuildinPackageHashOp.PackageHash;
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash); _loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
OperationSystem.StartOperation(_fileSystem.PackageName, _loadBuildinPackageManifestOp); _loadBuildinPackageManifestOp.StartOperation();
AddChildOperation(_loadBuildinPackageManifestOp);
} }
_loadBuildinPackageManifestOp.UpdateOperation();
if (_loadBuildinPackageManifestOp.IsDone == false) if (_loadBuildinPackageManifestOp.IsDone == false)
return; return;

View File

@@ -19,11 +19,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestPackageVersion; _steps = ESteps.RequestPackageVersion;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -33,9 +33,11 @@ namespace YooAsset
if (_requestBuildinPackageVersionOp == null) if (_requestBuildinPackageVersionOp == null)
{ {
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem); _requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp); _requestBuildinPackageVersionOp.StartOperation();
AddChildOperation(_requestBuildinPackageVersionOp);
} }
_requestBuildinPackageVersionOp.UpdateOperation();
if (_requestBuildinPackageVersionOp.IsDone == false) if (_requestBuildinPackageVersionOp.IsDone == false)
return; return;

View File

@@ -29,11 +29,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestPackageVersion; _steps = ESteps.RequestPackageVersion;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -43,9 +43,11 @@ namespace YooAsset
if (_requestBuildinPackageVersionOp == null) if (_requestBuildinPackageVersionOp == null)
{ {
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem); _requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp); _requestBuildinPackageVersionOp.StartOperation();
AddChildOperation(_requestBuildinPackageVersionOp);
} }
_requestBuildinPackageVersionOp.UpdateOperation();
if (_requestBuildinPackageVersionOp.IsDone == false) if (_requestBuildinPackageVersionOp.IsDone == false)
return; return;
@@ -82,9 +84,11 @@ namespace YooAsset
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion); string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
OperationSystem.StartOperation(_fileSystem.PackageName, _hashFileRequestOp); _hashFileRequestOp.StartOperation();
AddChildOperation(_hashFileRequestOp);
} }
_hashFileRequestOp.UpdateOperation();
if (_hashFileRequestOp.IsDone == false) if (_hashFileRequestOp.IsDone == false)
return; return;
@@ -121,9 +125,11 @@ namespace YooAsset
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion); string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
OperationSystem.StartOperation(_fileSystem.PackageName, _manifestFileRequestOp); _manifestFileRequestOp.StartOperation();
AddChildOperation(_manifestFileRequestOp);
} }
_manifestFileRequestOp.UpdateOperation();
if (_manifestFileRequestOp.IsDone == false) if (_manifestFileRequestOp.IsDone == false)
return; return;

View File

@@ -19,11 +19,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.LoadCatalog; _steps = ESteps.LoadCatalog;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -31,11 +31,11 @@ namespace YooAsset
_packageVersion = packageVersion; _packageVersion = packageVersion;
_packageHash = packageHash; _packageHash = packageHash;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestFileData; _steps = ESteps.RequestFileData;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -47,9 +47,11 @@ namespace YooAsset
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion); string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url);
OperationSystem.StartOperation(_fileSystem.PackageName, _webDataRequestOp); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
} }
_webDataRequestOp.UpdateOperation();
if (_webDataRequestOp.IsDone == false) if (_webDataRequestOp.IsDone == false)
return; return;
@@ -85,9 +87,11 @@ namespace YooAsset
if (_deserializer == null) if (_deserializer == null)
{ {
_deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result); _deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result);
OperationSystem.StartOperation(_fileSystem.PackageName, _deserializer); _deserializer.StartOperation();
AddChildOperation(_deserializer);
} }
_deserializer.UpdateOperation();
Progress = _deserializer.Progress; Progress = _deserializer.Progress;
if (_deserializer.IsDone == false) if (_deserializer.IsDone == false)
return; return;
@@ -106,5 +110,9 @@ namespace YooAsset
} }
} }
} }
internal override string InternalGetDesc()
{
return $"PackageVersion : {_packageVersion} PackageHash : {_packageHash}";
}
} }
} }

View File

@@ -26,11 +26,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_packageVersion = packageVersion; _packageVersion = packageVersion;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestPackageHash; _steps = ESteps.RequestPackageHash;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -42,9 +42,11 @@ namespace YooAsset
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion); string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url); _webTextRequestOp = new UnityWebTextRequestOperation(url);
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp); _webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp);
} }
_webTextRequestOp.UpdateOperation();
if (_webTextRequestOp.IsDone == false) if (_webTextRequestOp.IsDone == false)
return; return;

View File

@@ -24,11 +24,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.RequestPackageVersion; _steps = ESteps.RequestPackageVersion;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -40,9 +40,11 @@ namespace YooAsset
string filePath = _fileSystem.GetBuildinPackageVersionFilePath(); string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url); _webTextRequestOp = new UnityWebTextRequestOperation(url);
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp); _webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp);
} }
_webTextRequestOp.UpdateOperation();
if (_webTextRequestOp.IsDone == false) if (_webTextRequestOp.IsDone == false)
return; return;

View File

@@ -15,13 +15,18 @@ namespace YooAsset
protected readonly Dictionary<string, string> _bundleDataFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _bundleDataFilePathMapping = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _bundleInfoFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _bundleInfoFilePathMapping = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _tempFilePathMapping = new Dictionary<string, string>(10000); protected readonly Dictionary<string, string> _tempFilePathMapping = new Dictionary<string, string>(10000);
protected DefaultCacheDownloadCenter _downloadCenter;
protected string _packageRoot; protected string _packageRoot;
protected string _tempFilesRoot; protected string _tempFilesRoot;
protected string _cacheBundleFilesRoot; protected string _cacheBundleFilesRoot;
protected string _cacheManifestFilesRoot; protected string _cacheManifestFilesRoot;
/// <summary>
/// 下载中心
/// 说明:当异步操作任务终止的时候,所有下载子任务都会一同被终止!
/// </summary>
public DownloadCenterOperation DownloadCenter { set; get; }
/// <summary> /// <summary>
/// 包裹名称 /// 包裹名称
/// </summary> /// </summary>
@@ -98,19 +103,16 @@ namespace YooAsset
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync() public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
{ {
var operation = new DCFSInitializeOperation(this); var operation = new DCFSInitializeOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout) public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
{ {
var operation = new DCFSLoadPackageManifestOperation(this, packageVersion, timeout); var operation = new DCFSLoadPackageManifestOperation(this, packageVersion, timeout);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout) public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
{ {
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout); var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam) public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
@@ -118,64 +120,60 @@ namespace YooAsset
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString()) if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
{ {
var operation = new ClearAllCacheBundleFilesOperation(this); var operation = new ClearAllCacheBundleFilesOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString()) else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
{ {
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest); var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString()) else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
{ {
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam); var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString()) else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString())
{ {
var operation = new ClearAllCacheManifestFilesOperation(this); var operation = new ClearAllCacheManifestFilesOperation(this);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString()) else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
{ {
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest); var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else else
{ {
string error = $"Invalid clear mode : {clearMode}"; string error = $"Invalid clear mode : {clearMode}";
var operation = new FSClearCacheFilesCompleteOperation(error); var operation = new FSClearCacheFilesCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
{ {
return _downloadCenter.DownloadFileAsync(bundle, param); var downloader = DownloadCenter.DownloadFileAsync(bundle, param);
downloader.Reference(); //增加下载器的引用计数
// 注意:将下载器进行包裹,可以避免父类任务终止的时候,连带子任务里的下载器也一起被终止!
var wrapper = new DownloadFileWrapper(downloader);
return wrapper;
} }
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{ {
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle) if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{ {
var operation = new DCFSLoadAssetBundleOperation(this, bundle); var operation = new DCFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle) else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
{ {
var operation = new DCFSLoadRawBundleOperation(this, bundle); var operation = new DCFSLoadRawBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
else else
{ {
string error = $"{nameof(DefaultCacheFileSystem)} not support load bundle type : {bundle.BundleType}"; string error = $"{nameof(DefaultCacheFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error); var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation; return operation;
} }
} }
@@ -231,11 +229,14 @@ namespace YooAsset
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName); _cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName); _tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName); _cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
_downloadCenter = new DefaultCacheDownloadCenter(this);
} }
public virtual void OnUpdate() public virtual void OnDestroy()
{ {
_downloadCenter.Update(); if (DownloadCenter != null)
{
DownloadCenter.AbortOperation();
DownloadCenter = null;
}
} }
public virtual bool Belong(PackageBundle bundle) public virtual bool Belong(PackageBundle bundle)

View File

@@ -9,6 +9,7 @@ namespace YooAsset
CheckAppFootPrint, CheckAppFootPrint,
SearchCacheFiles, SearchCacheFiles,
VerifyCacheFiles, VerifyCacheFiles,
CreateDownloadCenter,
Done, Done,
} }
@@ -22,7 +23,7 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
#if UNITY_WEBGL #if UNITY_WEBGL
_steps = ESteps.Done; _steps = ESteps.Done;
@@ -32,7 +33,7 @@ namespace YooAsset
_steps = ESteps.CheckAppFootPrint; _steps = ESteps.CheckAppFootPrint;
#endif #endif
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -58,9 +59,11 @@ namespace YooAsset
if (_searchCacheFilesOp == null) if (_searchCacheFilesOp == null)
{ {
_searchCacheFilesOp = new SearchCacheFilesOperation(_fileSystem); _searchCacheFilesOp = new SearchCacheFilesOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _searchCacheFilesOp); _searchCacheFilesOp.StartOperation();
AddChildOperation(_searchCacheFilesOp);
} }
_searchCacheFilesOp.UpdateOperation();
Progress = _searchCacheFilesOp.Progress; Progress = _searchCacheFilesOp.Progress;
if (_searchCacheFilesOp.IsDone == false) if (_searchCacheFilesOp.IsDone == false)
return; return;
@@ -73,17 +76,18 @@ namespace YooAsset
if (_verifyCacheFilesOp == null) if (_verifyCacheFilesOp == null)
{ {
_verifyCacheFilesOp = new VerifyCacheFilesOperation(_fileSystem, _searchCacheFilesOp.Result); _verifyCacheFilesOp = new VerifyCacheFilesOperation(_fileSystem, _searchCacheFilesOp.Result);
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyCacheFilesOp); _verifyCacheFilesOp.StartOperation();
AddChildOperation(_verifyCacheFilesOp);
} }
_verifyCacheFilesOp.UpdateOperation();
Progress = _verifyCacheFilesOp.Progress; Progress = _verifyCacheFilesOp.Progress;
if (_verifyCacheFilesOp.IsDone == false) if (_verifyCacheFilesOp.IsDone == false)
return; return;
if (_verifyCacheFilesOp.Status == EOperationStatus.Succeed) if (_verifyCacheFilesOp.Status == EOperationStatus.Succeed)
{ {
_steps = ESteps.Done; _steps = ESteps.CreateDownloadCenter;
Status = EOperationStatus.Succeed;
YooLogger.Log($"Package '{_fileSystem.PackageName}' cached files count : {_fileSystem.FileCount}"); YooLogger.Log($"Package '{_fileSystem.PackageName}' cached files count : {_fileSystem.FileCount}");
} }
else else
@@ -93,6 +97,19 @@ namespace YooAsset
Error = _verifyCacheFilesOp.Error; Error = _verifyCacheFilesOp.Error;
} }
} }
if (_steps == ESteps.CreateDownloadCenter)
{
// 注意:下载中心作为独立任务运行!
if (_fileSystem.DownloadCenter == null)
{
_fileSystem.DownloadCenter = new DownloadCenterOperation(_fileSystem);
OperationSystem.StartOperation(_fileSystem.PackageName, _fileSystem.DownloadCenter);
}
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
} }
} }
} }

View File

@@ -29,11 +29,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_bundle = bundle; _bundle = bundle;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckExist; _steps = ESteps.CheckExist;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -54,15 +54,19 @@ namespace YooAsset
if (_steps == ESteps.DownloadFile) if (_steps == ESteps.DownloadFile)
{ {
// 注意边玩边下下载器引用计数没有Release
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
_downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp);
} }
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete(); _downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
DownloadProgress = _downloadFileOp.DownloadProgress; DownloadProgress = _downloadFileOp.DownloadProgress;
DownloadedBytes = _downloadFileOp.DownloadedBytes; DownloadedBytes = _downloadFileOp.DownloadedBytes;
if (_downloadFileOp.IsDone == false) if (_downloadFileOp.IsDone == false)
@@ -219,14 +223,6 @@ namespace YooAsset
} }
} }
} }
public override void AbortDownloadOperation()
{
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.SetAbort();
}
}
} }
internal class DCFSLoadRawBundleOperation : FSLoadBundleOperation internal class DCFSLoadRawBundleOperation : FSLoadBundleOperation
@@ -251,11 +247,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_bundle = bundle; _bundle = bundle;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckExist; _steps = ESteps.CheckExist;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -276,15 +272,19 @@ namespace YooAsset
if (_steps == ESteps.DownloadFile) if (_steps == ESteps.DownloadFile)
{ {
// 注意边玩边下下载器引用计数没有Release
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60); DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
_downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp);
} }
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete(); _downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
DownloadProgress = _downloadFileOp.DownloadProgress; DownloadProgress = _downloadFileOp.DownloadProgress;
DownloadedBytes = _downloadFileOp.DownloadedBytes; DownloadedBytes = _downloadFileOp.DownloadedBytes;
if (_downloadFileOp.IsDone == false) if (_downloadFileOp.IsDone == false)
@@ -335,13 +335,5 @@ namespace YooAsset
} }
} }
} }
public override void AbortDownloadOperation()
{
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.SetAbort();
}
}
} }
} }

View File

@@ -30,11 +30,11 @@ namespace YooAsset
_packageVersion = packageVersion; _packageVersion = packageVersion;
_timeout = timeout; _timeout = timeout;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.DownloadPackageHash; _steps = ESteps.DownloadPackageHash;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -44,9 +44,11 @@ namespace YooAsset
if (_downloadPackageHashOp == null) if (_downloadPackageHashOp == null)
{ {
_downloadPackageHashOp = new DownloadPackageHashOperation(_fileSystem, _packageVersion, _timeout); _downloadPackageHashOp = new DownloadPackageHashOperation(_fileSystem, _packageVersion, _timeout);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadPackageHashOp); _downloadPackageHashOp.StartOperation();
AddChildOperation(_downloadPackageHashOp);
} }
_downloadPackageHashOp.UpdateOperation();
if (_downloadPackageHashOp.IsDone == false) if (_downloadPackageHashOp.IsDone == false)
return; return;
@@ -67,9 +69,11 @@ namespace YooAsset
if (_downloadPackageManifestOp == null) if (_downloadPackageManifestOp == null)
{ {
_downloadPackageManifestOp = new DownloadPackageManifestOperation(_fileSystem, _packageVersion, _timeout); _downloadPackageManifestOp = new DownloadPackageManifestOperation(_fileSystem, _packageVersion, _timeout);
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadPackageManifestOp); _downloadPackageManifestOp.StartOperation();
AddChildOperation(_downloadPackageManifestOp);
} }
_downloadPackageManifestOp.UpdateOperation();
if (_downloadPackageManifestOp.IsDone == false) if (_downloadPackageManifestOp.IsDone == false)
return; return;
@@ -90,9 +94,11 @@ namespace YooAsset
if (_loadCachePackageHashOp == null) if (_loadCachePackageHashOp == null)
{ {
_loadCachePackageHashOp = new LoadCachePackageHashOperation(_fileSystem, _packageVersion); _loadCachePackageHashOp = new LoadCachePackageHashOperation(_fileSystem, _packageVersion);
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCachePackageHashOp); _loadCachePackageHashOp.StartOperation();
AddChildOperation(_loadCachePackageHashOp);
} }
_loadCachePackageHashOp.UpdateOperation();
if (_loadCachePackageHashOp.IsDone == false) if (_loadCachePackageHashOp.IsDone == false)
return; return;
@@ -115,9 +121,11 @@ namespace YooAsset
{ {
string packageHash = _loadCachePackageHashOp.PackageHash; string packageHash = _loadCachePackageHashOp.PackageHash;
_loadCachePackageManifestOp = new LoadCachePackageManifestOperation(_fileSystem, _packageVersion, packageHash); _loadCachePackageManifestOp = new LoadCachePackageManifestOperation(_fileSystem, _packageVersion, packageHash);
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCachePackageManifestOp); _loadCachePackageManifestOp.StartOperation();
AddChildOperation(_loadCachePackageManifestOp);
} }
_loadCachePackageManifestOp.UpdateOperation();
Progress = _loadCachePackageManifestOp.Progress; Progress = _loadCachePackageManifestOp.Progress;
if (_loadCachePackageManifestOp.IsDone == false) if (_loadCachePackageManifestOp.IsDone == false)
return; return;

View File

@@ -23,11 +23,11 @@ namespace YooAsset
_appendTimeTicks = appendTimeTicks; _appendTimeTicks = appendTimeTicks;
_timeout = timeout; _timeout = timeout;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.GetPackageVersion; _steps = ESteps.GetPackageVersion;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -37,9 +37,11 @@ namespace YooAsset
if (_requestRemotePackageVersionOp == null) if (_requestRemotePackageVersionOp == null)
{ {
_requestRemotePackageVersionOp = new RequestRemotePackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout); _requestRemotePackageVersionOp = new RequestRemotePackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout);
OperationSystem.StartOperation(_fileSystem.PackageName, _requestRemotePackageVersionOp); _requestRemotePackageVersionOp.StartOperation();
AddChildOperation(_requestRemotePackageVersionOp);
} }
_requestRemotePackageVersionOp.UpdateOperation();
Progress = _requestRemotePackageVersionOp.Progress; Progress = _requestRemotePackageVersionOp.Progress;
if (_requestRemotePackageVersionOp.IsDone == false) if (_requestRemotePackageVersionOp.IsDone == false)
return; return;

View File

@@ -23,11 +23,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.GetAllCacheFiles; _steps = ESteps.GetAllCacheFiles;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -20,11 +20,11 @@ namespace YooAsset
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.ClearAllCacheFiles; _steps = ESteps.ClearAllCacheFiles;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -27,11 +27,11 @@ namespace YooAsset
_manifest = manifest; _manifest = manifest;
_clearParam = clearParam; _clearParam = clearParam;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.CheckArgs; _steps = ESteps.CheckArgs;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -25,11 +25,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_manifest = manifest; _manifest = manifest;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.GetUnusedCacheFiles; _steps = ESteps.GetUnusedCacheFiles;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -22,11 +22,11 @@ namespace YooAsset
_fileSystem = fileSystem; _fileSystem = fileSystem;
_manifest = manifest; _manifest = manifest;
} }
internal override void InternalOnStart() internal override void InternalStart()
{ {
_steps = ESteps.ClearUnusedCacheFiles; _steps = ESteps.ClearUnusedCacheFiles;
} }
internal override void InternalOnUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -3,33 +3,33 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
internal class DefaultCacheDownloadCenter internal class DownloadCenterOperation : AsyncOperationBase
{ {
private readonly DefaultCacheFileSystem _fileSystem; private readonly DefaultCacheFileSystem _fileSystem;
protected readonly Dictionary<string, DefaultDownloadFileOperation> _downloaders = new Dictionary<string, DefaultDownloadFileOperation>(1000); protected readonly Dictionary<string, DefaultDownloadFileOperation> _downloaders = new Dictionary<string, DefaultDownloadFileOperation>(1000);
protected readonly List<string> _removeDownloadList = new List<string>(1000); protected readonly List<string> _removeDownloadList = new List<string>(1000);
public DefaultCacheDownloadCenter(DefaultCacheFileSystem fileSystem) public DownloadCenterOperation(DefaultCacheFileSystem fileSystem)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
} }
internal override void InternalStart()
/// <summary> {
/// 更新下载中心 }
/// </summary> internal override void InternalUpdate()
public void Update()
{ {
// 获取可移除的下载器集合 // 获取可移除的下载器集合
_removeDownloadList.Clear(); _removeDownloadList.Clear();
foreach (var valuePair in _downloaders) foreach (var valuePair in _downloaders)
{ {
var downloader = valuePair.Value; var downloader = valuePair.Value;
downloader.UpdateOperation();
// 注意:主动终止引用计数为零的下载任务 // 注意:主动终止引用计数为零的下载任务
if (downloader.RefCount <= 0) if (downloader.RefCount <= 0)
{ {
_removeDownloadList.Add(valuePair.Key); _removeDownloadList.Add(valuePair.Key);
downloader.SetAbort(); downloader.AbortOperation();
continue; continue;
} }
@@ -61,7 +61,7 @@ namespace YooAsset
var operation = operationPair.Value; var operation = operationPair.Value;
if (operation.Status == EOperationStatus.None) if (operation.Status == EOperationStatus.None)
{ {
OperationSystem.StartOperation(_fileSystem.PackageName, operation); operation.StartOperation();
startCount--; startCount--;
if (startCount <= 0) if (startCount <= 0)
break; break;
@@ -79,7 +79,6 @@ namespace YooAsset
// 查询旧的下载器 // 查询旧的下载器
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader)) if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
{ {
oldDownloader.Reference();
return oldDownloader; return oldDownloader;
} }
@@ -101,13 +100,13 @@ namespace YooAsset
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize) if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
{ {
newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, param); newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, param);
newDownloader.Reference(); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }
else else
{ {
newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, param); newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, param);
newDownloader.Reference(); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }
return newDownloader; return newDownloader;

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