mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-15 04:00:16 +00:00
Compare commits
92 Commits
2.2.10
...
2.3.2-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7382afe535 | ||
|
|
af7d4774d6 | ||
|
|
520a8a0623 | ||
|
|
fbd0d8ec40 | ||
|
|
3fea98ce4c | ||
|
|
7c561ce254 | ||
|
|
522ddb5115 | ||
|
|
47f5790507 | ||
|
|
0cdcfe7f52 | ||
|
|
e4d69d869b | ||
|
|
61afb70cb9 | ||
|
|
79580697a1 | ||
|
|
6cb74760b0 | ||
|
|
c758aa81ff | ||
|
|
400c2ccefe | ||
|
|
64e9734bbe | ||
|
|
f6244885be | ||
|
|
82c57c382f | ||
|
|
7eacb46555 | ||
|
|
d9c911d89b | ||
|
|
a3ceb3dcb6 | ||
|
|
a5b68b28b2 | ||
|
|
bd285faf37 | ||
|
|
8a4960b560 | ||
|
|
83c6ae2057 | ||
|
|
b71563e889 | ||
|
|
79e0cf85f9 | ||
|
|
e996eaa008 | ||
|
|
5088c9e985 | ||
|
|
610b3c6d32 | ||
|
|
cc7290f10e | ||
|
|
576b842368 | ||
|
|
d23c0ba715 | ||
|
|
98e19baebd | ||
|
|
f5947db44a | ||
|
|
e978164329 | ||
|
|
966c8f2efa | ||
|
|
a57fec3d71 | ||
|
|
84844eda20 | ||
|
|
698cdcba61 | ||
|
|
1d6c9393d4 | ||
|
|
b654ac156d | ||
|
|
d133a9a692 | ||
|
|
d55db19f0e | ||
|
|
e3fc3df32c | ||
|
|
f2334da72d | ||
|
|
2902b6c2cf | ||
|
|
dfa95b57b9 | ||
|
|
33a2cf66d0 | ||
|
|
5f52cf5b51 | ||
|
|
9d07905f2d | ||
|
|
26dbe9dfdd | ||
|
|
98c5851071 | ||
|
|
a6ee571d65 | ||
|
|
a138701afe | ||
|
|
e52bdea255 | ||
|
|
068a712a30 | ||
|
|
80a5300648 | ||
|
|
0c36e458f7 | ||
|
|
b2fa52e4c4 | ||
|
|
151e978e5b | ||
|
|
9e806861ec | ||
|
|
a9a9368b9b | ||
|
|
7936ba31ea | ||
|
|
afc456de9a | ||
|
|
a98db0ba83 | ||
|
|
fb8720edd3 | ||
|
|
2aa2a0ac3a | ||
|
|
0531b6ef3a | ||
|
|
24142de11f | ||
|
|
7fad6eb70b | ||
|
|
f60227abdf | ||
|
|
18d6a74c53 | ||
|
|
03d06ba657 | ||
|
|
07086b68c8 | ||
|
|
0a85f3126f | ||
|
|
efa4180340 | ||
|
|
fb06f2aa11 | ||
|
|
ce023cedb8 | ||
|
|
3d1a28a50e | ||
|
|
5d2d0b4168 | ||
|
|
fa985a5a93 | ||
|
|
40f9937b60 | ||
|
|
c543c629c3 | ||
|
|
f861279c49 | ||
|
|
ee89f81d46 | ||
|
|
6d216561f8 | ||
|
|
0a96e583d3 | ||
|
|
c9d263c60d | ||
|
|
2d6488abf4 | ||
|
|
7dfbac4a24 | ||
|
|
7cfe4cb2c9 |
@@ -2,6 +2,142 @@
|
||||
|
||||
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
|
||||
|
||||
### Improvements
|
||||
|
||||
资源收集窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
资源扫描窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了UIElements扩展类ReorderableListView
|
||||
|
||||
- 新增初始化方法
|
||||
|
||||
```csharp
|
||||
public class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置异步系统参数,快速启动模式的开关
|
||||
/// 注意:该模式默认开启
|
||||
/// </summary>
|
||||
public static void SetOperationSystemQuickStartMode(bool state)
|
||||
}
|
||||
```
|
||||
|
||||
- 新增打包构建参数
|
||||
|
||||
```csharp
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 旧版依赖模式
|
||||
/// 说明:兼容YooAssets1.5.x版本
|
||||
/// </summary>
|
||||
public bool LegacyDependency = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#472) 修复了Unity6平台,TableView视图无法显示问题。
|
||||
- 修复了微信小游戏和抖音小游戏未正确使用插件的卸载方法。
|
||||
|
||||
## [2.2.12] - 2025-02-14
|
||||
|
||||
### Improvements
|
||||
|
||||
- WebGL网页平台支持文件加密。
|
||||
- 微信小游戏平台支持文件加密。
|
||||
- 抖音小游戏平台支持文件加密。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#466) 修复了微信小游戏文件系统查询机制不生效!
|
||||
- (#341) 修复了微信小游戏的下载进度异常问题。
|
||||
- (#471) 修复了Unity2019,Unity2020平台上,TableView视图无法显示的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了ResourcePackage.UnloadAllAssetsAsync(UnloadAllAssetsOptions options)方法
|
||||
|
||||
```csharp
|
||||
public sealed class UnloadAllAssetsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
||||
/// </summary>
|
||||
public bool ReleaseAllHandles = true;
|
||||
|
||||
/// <summary>
|
||||
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
||||
/// </summary>
|
||||
public bool LockLoadOperation = true;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.2.11] - 2025-02-10
|
||||
|
||||
### Improvements
|
||||
|
||||
- AssetArtScanner配置和生成报告的容错性检测。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#465) 修复了特殊情况下,没有配置资源包文件后缀名构建失败的问题。
|
||||
- (#468) 修复了安卓平台二次启动加载原生文件或加密文件失败的问题。
|
||||
|
||||
## [2.2.10] - 2025-02-08
|
||||
|
||||
### Improvements
|
||||
|
||||
@@ -3,9 +3,24 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public enum EHeaderType
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
AssetPath,
|
||||
|
||||
/// <summary>
|
||||
/// 字符串
|
||||
/// </summary>
|
||||
StringValue,
|
||||
|
||||
/// <summary>
|
||||
/// 整数数值
|
||||
/// </summary>
|
||||
LongValue,
|
||||
|
||||
/// <summary>
|
||||
/// 浮点数数值
|
||||
/// </summary>
|
||||
DoubleValue,
|
||||
}
|
||||
}
|
||||
@@ -31,12 +31,28 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, string scanInfo)
|
||||
public void AddScanInfo(string headerTitle, string value)
|
||||
{
|
||||
var reportScanInfo = new ReportScanInfo(headerTitle, scanInfo);
|
||||
var reportScanInfo = new ReportScanInfo(headerTitle, value);
|
||||
ScanInfos.Add(reportScanInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, long value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, double value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取扫描信息
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -93,5 +94,35 @@ namespace YooAsset.Editor
|
||||
HeaderType = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测数值有效性
|
||||
/// </summary>
|
||||
public void CheckValueValid(string value)
|
||||
{
|
||||
if (HeaderType == EHeaderType.AssetPath)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
if (double.TryParse(value, out double doubleValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid double value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.LongValue)
|
||||
{
|
||||
if (long.TryParse(value, out long longValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid long value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(HeaderType.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,9 @@ namespace YooAsset.Editor
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报告标题
|
||||
/// 报告名称
|
||||
/// </summary>
|
||||
public string ReportTitle;
|
||||
public string ReportName;
|
||||
|
||||
/// <summary>
|
||||
/// 报告介绍
|
||||
@@ -41,7 +41,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 报告的标题列表
|
||||
/// </summary>
|
||||
public List<ReportHeader> HeaderTitles = new List<ReportHeader>();
|
||||
public List<ReportHeader> ReportHeaders = new List<ReportHeader>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描的元素列表
|
||||
@@ -49,23 +49,70 @@ namespace YooAsset.Editor
|
||||
public List<ReportElement> ReportElements = new List<ReportElement>();
|
||||
|
||||
|
||||
public ScanReport(string reportTitle, string reportDesc)
|
||||
public ScanReport(string reportName, string reportDesc)
|
||||
{
|
||||
ReportTitle = reportTitle;
|
||||
ReportName = reportName;
|
||||
ReportDesc = reportDesc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width);
|
||||
HeaderTitles.Add(reportHeader);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width, minWidth, maxWidth);
|
||||
HeaderTitles.Add(reportHeader);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测错误
|
||||
/// </summary>
|
||||
public void CheckError()
|
||||
{
|
||||
// 检测标题
|
||||
Dictionary<string, ReportHeader> headerMap = new Dictionary<string, ReportHeader>();
|
||||
foreach (var header in ReportHeaders)
|
||||
{
|
||||
string headerTitle = header.HeaderTitle;
|
||||
if (headerMap.ContainsKey(headerTitle))
|
||||
throw new Exception($"The header title {headerTitle} already exists !");
|
||||
else
|
||||
headerMap.Add(headerTitle, header);
|
||||
}
|
||||
|
||||
// 检测扫描元素
|
||||
HashSet<string> elementMap = new HashSet<string>();
|
||||
foreach (var element in ReportElements)
|
||||
{
|
||||
if (string.IsNullOrEmpty(element.GUID))
|
||||
throw new Exception($"The report element GUID is null or empty !");
|
||||
|
||||
if (elementMap.Contains(element.GUID))
|
||||
throw new Exception($"The report element GUID already exists ! {element.GUID}");
|
||||
else
|
||||
elementMap.Add(element.GUID);
|
||||
|
||||
foreach (var scanInfo in element.ScanInfos)
|
||||
{
|
||||
if (headerMap.ContainsKey(scanInfo.HeaderTitle) == false)
|
||||
throw new Exception($"The report element header {scanInfo.HeaderTitle} is missing !");
|
||||
|
||||
// 检测数值有效性
|
||||
var header = headerMap[scanInfo.HeaderTitle];
|
||||
header.CheckValueValid(scanInfo.ScanInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,9 @@ namespace YooAsset.Editor
|
||||
if (string.IsNullOrEmpty(SchemaType))
|
||||
{
|
||||
SchemaType = scanReport.SchemaType;
|
||||
ReportTitle = scanReport.ReportTitle;
|
||||
ReportTitle = scanReport.ReportName;
|
||||
ReportDesc = scanReport.ReportDesc;
|
||||
Headers = scanReport.HeaderTitles;
|
||||
Headers = scanReport.ReportHeaders;
|
||||
}
|
||||
|
||||
if (SchemaType != scanReport.SchemaType)
|
||||
@@ -82,7 +82,7 @@ namespace YooAsset.Editor
|
||||
List<ReportElement> elements = scanReport.ReportElements;
|
||||
|
||||
// 设置白名单
|
||||
var scanner = AssetArtScannerSettingData.GetScannerByGUID(scannerGUID);
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
foreach (var element in elements)
|
||||
@@ -144,7 +144,7 @@ namespace YooAsset.Editor
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
var scanner = AssetArtScannerSettingData.GetScannerByGUID(scannerGUID);
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
List<string> whiteList = new List<string>(elements.Count);
|
||||
@@ -207,7 +207,7 @@ namespace YooAsset.Editor
|
||||
|
||||
private void FixInternal(string scannerGUID, List<ReportElement> fixList)
|
||||
{
|
||||
AssetArtScanner scanner = AssetArtScannerSettingData.GetScannerByGUID(scannerGUID);
|
||||
AssetArtScanner scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
var schema = scanner.LoadSchema();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace YooAsset.Editor
|
||||
// 检测标题数和内容是否匹配
|
||||
foreach (var element in report.ReportElements)
|
||||
{
|
||||
if (element.ScanInfos.Count != report.HeaderTitles.Count)
|
||||
if (element.ScanInfos.Count != report.ReportHeaders.Count)
|
||||
{
|
||||
throw new Exception($"报告的标题数和内容不匹配!");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -46,6 +47,17 @@ namespace YooAsset.Editor
|
||||
public List<string> WhiteList = new List<string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测关键字匹配
|
||||
/// </summary>
|
||||
public bool CheckKeyword(string keyword)
|
||||
{
|
||||
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在白名单里
|
||||
/// </summary>
|
||||
@@ -54,6 +66,24 @@ namespace YooAsset.Editor
|
||||
return WhiteList.Contains(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerName))
|
||||
throw new Exception($"Scanner name is null or empty !");
|
||||
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
throw new Exception($"Scanner {ScannerName} schema is null !");
|
||||
|
||||
if (string.IsNullOrEmpty(SaveDirectory) == false)
|
||||
{
|
||||
if (Directory.Exists(SaveDirectory) == false)
|
||||
throw new Exception($"Scanner {ScannerName} save directory is invalid : {SaveDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载扫描模式实例
|
||||
/// </summary>
|
||||
@@ -85,14 +115,11 @@ namespace YooAsset.Editor
|
||||
public ScanReport RunScanner()
|
||||
{
|
||||
if (Collectors.Count == 0)
|
||||
{
|
||||
Debug.LogWarning($"Scanner collector is empty : {ScannerName}");
|
||||
return null;
|
||||
}
|
||||
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
|
||||
|
||||
ScannerSchema schema = LoadSchema();
|
||||
if (schema == null)
|
||||
return null;
|
||||
throw new Exception($"Failed to load schema : {ScannerSchema}");
|
||||
|
||||
var report = schema.RunScanner(this);
|
||||
report.FileSign = ScannerDefine.ReportFileSign;
|
||||
@@ -101,13 +128,5 @@ namespace YooAsset.Editor
|
||||
report.ScannerGUID = ScannerGUID;
|
||||
return report;
|
||||
}
|
||||
|
||||
public bool CheckKeyword(string keyword)
|
||||
{
|
||||
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -13,5 +14,55 @@ namespace YooAsset.Editor
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
|
||||
/// <summary>
|
||||
/// 开始扫描
|
||||
/// </summary>
|
||||
public ScannerResult BeginScan(string scannerGUID)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取扫描器配置
|
||||
var scanner = GetScanner(scannerGUID);
|
||||
if (scanner == null)
|
||||
throw new Exception($"Invalid scanner GUID : {scannerGUID}");
|
||||
|
||||
// 检测配置合法性
|
||||
scanner.CheckConfigError();
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的扫描器
|
||||
/// </summary>
|
||||
public AssetArtScanner GetScanner(string scannerGUID)
|
||||
{
|
||||
foreach (var scanner in Scanners)
|
||||
{
|
||||
if (scanner.ScannerGUID == scannerGUID)
|
||||
return scanner;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,10 +61,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
var scanResult = ScanInternal(scanner);
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"Scanner {scanner.ScannerName} failed ! {scanResult.ErrorInfo}");
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,10 +82,10 @@ namespace YooAsset.Editor
|
||||
continue;
|
||||
}
|
||||
|
||||
var scanResult = ScanInternal(scanner);
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"Scanner {scanner.ScannerName} failed ! {scanResult.ErrorInfo}");
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,30 +95,14 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static ScannerResult Scan(string scannerGUID)
|
||||
{
|
||||
AssetArtScanner scanner = GetScannerByGUID(scannerGUID);
|
||||
var scanResult = ScanInternal(scanner);
|
||||
var scanResult = Setting.BeginScan(scannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"Scanner {scanner.ScannerName} failed ! {scanResult.ErrorInfo}");
|
||||
Debug.LogError(scanResult.ErrorInfo);
|
||||
}
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的扫描器
|
||||
/// </summary>
|
||||
public static AssetArtScanner GetScannerByGUID(string scannerGUID)
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
if (scanner.ScannerGUID == scannerGUID)
|
||||
return scanner;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||
return null;
|
||||
}
|
||||
|
||||
// 扫描器编辑相关
|
||||
public static AssetArtScanner CreateScanner(string name, string desc)
|
||||
{
|
||||
@@ -173,31 +157,5 @@ namespace YooAsset.Editor
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static ScannerResult ScanInternal(AssetArtScanner scanner)
|
||||
{
|
||||
if (scanner == null)
|
||||
return new ScannerResult("Scanner is null !");
|
||||
|
||||
string saveDirectory = "Assets/";
|
||||
if (string.IsNullOrEmpty(scanner.SaveDirectory) == false)
|
||||
{
|
||||
saveDirectory = scanner.SaveDirectory;
|
||||
if (Directory.Exists(saveDirectory) == false)
|
||||
return new ScannerResult($"Scanner save directory is invalid : {saveDirectory}");
|
||||
}
|
||||
|
||||
ScanReport report = scanner.RunScanner();
|
||||
if (report != null)
|
||||
{
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ScannerResult($"Scanner run failed : {scanner.ScannerName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,6 @@ namespace YooAsset.Editor
|
||||
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||
_scannerListView.bindItem = BindScannerListViewItem;
|
||||
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
@@ -277,12 +276,23 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_scannerListView.Clear();
|
||||
_scannerListView.ClearSelection();
|
||||
_scannerListView.itemsSource = FilterScanners();
|
||||
_scannerListView.Rebuild();
|
||||
|
||||
if (_lastModifyScannerIndex >= 0 && _lastModifyScannerIndex < _scannerListView.itemsSource.Count)
|
||||
var filterItems = FilterScanners();
|
||||
if (AssetArtScannerSettingData.Setting.Scanners.Count == filterItems.Count)
|
||||
{
|
||||
_scannerListView.selectedIndex = _lastModifyScannerIndex;
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = true;
|
||||
#endif
|
||||
_scannerListView.itemsSource = AssetArtScannerSettingData.Setting.Scanners;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = false;
|
||||
#endif
|
||||
_scannerListView.itemsSource = filterItems;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
}
|
||||
private List<AssetArtScanner> FilterScanners()
|
||||
@@ -344,31 +354,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 显示检视面板
|
||||
var scanSchema = selectScanner.LoadSchema();
|
||||
if (scanSchema != null)
|
||||
{
|
||||
var inspector = scanSchema.CreateInspector();
|
||||
if (inspector == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inspector.Containner is VisualElement container)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||
_inspectorContainer.Clear();
|
||||
_inspectorContainer.Add(container);
|
||||
_inspectorContainer.style.width = inspector.Width;
|
||||
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
RefreshInspector(scanSchema);
|
||||
|
||||
// 设置Schema对象
|
||||
if (scanSchema == null)
|
||||
@@ -521,6 +507,38 @@ namespace YooAsset.Editor
|
||||
AssetArtScannerSettingData.RemoveCollector(selectSacnner, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
// 属性面板相关
|
||||
private void RefreshInspector(ScannerSchema scanSchema)
|
||||
{
|
||||
if (scanSchema == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var inspector = scanSchema.CreateInspector();
|
||||
if (inspector == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspector.Containner is VisualElement container)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||
_inspectorContainer.Clear();
|
||||
_inspectorContainer.Add(container);
|
||||
_inspectorContainer.style.width = inspector.Width;
|
||||
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -9,7 +9,7 @@
|
||||
<ui:VisualElement name="ScannerListContainer" style="width: 250px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Scanner List" display-tooltip-when-elided="true" name="ScannerListTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; font-size: 12px;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="ScannerSearchField" style="width: 230px;" />
|
||||
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" reorder-mode="Animated" reorderable="true" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="ScannerAddContainer" style="justify-content: center; flex-direction: row; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 检视界面的UI元素容器(UIElements元素)
|
||||
/// </summary>
|
||||
public object Containner;
|
||||
public object Containner { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面宽度
|
||||
@@ -22,5 +22,24 @@ namespace YooAsset.Editor
|
||||
/// 检视界面最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = 250;
|
||||
|
||||
public SchemaInspector(object containner)
|
||||
{
|
||||
Containner = containner;
|
||||
}
|
||||
public SchemaInspector(object containner, int width)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public SchemaInspector(object containner, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,13 +56,13 @@ namespace YooAsset.Editor
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
private readonly Dictionary<string, BuildAssetInfo> _packAssetDic = new Dictionary<string, BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
public readonly List<BuildAssetInfo> AllPackAssets = new List<BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
@@ -86,51 +86,68 @@ namespace YooAsset.Editor
|
||||
public void PackAsset(BuildAssetInfo buildAsset)
|
||||
{
|
||||
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}");
|
||||
|
||||
_assetPaths.Add(assetPath);
|
||||
MainAssets.Add(buildAsset);
|
||||
_packAssetDic.Add(assetPath, buildAsset);
|
||||
AllPackAssets.Add(buildAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
public bool IsContainsPackAsset(string assetPath)
|
||||
{
|
||||
return _assetPaths.Contains(assetPath);
|
||||
return _packAssetDic.ContainsKey(assetPath);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
public BuildAssetInfo GetPackAssetInfo(string assetPath)
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(packAssets);
|
||||
foreach (var buildAsset in MainAssets)
|
||||
if (_packAssetDic.TryGetValue(assetPath, out BuildAssetInfo value))
|
||||
{
|
||||
if (buildAsset.AllDependAssetInfos == null)
|
||||
continue;
|
||||
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
||||
return value;
|
||||
}
|
||||
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)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
foreach (var dependAssetInfo in packAsset.AllDependAssetInfos)
|
||||
{
|
||||
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>
|
||||
@@ -142,7 +159,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllMainAssetPaths();
|
||||
build.assetNames = GetAllPackAssetPaths();
|
||||
return build;
|
||||
}
|
||||
|
||||
@@ -151,7 +168,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,17 +43,21 @@ namespace YooAsset.Editor
|
||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||
|
||||
// 处理资源清单的ID数据
|
||||
ProcessPacakgeIDs(manifest);
|
||||
// 1. 处理资源清单的资源对象
|
||||
ProcessPacakgeAsset(manifest);
|
||||
|
||||
// 处理资源包的依赖列表
|
||||
// 2. 处理资源包的依赖列表
|
||||
if (processBundleDepends)
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
// 3. 处理资源包的标签集合
|
||||
if (processBundleTags)
|
||||
ProcessBundleTags(manifest);
|
||||
|
||||
// 4. 处理内置资源包
|
||||
if (processBundleDepends)
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
@@ -64,17 +68,13 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
string packagePath;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(packagePath);
|
||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
@@ -92,6 +92,14 @@ namespace YooAsset.Editor
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
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>
|
||||
@@ -137,7 +145,7 @@ namespace YooAsset.Editor
|
||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
||||
packageAsset.TempDataInEditor = assetInfo;
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
@@ -165,9 +173,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源清单的ID数据
|
||||
/// 处理资源清单的资源对象列表
|
||||
/// </summary>
|
||||
private void ProcessPacakgeIDs(PackageManifest manifest)
|
||||
private void ProcessPacakgeAsset(PackageManifest manifest)
|
||||
{
|
||||
// 注意:优先缓存资源包索引
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
@@ -176,10 +184,19 @@ namespace YooAsset.Editor
|
||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||
}
|
||||
|
||||
// 记录资源对象所属的资源包ID
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
string bundleName = packageAsset.BundleNameInEditor;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
|
||||
}
|
||||
|
||||
// 记录资源对象依赖的资源包ID集合
|
||||
// 注意:依赖关系非引擎构建结果里查询!
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,15 +209,18 @@ namespace YooAsset.Editor
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(depends.Length);
|
||||
foreach (var dependBundleName in depends)
|
||||
string[] dependNames = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(dependNames.Length);
|
||||
foreach (var dependName in dependNames)
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
int dependBundleID = GetCachedBundleIndexID(dependName);
|
||||
if (dependBundleID != mainBundleID)
|
||||
dependIDs.Add(dependBundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
|
||||
// 排序并填充数据
|
||||
dependIDs.Sort();
|
||||
packageBundle.DependBundleIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,23 +229,27 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
packageBundle.Tags = Array.Empty<string>();
|
||||
}
|
||||
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
if (packageBundle.DependIDs != null)
|
||||
if (packageAsset.DependBundleIDs != null)
|
||||
{
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
foreach (var dependBundleID in packageAsset.DependBundleIDs)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将缓存的资源标签赋值给资源包
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
@@ -264,5 +288,94 @@ namespace YooAsset.Editor
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含该资源包的索引ID
|
||||
/// </summary>
|
||||
private bool ContainsCachedBundleIndexID(string bundleName)
|
||||
{
|
||||
return _cachedBundleIndexIDs.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
#region YOOASSET_LEGACY_DEPENDENCY
|
||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||
// 注意:该步骤依赖前面的操作!
|
||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResultContext != null)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
ManifestTools.InitManifest(manifest);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
|
||||
}
|
||||
}
|
||||
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(builtinBundleName))
|
||||
return;
|
||||
|
||||
// 查询内置资源包是否存在
|
||||
if (ContainsCachedBundleIndexID(builtinBundleName) == false)
|
||||
return;
|
||||
|
||||
// 获取内置资源包
|
||||
int builtinBundleID = GetCachedBundleIndexID(builtinBundleName);
|
||||
var builtinPackageBundle = manifest.BundleList[builtinBundleID];
|
||||
|
||||
// 更新依赖资源包ID集合
|
||||
HashSet<int> cacheBundleIDs = new HashSet<int>(builtinPackageBundle.ReferenceBundleIDs);
|
||||
HashSet<string> tempTags = new HashSet<string>();
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
if (cacheBundleIDs.Contains(packageAsset.BundleID))
|
||||
{
|
||||
if (packageAsset.DependBundleIDs.Contains(builtinBundleID) == false)
|
||||
{
|
||||
var tempBundleIDs = new List<int>(packageAsset.DependBundleIDs);
|
||||
tempBundleIDs.Add(builtinBundleID);
|
||||
packageAsset.DependBundleIDs = tempBundleIDs.ToArray();
|
||||
}
|
||||
|
||||
foreach (var tag in packageAsset.AssetTags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新内置资源包的标签集合
|
||||
foreach (var tag in builtinPackageBundle.Tags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
builtinPackageBundle.Tags = tempTags.ToArray();
|
||||
}
|
||||
private int[] GetAssetDependBundleIDs(BuildAssetInfo mainAssetInfo)
|
||||
{
|
||||
HashSet<int> result = new HashSet<int>();
|
||||
int mainBundleID = GetCachedBundleIndexID(mainAssetInfo.BundleName);
|
||||
foreach (var dependAssetInfo in mainAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
if (dependAssetInfo.HasBundleName())
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependAssetInfo.BundleName);
|
||||
if (mainBundleID != bundleID)
|
||||
{
|
||||
if (result.Contains(bundleID) == false)
|
||||
result.Add(bundleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 排序并返回数据
|
||||
List<int> listResult = new List<int>(result);
|
||||
listResult.Sort();
|
||||
return listResult.ToArray();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.YooVersion = EditorTools.GetPackageManagerYooVersion();
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
@@ -38,36 +34,34 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||
|
||||
// 构建参数
|
||||
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
||||
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
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;
|
||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||
if (buildParameters is BuiltinBuildParameters)
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||
else if (buildParameters is ScriptableBuildParameters)
|
||||
{
|
||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||
buildReport.Summary.DisableWriteTypeTree = false;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||
buildReport.Summary.BuiltinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
|
||||
buildReport.Summary.MonoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
|
||||
}
|
||||
|
||||
// 构建结果
|
||||
@@ -91,7 +85,8 @@ namespace YooAsset.Editor
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -107,8 +102,9 @@ namespace YooAsset.Editor
|
||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||
reportBundleInfo.Tags = packageBundle.Tags;
|
||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||
reportBundleInfo.DependBundles = GetBundleDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.ReferenceBundles = GetBundleReferenceBundles(manifest, packageBundle);
|
||||
reportBundleInfo.BundleContents = GetBundleContents(buildMapContext, packageBundle.BundleName);
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
@@ -123,12 +119,28 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <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);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
List<AssetInfo> result = new List<AssetInfo>();
|
||||
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;
|
||||
dependBundles.Add(dependBundleName);
|
||||
@@ -138,42 +150,42 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <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>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependBundleIDs.Length);
|
||||
foreach (int index in packageBundle.DependBundleIDs)
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
{
|
||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
}
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
dependBundles.Sort();
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||
List<AssetInfo> result = bundleInfo.GetBundleContents();
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
long tempSize = 0;
|
||||
|
||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||
var assetPaths = bundleInfo.GetAllPackAssetPaths();
|
||||
foreach (var assetPath in assetPaths)
|
||||
{
|
||||
long size = FileUtility.GetFileSize(assetPath);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
foreach (var buildAsset in bundleInfo.AllPackAssets)
|
||||
{
|
||||
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
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}");
|
||||
throw new Exception(message);
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace YooAsset.Editor
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
public string BuiltinShadersBundleName;
|
||||
public string MonoScriptsBundleName;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -53,6 +55,8 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
buildResultContext.BuiltinShadersBundleName = builtinShadersBundleName;
|
||||
buildResultContext.MonoScriptsBundleName = monoScriptsBundleName;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// 清空所有上下文对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// 设置上下文对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
@@ -46,5 +46,21 @@ namespace YooAsset.Editor
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T TryGetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,9 +98,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始收集工作
|
||||
/// 获取收集的资源列表
|
||||
/// </summary>
|
||||
public CollectResult BeginCollect(CollectCommand command)
|
||||
public List<CollectAssetInfo> GetCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
@@ -139,9 +139,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
var collectAssets = result.Values.ToList();
|
||||
var collectResult = new CollectResult(command, collectAssets);
|
||||
return collectResult;
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -116,7 +116,8 @@ namespace YooAsset.Editor
|
||||
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||
|
||||
// 开始收集工作
|
||||
CollectResult collectResult = package.BeginCollect(command);
|
||||
var collectAssets = package.GetCollectAssets(command);
|
||||
var collectResult = new CollectResult(command, collectAssets);
|
||||
return collectResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
@@ -38,7 +38,7 @@
|
||||
<ui:Label text="Groups" display-tooltip-when-elided="true" name="GroupTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace YooAsset.Editor
|
||||
packageData.ProviderInfos.Sort();
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
providerInfo.DependBundleInfos.Sort();
|
||||
providerInfo.DependBundles.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
private class ProviderTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class DependTableData : DefaultTableData
|
||||
@@ -205,7 +206,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
StyleColor textColor;
|
||||
var providerTableData = data as ProviderTableData;
|
||||
if(providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||
if (providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
@@ -309,6 +310,7 @@ namespace YooAsset.Editor
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
var rowData = new ProviderTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
||||
@@ -368,12 +370,14 @@ namespace YooAsset.Editor
|
||||
private void OnProviderTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
var providerTableData = data as ProviderTableData;
|
||||
DebugPackageData packageData = providerTableData.PackageData;
|
||||
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
||||
|
||||
// 填充依赖数据
|
||||
var sourceDatas = new List<ITableData>(providerInfo.DependBundleInfos.Count);
|
||||
foreach (var dependBundleInfo in providerInfo.DependBundleInfos)
|
||||
var sourceDatas = new List<ITableData>(providerInfo.DependBundles.Count);
|
||||
foreach (var bundleName in providerInfo.DependBundles)
|
||||
{
|
||||
var dependBundleInfo = packageData.GetBundleInfo(bundleName);
|
||||
var rowData = new DependTableData();
|
||||
rowData.BundleInfo = dependBundleInfo;
|
||||
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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="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: 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; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -13,19 +13,24 @@ namespace YooAsset.Editor
|
||||
{
|
||||
private class BundleTableData : DefaultTableData
|
||||
{
|
||||
public string PackageName;
|
||||
public DebugPackageData PackageData;
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
private class UsingTableData : DefaultTableData
|
||||
{
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class ReferenceTableData : DefaultTableData
|
||||
{
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private TableView _bundleTableView;
|
||||
private TableView _usingTableView;
|
||||
private TableView _referenceTableView;
|
||||
|
||||
private DebugReport _debugReport;
|
||||
private List<ITableData> _sourceDatas;
|
||||
@@ -44,20 +49,25 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleTableView = _root.Q<TableView>("TopTableView");
|
||||
_bundleTableView = _root.Q<TableView>("BundleTableView");
|
||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||
CreateBundleTableViewColumns();
|
||||
|
||||
// 使用列表
|
||||
_usingTableView = _root.Q<TableView>("BottomTableView");
|
||||
_usingTableView = _root.Q<TableView>("UsingTableView");
|
||||
CreateUsingTableViewColumns();
|
||||
|
||||
// 引用列表
|
||||
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
|
||||
CreateReferenceTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
PanelSplitView.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
||||
#endif
|
||||
}
|
||||
private void CreateBundleTableViewColumns()
|
||||
@@ -269,6 +279,79 @@ namespace YooAsset.Editor
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateReferenceTableViewColumns()
|
||||
{
|
||||
// BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = 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>
|
||||
/// 填充页面数据
|
||||
@@ -280,30 +363,22 @@ namespace YooAsset.Editor
|
||||
// 清空旧数据
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
var tempDic = new HashSet<string>();
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
foreach (var bundleInfo in packageData.BundleInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (tempDic.Contains(bundleInfo.BundleName) == false)
|
||||
{
|
||||
tempDic.Add(bundleInfo.BundleName);
|
||||
|
||||
var rowData = new BundleTableData();
|
||||
rowData.PackageName = packageData.PackageName;
|
||||
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);
|
||||
}
|
||||
}
|
||||
var rowData = new BundleTableData();
|
||||
rowData.PackageData = packageData;
|
||||
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;
|
||||
@@ -322,6 +397,8 @@ namespace YooAsset.Editor
|
||||
_bundleTableView.RebuildView();
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_usingTableView.RebuildView();
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -355,19 +432,17 @@ namespace YooAsset.Editor
|
||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
var bundleTableData = data as BundleTableData;
|
||||
var packageData = bundleTableData.PackageData;
|
||||
var selectBundleInfo = bundleTableData.BundleInfo;
|
||||
|
||||
// 填充依赖数据
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in _debugReport.PackageDatas)
|
||||
// 填充UsingTableView
|
||||
{
|
||||
if (packageData.PackageName != bundleTableData.PackageName)
|
||||
continue;
|
||||
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
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();
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
@@ -381,9 +456,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<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;">
|
||||
<YooAsset.Editor.TableView name="TopTableView" />
|
||||
<YooAsset.Editor.TableView name="BundleTableView" />
|
||||
</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;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||
<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="UsingTableView" />
|
||||
<YooAsset.Editor.TableView name="ReferenceTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -39,8 +39,14 @@ namespace YooAsset.Editor
|
||||
public long MainBundleSize;
|
||||
|
||||
/// <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>();
|
||||
}
|
||||
}
|
||||
@@ -44,14 +44,21 @@ namespace YooAsset.Editor
|
||||
public string[] Tags;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包的依赖集合
|
||||
/// 依赖的资源包集合
|
||||
/// 说明:引擎层构建查询结果
|
||||
/// </summary>
|
||||
public List<string> DependBundles;
|
||||
public List<string> DependBundles = new List<string>();
|
||||
|
||||
/// <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>
|
||||
/// 获取资源分类标签的字符串
|
||||
|
||||
@@ -70,11 +70,19 @@ namespace YooAsset.Editor
|
||||
public bool ClearBuildCacheFiles;
|
||||
public bool UseAssetDependencyDB;
|
||||
public bool EnableSharePackRule;
|
||||
public bool SingleReferencedPackAlone;
|
||||
public string EncryptionClassName;
|
||||
public EFileNameStyle FileNameStyle;
|
||||
|
||||
// 引擎参数
|
||||
public ECompressOption CompressOption;
|
||||
public bool DisableWriteTypeTree;
|
||||
public bool IgnoreTypeTreeChanges;
|
||||
public bool WriteLinkXML = true;
|
||||
public string CacheServerHost;
|
||||
public int CacheServerPort;
|
||||
public string BuiltinShadersBundleName;
|
||||
public string MonoScriptsBundleName;
|
||||
|
||||
// 构建结果
|
||||
public int AssetFileTotalCount;
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace YooAsset.Editor
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
@@ -116,6 +117,7 @@ namespace YooAsset.Editor
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<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;">
|
||||
<YooAsset.Editor.TableView name="TopTableView" />
|
||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||
</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;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||
<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; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace YooAsset.Editor
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
@@ -181,6 +182,7 @@ namespace YooAsset.Editor
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("IncludeAssets", "Include Assets", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
@@ -320,15 +322,15 @@ namespace YooAsset.Editor
|
||||
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();
|
||||
rowData.AssetInfo = null;
|
||||
rowData.AddAssetPathCell("IncludeAssets", assetPath);
|
||||
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
|
||||
rowData.AddStringValueCell("AssetGUID", "--");
|
||||
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<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;">
|
||||
<YooAsset.Editor.TableView name="TopTableView" />
|
||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||
</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;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||
<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; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -11,24 +11,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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 TemplateContainer _root;
|
||||
|
||||
private ListView _listView;
|
||||
private readonly List<ItemWrapper> _items = new List<ItemWrapper>();
|
||||
|
||||
private ScrollView _scrollView;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@@ -44,9 +29,7 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 概述列表
|
||||
_listView = _root.Q<ListView>("ListView");
|
||||
_listView.makeItem = MakeListViewItem;
|
||||
_listView.bindItem = BindListViewItem;
|
||||
_scrollView = _root.Q<ScrollView>("ScrollView");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -54,52 +37,49 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport)
|
||||
{
|
||||
_items.Clear();
|
||||
_scrollView.Clear();
|
||||
|
||||
_items.Add(new ItemWrapper("YooAsset Version", buildReport.Summary.YooVersion));
|
||||
_items.Add(new ItemWrapper("UnityEngine Version", buildReport.Summary.UnityVersion));
|
||||
_items.Add(new ItemWrapper("Build Date", buildReport.Summary.BuildDate));
|
||||
_items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)));
|
||||
_items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString()));
|
||||
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||
_items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote));
|
||||
BindListViewHeader("Build Infos");
|
||||
BindListViewItem("YooAsset Version", buildReport.Summary.YooVersion);
|
||||
BindListViewItem("UnityEngine Version", buildReport.Summary.UnityVersion);
|
||||
BindListViewItem("Build Date", buildReport.Summary.BuildDate);
|
||||
BindListViewItem("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds));
|
||||
BindListViewItem("Build Target", $"{buildReport.Summary.BuildTarget}");
|
||||
BindListViewItem("Build Pipeline", $"{buildReport.Summary.BuildPipeline}");
|
||||
BindListViewItem("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString());
|
||||
BindListViewItem("Package Name", buildReport.Summary.BuildPackageName);
|
||||
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));
|
||||
_items.Add(new ItemWrapper("Collect Settings", string.Empty));
|
||||
_items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"));
|
||||
_items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
|
||||
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
||||
_items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"));
|
||||
BindListViewHeader("Collect Settings");
|
||||
BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
|
||||
BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
|
||||
BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
|
||||
BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
|
||||
BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
|
||||
BindListViewItem("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}");
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||
_items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}"));
|
||||
_items.Add(new ItemWrapper("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}"));
|
||||
_items.Add(new ItemWrapper("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"));
|
||||
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
|
||||
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
|
||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
|
||||
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
|
||||
BindListViewHeader("Build Params");
|
||||
BindListViewItem("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}");
|
||||
BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
|
||||
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
|
||||
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
|
||||
BindListViewItem("Encryption Class Name", buildReport.Summary.EncryptionClassName);
|
||||
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
|
||||
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
||||
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
||||
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Build Results", string.Empty));
|
||||
_items.Add(new ItemWrapper("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}"));
|
||||
_items.Add(new ItemWrapper("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}"));
|
||||
_items.Add(new ItemWrapper("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
|
||||
_items.Add(new ItemWrapper("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
|
||||
|
||||
_listView.Clear();
|
||||
_listView.ClearSelection();
|
||||
_listView.itemsSource = _items;
|
||||
_listView.Rebuild();
|
||||
BindListViewHeader("Build Results");
|
||||
BindListViewItem("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}");
|
||||
BindListViewItem("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}");
|
||||
BindListViewItem("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}");
|
||||
BindListViewItem("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize));
|
||||
BindListViewItem("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}");
|
||||
BindListViewItem("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,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()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 200;
|
||||
element.Add(label);
|
||||
}
|
||||
var titleLabel = new Label();
|
||||
titleLabel.name = "TitleLabel";
|
||||
titleLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
titleLabel.style.marginLeft = 3f;
|
||||
titleLabel.style.width = 200;
|
||||
element.Add(titleLabel);
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
var valueLabel = new Label();
|
||||
valueLabel.name = "ValueLabel";
|
||||
valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
valueLabel.style.marginLeft = 3f;
|
||||
valueLabel.style.flexGrow = 1f;
|
||||
valueLabel.style.width = 150;
|
||||
element.Add(valueLabel);
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
<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;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<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:ScrollView name="ScrollView" horizontal-scroller-visibility="Hidden" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetInfo
|
||||
public class AssetInfo : IComparable<AssetInfo>
|
||||
{
|
||||
private string _fileExtension = null;
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AssetInfo(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
@@ -60,5 +61,10 @@ namespace YooAsset.Editor
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public int CompareTo(AssetInfo other)
|
||||
{
|
||||
return this.AssetPath.CompareTo(other.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +129,21 @@ namespace YooAsset.Editor
|
||||
}
|
||||
#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
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
@@ -559,7 +574,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移除路径里的后缀名
|
||||
/// </summary>
|
||||
|
||||
@@ -12,15 +12,9 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public class PanelSplitView : TwoPaneSplitView
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
public new class UxmlFactory : UxmlElementAttribute
|
||||
{
|
||||
}
|
||||
#else
|
||||
public new class UxmlFactory : UxmlFactory<PanelSplitView, UxmlTraits>
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 竖版分屏
|
||||
|
||||
@@ -0,0 +1,627 @@
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ReorderableListView : VisualElement
|
||||
{
|
||||
public new class UxmlFactory : UxmlFactory<ReorderableListView, UxmlTraits>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 制作元素委托
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public delegate VisualElement MakeElementDelegate();
|
||||
|
||||
/// <summary>
|
||||
/// 绑定元素委托
|
||||
/// </summary>
|
||||
public delegate void BindElementDelegqate(VisualElement element, int index);
|
||||
|
||||
private Foldout _foldout;
|
||||
private ListView _listView;
|
||||
private Label _headerLabel;
|
||||
private Button _addButton;
|
||||
private Button _removeButton;
|
||||
private string _headerName = nameof(ReorderableListView);
|
||||
|
||||
/// <summary>
|
||||
/// 源数据
|
||||
/// </summary>
|
||||
public IList SourceData
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value is ArrayList)
|
||||
throw new Exception($"{nameof(SourceData)} not support {nameof(ArrayList)}");
|
||||
|
||||
_listView.Clear();
|
||||
_listView.ClearSelection();
|
||||
_listView.itemsSource = value;
|
||||
_listView.Rebuild();
|
||||
RefreshFoldoutName();
|
||||
RefreshRemoveButton();
|
||||
}
|
||||
get
|
||||
{
|
||||
return _listView.itemsSource;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 元素固定高度
|
||||
/// </summary>
|
||||
public float ElementHeight
|
||||
{
|
||||
set
|
||||
{
|
||||
_listView.fixedItemHeight = value;
|
||||
_listView.Rebuild();
|
||||
}
|
||||
get
|
||||
{
|
||||
return _listView.fixedItemHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加按钮显隐
|
||||
/// </summary>
|
||||
public bool DisplayAdd
|
||||
{
|
||||
set
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_addButton, value);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _addButton.style.visibility == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除按钮显隐
|
||||
/// </summary>
|
||||
public bool DisplayRemove
|
||||
{
|
||||
set
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_removeButton, value);
|
||||
}
|
||||
get
|
||||
{
|
||||
return _removeButton.style.visibility == Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题名称
|
||||
/// </summary>
|
||||
public string HeaderName
|
||||
{
|
||||
set
|
||||
{
|
||||
_headerName = value;
|
||||
RefreshFoldoutName();
|
||||
}
|
||||
get
|
||||
{
|
||||
return _headerName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 制作元素的回调
|
||||
/// </summary>
|
||||
public MakeElementDelegate MakeElementCallback;
|
||||
|
||||
/// <summary>
|
||||
/// 绑定元素的回调
|
||||
/// </summary>
|
||||
public BindElementDelegqate BindElementCallback;
|
||||
|
||||
|
||||
public ReorderableListView()
|
||||
{
|
||||
CreateView(true);
|
||||
}
|
||||
public ReorderableListView(bool foldout)
|
||||
{
|
||||
CreateView(foldout);
|
||||
}
|
||||
private void CreateView(bool foldout)
|
||||
{
|
||||
this.style.flexGrow = 1;
|
||||
this.style.flexShrink = 1;
|
||||
|
||||
// 折叠栏
|
||||
if (foldout)
|
||||
{
|
||||
_foldout = new Foldout();
|
||||
_foldout.style.flexGrow = 1f;
|
||||
_foldout.style.flexShrink = 1f;
|
||||
_foldout.text = $"{nameof(ReorderableListView)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_headerLabel = new Label();
|
||||
}
|
||||
|
||||
// 列表视图
|
||||
_listView = new ListView();
|
||||
_listView.style.flexGrow = 1;
|
||||
_listView.style.flexShrink = 1;
|
||||
_listView.reorderable = true;
|
||||
_listView.reorderMode = ListViewReorderMode.Animated;
|
||||
_listView.makeItem = MakeListViewElement;
|
||||
_listView.bindItem = BindListViewElement;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_listView.selectionChanged += OnSelectionChanged;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_listView.onSelectionChange += OnSelectionChanged;
|
||||
#else
|
||||
_listView.onSelectionChanged += OnSelectionChanged;
|
||||
#endif
|
||||
|
||||
// 按钮组
|
||||
var buttonContainer = new VisualElement();
|
||||
buttonContainer.style.flexDirection = FlexDirection.RowReverse;
|
||||
|
||||
// 移除按钮
|
||||
_removeButton = new Button();
|
||||
_removeButton.text = " - ";
|
||||
_removeButton.clicked += OnClickRemoveButton;
|
||||
_removeButton.SetEnabled(false);
|
||||
buttonContainer.Add(_removeButton);
|
||||
|
||||
// 增加按钮
|
||||
_addButton = new Button();
|
||||
_addButton.text = " + ";
|
||||
_addButton.clicked += OnClickAddButton;
|
||||
buttonContainer.Add(_addButton);
|
||||
|
||||
// 组织页面
|
||||
if (foldout)
|
||||
{
|
||||
_foldout.Add(_listView);
|
||||
_foldout.Add(buttonContainer);
|
||||
this.Add(_foldout);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Add(_headerLabel);
|
||||
this.Add(_listView);
|
||||
this.Add(buttonContainer);
|
||||
}
|
||||
}
|
||||
private void OnClickAddButton()
|
||||
{
|
||||
if (_listView.itemsSource != null)
|
||||
{
|
||||
object defaultValue = GetElementDefaultValue();
|
||||
_listView.itemsSource.Add(defaultValue);
|
||||
_listView.Rebuild();
|
||||
RefreshFoldoutName();
|
||||
RefreshRemoveButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("The source data is null !");
|
||||
}
|
||||
}
|
||||
private void OnClickRemoveButton()
|
||||
{
|
||||
if (_listView.itemsSource != null)
|
||||
{
|
||||
if (_listView.selectedIndex >= 0)
|
||||
{
|
||||
_listView.itemsSource.RemoveAt(_listView.selectedIndex);
|
||||
_listView.Rebuild();
|
||||
RefreshFoldoutName();
|
||||
RefreshRemoveButton();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("The source data is null !");
|
||||
}
|
||||
}
|
||||
private void OnSelectionChanged(IEnumerable<object> objs)
|
||||
{
|
||||
RefreshRemoveButton();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成元素
|
||||
/// </summary>
|
||||
private VisualElement MakeListViewElement()
|
||||
{
|
||||
if (MakeElementCallback != null)
|
||||
{
|
||||
return MakeElementCallback.Invoke();
|
||||
}
|
||||
|
||||
Type elementType = GetElementType();
|
||||
if (elementType == typeof(string))
|
||||
{
|
||||
TextField textField = new TextField();
|
||||
textField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)textField.userData;
|
||||
_listView.itemsSource[itemIndex] = textField.value;
|
||||
});
|
||||
return textField;
|
||||
}
|
||||
else if (elementType == typeof(int))
|
||||
{
|
||||
IntegerField intField = new IntegerField();
|
||||
intField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)intField.userData;
|
||||
_listView.itemsSource[itemIndex] = intField.value;
|
||||
});
|
||||
return intField;
|
||||
}
|
||||
else if (elementType == typeof(long))
|
||||
{
|
||||
LongField longField = new LongField();
|
||||
longField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)longField.userData;
|
||||
_listView.itemsSource[itemIndex] = longField.value;
|
||||
});
|
||||
return longField;
|
||||
}
|
||||
else if (elementType == typeof(float))
|
||||
{
|
||||
FloatField floatField = new FloatField();
|
||||
floatField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)floatField.userData;
|
||||
_listView.itemsSource[itemIndex] = floatField.value;
|
||||
});
|
||||
return floatField;
|
||||
}
|
||||
else if (elementType == typeof(double))
|
||||
{
|
||||
DoubleField doubleField = new DoubleField();
|
||||
doubleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)doubleField.userData;
|
||||
_listView.itemsSource[itemIndex] = doubleField.value;
|
||||
});
|
||||
return doubleField;
|
||||
}
|
||||
else if (elementType == typeof(bool))
|
||||
{
|
||||
Toggle toggle = new Toggle();
|
||||
toggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)toggle.userData;
|
||||
_listView.itemsSource[itemIndex] = toggle.value;
|
||||
});
|
||||
return toggle;
|
||||
}
|
||||
else if (elementType == typeof(Hash128))
|
||||
{
|
||||
Hash128Field hash128Field = new Hash128Field();
|
||||
hash128Field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)hash128Field.userData;
|
||||
_listView.itemsSource[itemIndex] = hash128Field.value;
|
||||
});
|
||||
return hash128Field;
|
||||
}
|
||||
else if (elementType == typeof(Vector2))
|
||||
{
|
||||
Vector2Field vector2Field = new Vector2Field();
|
||||
vector2Field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)vector2Field.userData;
|
||||
_listView.itemsSource[itemIndex] = vector2Field.value;
|
||||
});
|
||||
return vector2Field;
|
||||
}
|
||||
else if (elementType == typeof(Vector3))
|
||||
{
|
||||
Vector3Field vector3Field = new Vector3Field();
|
||||
vector3Field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)vector3Field.userData;
|
||||
_listView.itemsSource[itemIndex] = vector3Field.value;
|
||||
});
|
||||
return vector3Field;
|
||||
}
|
||||
else if (elementType == typeof(Vector4))
|
||||
{
|
||||
Vector4Field vector4Field = new Vector4Field();
|
||||
vector4Field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)vector4Field.userData;
|
||||
_listView.itemsSource[itemIndex] = vector4Field.value;
|
||||
});
|
||||
return vector4Field;
|
||||
}
|
||||
else if (elementType == typeof(Rect))
|
||||
{
|
||||
RectField rectField = new RectField();
|
||||
rectField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)rectField.userData;
|
||||
_listView.itemsSource[itemIndex] = rectField.value;
|
||||
});
|
||||
return rectField;
|
||||
}
|
||||
else if (elementType == typeof(Bounds))
|
||||
{
|
||||
BoundsField boundsField = new BoundsField();
|
||||
boundsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)boundsField.userData;
|
||||
_listView.itemsSource[itemIndex] = boundsField.value;
|
||||
});
|
||||
return boundsField;
|
||||
}
|
||||
else if (elementType == typeof(Color))
|
||||
{
|
||||
ColorField colorField = new ColorField();
|
||||
colorField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)colorField.userData;
|
||||
_listView.itemsSource[itemIndex] = colorField.value;
|
||||
});
|
||||
return colorField;
|
||||
}
|
||||
else if (elementType == typeof(Gradient))
|
||||
{
|
||||
GradientField gradientField = new GradientField();
|
||||
gradientField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)gradientField.userData;
|
||||
_listView.itemsSource[itemIndex] = gradientField.value;
|
||||
});
|
||||
return gradientField;
|
||||
}
|
||||
else if (elementType == typeof(AnimationCurve))
|
||||
{
|
||||
CurveField curveField = new CurveField();
|
||||
curveField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)curveField.userData;
|
||||
_listView.itemsSource[itemIndex] = curveField.value;
|
||||
});
|
||||
return curveField;
|
||||
}
|
||||
else if (elementType == typeof(UnityEngine.Object))
|
||||
{
|
||||
ObjectField objectField = new ObjectField();
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)objectField.userData;
|
||||
_listView.itemsSource[itemIndex] = objectField.value;
|
||||
});
|
||||
return objectField;
|
||||
}
|
||||
else if (elementType.IsEnum)
|
||||
{
|
||||
EnumField enumField = new EnumField();
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
int itemIndex = (int)enumField.userData;
|
||||
_listView.itemsSource[itemIndex] = enumField.value;
|
||||
});
|
||||
return enumField;
|
||||
}
|
||||
else
|
||||
{
|
||||
Label label = new Label();
|
||||
label.text = $"Not support element type : {elementType.Name}";
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定元素
|
||||
/// </summary>
|
||||
private void BindListViewElement(VisualElement listViewElement, int index)
|
||||
{
|
||||
if (BindElementCallback != null)
|
||||
{
|
||||
BindElementCallback.Invoke(listViewElement, index);
|
||||
return;
|
||||
}
|
||||
|
||||
var elementValue = _listView.itemsSource[index];
|
||||
string elementName = GetElementName(index);
|
||||
Type elementType = GetElementType();
|
||||
if (elementType == typeof(string))
|
||||
{
|
||||
TextField textField = listViewElement as TextField;
|
||||
textField.userData = index;
|
||||
textField.label = elementName;
|
||||
textField.SetValueWithoutNotify(elementValue as string);
|
||||
}
|
||||
else if (elementType == typeof(int))
|
||||
{
|
||||
IntegerField intField = listViewElement as IntegerField;
|
||||
intField.userData = index;
|
||||
intField.label = elementName;
|
||||
intField.SetValueWithoutNotify((int)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(long))
|
||||
{
|
||||
LongField longField = listViewElement as LongField;
|
||||
longField.userData = index;
|
||||
longField.label = elementName;
|
||||
longField.SetValueWithoutNotify((long)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(float))
|
||||
{
|
||||
FloatField floatField = listViewElement as FloatField;
|
||||
floatField.userData = index;
|
||||
floatField.label = elementName;
|
||||
floatField.SetValueWithoutNotify((float)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(double))
|
||||
{
|
||||
DoubleField doubleField = listViewElement as DoubleField;
|
||||
doubleField.userData = index;
|
||||
doubleField.label = elementName;
|
||||
doubleField.SetValueWithoutNotify((double)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(bool))
|
||||
{
|
||||
Toggle toggle = listViewElement as Toggle;
|
||||
toggle.userData = index;
|
||||
toggle.label = elementName;
|
||||
toggle.SetValueWithoutNotify((bool)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Hash128))
|
||||
{
|
||||
Hash128Field hash128Field = listViewElement as Hash128Field;
|
||||
hash128Field.userData = index;
|
||||
hash128Field.label = elementName;
|
||||
hash128Field.SetValueWithoutNotify((Hash128)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Vector2))
|
||||
{
|
||||
Vector2Field vector2Field = listViewElement as Vector2Field;
|
||||
vector2Field.userData = index;
|
||||
vector2Field.label = elementName;
|
||||
vector2Field.SetValueWithoutNotify((Vector2)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Vector3))
|
||||
{
|
||||
Vector3Field vector3Field = listViewElement as Vector3Field;
|
||||
vector3Field.userData = index;
|
||||
vector3Field.label = elementName;
|
||||
vector3Field.SetValueWithoutNotify((Vector3)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Vector4))
|
||||
{
|
||||
Vector4Field vector4Field = listViewElement as Vector4Field;
|
||||
vector4Field.userData = index;
|
||||
vector4Field.label = elementName;
|
||||
vector4Field.SetValueWithoutNotify((Vector4)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Rect))
|
||||
{
|
||||
RectField rectField = listViewElement as RectField;
|
||||
rectField.userData = index;
|
||||
rectField.label = elementName;
|
||||
rectField.SetValueWithoutNotify((Rect)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Bounds))
|
||||
{
|
||||
BoundsField boundsField = listViewElement as BoundsField;
|
||||
boundsField.userData = index;
|
||||
boundsField.label = elementName;
|
||||
boundsField.SetValueWithoutNotify((Bounds)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Color))
|
||||
{
|
||||
ColorField colorField = listViewElement as ColorField;
|
||||
colorField.userData = index;
|
||||
colorField.label = elementName;
|
||||
colorField.SetValueWithoutNotify((Color)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(Gradient))
|
||||
{
|
||||
GradientField gradientField = listViewElement as GradientField;
|
||||
gradientField.userData = index;
|
||||
gradientField.label = elementName;
|
||||
gradientField.SetValueWithoutNotify((Gradient)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(AnimationCurve))
|
||||
{
|
||||
CurveField curveField = listViewElement as CurveField;
|
||||
curveField.userData = index;
|
||||
curveField.label = elementName;
|
||||
curveField.SetValueWithoutNotify((AnimationCurve)elementValue);
|
||||
}
|
||||
else if (elementType == typeof(UnityEngine.Object))
|
||||
{
|
||||
ObjectField objectField = listViewElement as ObjectField;
|
||||
objectField.userData = index;
|
||||
objectField.label = elementName;
|
||||
objectField.SetValueWithoutNotify(elementValue as UnityEngine.Object);
|
||||
}
|
||||
else if (elementType.IsEnum)
|
||||
{
|
||||
EnumField enumField = listViewElement as EnumField;
|
||||
enumField.userData = index;
|
||||
enumField.label = elementName;
|
||||
enumField.Init((Enum)elementValue);
|
||||
enumField.SetValueWithoutNotify((Enum)elementValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private Type GetElementType()
|
||||
{
|
||||
Type elementType = _listView.itemsSource.GetType().GetGenericArguments()[0];
|
||||
return elementType;
|
||||
}
|
||||
private object GetElementDefaultValue()
|
||||
{
|
||||
Type type = GetElementType();
|
||||
if (type.IsValueType)
|
||||
{
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private string GetElementName(int index)
|
||||
{
|
||||
return $"Element {index}";
|
||||
}
|
||||
|
||||
private void RefreshRemoveButton()
|
||||
{
|
||||
if (_listView.itemsSource == null)
|
||||
{
|
||||
_removeButton.SetEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 注意:数据列表移除元素的时候有可能会越界!
|
||||
if (_listView.selectedIndex >= _listView.itemsSource.Count)
|
||||
_listView.ClearSelection();
|
||||
|
||||
if (_listView.selectedIndex >= 0)
|
||||
_removeButton.SetEnabled(true);
|
||||
else
|
||||
_removeButton.SetEnabled(false);
|
||||
}
|
||||
private void RefreshFoldoutName()
|
||||
{
|
||||
if (_listView.itemsSource == null)
|
||||
{
|
||||
if (_foldout != null)
|
||||
_foldout.text = _headerName;
|
||||
if (_headerLabel != null)
|
||||
_headerLabel.text = _headerName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_foldout != null)
|
||||
_foldout.text = _headerName + $" ({_listView.itemsSource.Count}) ";
|
||||
if (_headerLabel != null)
|
||||
_headerLabel.text = _headerName + $" ({_listView.itemsSource.Count}) ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c10fd3507a1c24a9043aebb72db5f5
|
||||
guid: 111ec0d18888d7e4396b2192f7b4f347
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -9,15 +9,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class ResizeHandle : VisualElement
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
public new class UxmlFactory : UxmlElementAttribute
|
||||
{
|
||||
}
|
||||
#else
|
||||
public new class UxmlFactory : UxmlFactory<ResizeHandle, UxmlTraits>
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool _isResizing = false;
|
||||
private float _initialWidth;
|
||||
|
||||
@@ -41,6 +41,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool Sortable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 统计数量
|
||||
/// </summary>
|
||||
public bool Counter = false;
|
||||
|
||||
public ColumnStyle(Length width)
|
||||
{
|
||||
if (width.value > MaxValue)
|
||||
|
||||
@@ -15,15 +15,9 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public class TableView : VisualElement
|
||||
{
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
public new class UxmlFactory : UxmlElementAttribute
|
||||
{
|
||||
}
|
||||
#else
|
||||
public new class UxmlFactory : UxmlFactory<TableView, UxmlTraits>
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
private readonly Toolbar _toolbar;
|
||||
private readonly ListView _listView;
|
||||
@@ -33,7 +27,7 @@ namespace YooAsset.Editor
|
||||
private List<ITableData> _sortingDatas;
|
||||
|
||||
// 排序相关
|
||||
private string _sortingHeaderElement = string.Empty;
|
||||
private string _sortingHeader;
|
||||
private bool _descendingSort = true;
|
||||
|
||||
/// <summary>
|
||||
@@ -90,10 +84,16 @@ namespace YooAsset.Editor
|
||||
|
||||
public TableView()
|
||||
{
|
||||
_toolbar = new Toolbar();
|
||||
this.Add(_toolbar);
|
||||
this.style.flexShrink = 1f;
|
||||
this.style.flexGrow = 1f;
|
||||
|
||||
// 定义标题栏
|
||||
_toolbar = new Toolbar();
|
||||
|
||||
// 定义列表视图
|
||||
_listView = new ListView();
|
||||
_listView.style.flexShrink = 1f;
|
||||
_listView.style.flexGrow = 1f;
|
||||
_listView.makeItem = MakeListViewElement;
|
||||
_listView.bindItem = BindListViewElement;
|
||||
_listView.selectionType = SelectionType.Multiple;
|
||||
@@ -107,6 +107,7 @@ namespace YooAsset.Editor
|
||||
_listView.onSelectionChanged += OnSelectionChanged;
|
||||
#endif
|
||||
|
||||
this.Add(_toolbar);
|
||||
this.Add(_listView);
|
||||
}
|
||||
|
||||
@@ -190,6 +191,38 @@ namespace YooAsset.Editor
|
||||
_listView.ClearSelection();
|
||||
_listView.itemsSource = itemsSource.ToList();
|
||||
_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>
|
||||
@@ -236,9 +269,9 @@ namespace YooAsset.Editor
|
||||
if (clickedColumn.ColumnStyle.Sortable == false)
|
||||
return;
|
||||
|
||||
if (_sortingHeaderElement != clickedColumn.ElementName)
|
||||
if (_sortingHeader != clickedColumn.ElementName)
|
||||
{
|
||||
_sortingHeaderElement = clickedColumn.ElementName;
|
||||
_sortingHeader = clickedColumn.ElementName;
|
||||
_descendingSort = false;
|
||||
}
|
||||
else
|
||||
@@ -246,17 +279,6 @@ namespace YooAsset.Editor
|
||||
_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)
|
||||
_sortingDatas = _itemsSource.OrderByDescending(tableData => tableData.Cells[clickedColumn.ColumnIndex]).ToList();
|
||||
|
||||
@@ -22,6 +22,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public EOperationStatus Status;
|
||||
|
||||
/// <summary>
|
||||
/// 谁引用了该资源包
|
||||
/// </summary>
|
||||
public List<string> ReferenceBundles;
|
||||
|
||||
public int CompareTo(DebugBundleInfo other)
|
||||
{
|
||||
return Compare(this, other);
|
||||
|
||||
@@ -17,5 +17,44 @@ namespace YooAsset
|
||||
/// 调试数据列表
|
||||
/// </summary>
|
||||
public List<DebugProviderInfo> ProviderInfos = new List<DebugProviderInfo>(1000);
|
||||
|
||||
/// <summary>
|
||||
/// 调试数据列表
|
||||
/// </summary>
|
||||
public List<DebugBundleInfo> BundleInfos = new List<DebugBundleInfo>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 依赖的资源包列表
|
||||
/// </summary>
|
||||
public List<DebugBundleInfo> DependBundleInfos;
|
||||
public List<string> DependBundles;
|
||||
|
||||
public int CompareTo(DebugProviderInfo other)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public List<DebugPackageData> PackageDatas = new List<DebugPackageData>(10);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 序列化
|
||||
/// </summary>
|
||||
|
||||
@@ -16,11 +16,11 @@ namespace YooAsset
|
||||
internal UnityWebDataRequestOperation(string url, int timeout = 60) : base(url, timeout)
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ namespace YooAsset
|
||||
DisposeRequest();
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeRequest();
|
||||
|
||||
@@ -12,11 +12,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSavePath = fileSavePath;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -54,7 +54,7 @@ namespace YooAsset
|
||||
DisposeRequest();
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeRequest();
|
||||
|
||||
@@ -16,11 +16,11 @@ namespace YooAsset
|
||||
internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout)
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ namespace YooAsset
|
||||
DisposeRequest();
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeRequest();
|
||||
|
||||
@@ -48,25 +48,21 @@ namespace YooAsset
|
||||
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new AssetBundleLoadAssetOperation(_packageBundle, _assetBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new AssetBundleLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new AssetBundleLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
|
||||
{
|
||||
var operation = new AssetBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace YooAsset
|
||||
_assetBundle = assetBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace YooAsset
|
||||
_assetBundle = assetBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace YooAsset
|
||||
_loadParams = loadParams;
|
||||
_suspendLoad = suspendLoad;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadScene;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -107,7 +107,7 @@ namespace YooAsset
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
|
||||
InternalOnUpdate();
|
||||
InternalUpdate();
|
||||
}
|
||||
public override void UnSuspendLoad()
|
||||
{
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace YooAsset
|
||||
_assetBundle = assetBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -3,12 +3,12 @@ namespace YooAsset
|
||||
{
|
||||
internal class RawBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ namespace YooAsset
|
||||
{
|
||||
internal class RawBundleLoadAssetOperation : FSLoadAssetOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ namespace YooAsset
|
||||
{
|
||||
internal class RawBundleLoadSceneOperation : FSLoadSceneOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
public override void UnSuspendLoad()
|
||||
|
||||
@@ -3,12 +3,12 @@ namespace YooAsset
|
||||
{
|
||||
internal class RawBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,25 +32,21 @@ namespace YooAsset
|
||||
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new RawBundleLoadAssetOperation();
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new RawBundleLoadAllAssetsOperation();
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new RawBundleLoadSubAssetsOperation();
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
|
||||
{
|
||||
var operation = new RawBundleLoadSceneOperation();
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset
|
||||
_packageBundle = packageBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_steps = ESteps.CheckBundle;
|
||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Failed;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace YooAsset
|
||||
_packageBundle = packageBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_steps = ESteps.CheckBundle;
|
||||
@@ -31,7 +31,7 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Failed;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
||||
_loadParams = loadParams;
|
||||
_suspendLoad = suspendLoad;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_steps = ESteps.LoadScene;
|
||||
@@ -35,7 +35,7 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Failed;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
@@ -113,7 +113,7 @@ namespace YooAsset
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
//TODO 场景加载不支持异步转同步,为了支持同步加载方法需要实现该方法!
|
||||
InternalOnUpdate();
|
||||
InternalUpdate();
|
||||
}
|
||||
public override void UnSuspendLoad()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset
|
||||
_packageBundle = packageBundle;
|
||||
_assetInfo = assetInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_steps = ESteps.CheckBundle;
|
||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
||||
Status = EOperationStatus.Failed;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
|
||||
@@ -32,25 +32,21 @@ namespace YooAsset
|
||||
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new VirtualBundleLoadAssetOperation(_packageBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new VirtualBundleLoadAllAssetsOperation(_packageBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
var operation = new VirtualBundleLoadSubAssetsOperation(_packageBundle, assetInfo);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
|
||||
{
|
||||
var operation = new VirtualBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _buildinFilePathMapping = new Dictionary<string, string>(10000);
|
||||
protected IFileSystem _unpackFileSystem;
|
||||
protected string _packageRoot;
|
||||
|
||||
@@ -92,19 +92,16 @@ namespace YooAsset
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
{
|
||||
var operation = new DBFSInitializeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DBFSLoadPackageManifestOperation(this, packageVersion);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new DBFSRequestPackageVersionOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||
@@ -113,12 +110,13 @@ namespace YooAsset
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||
{
|
||||
// 注意:业务层的解压下载器会依赖内置文件系统的下载方法
|
||||
param.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
||||
return _unpackFileSystem.DownloadFileAsync(bundle, param);
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
{
|
||||
if (NeedUnpack(bundle))
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
{
|
||||
return _unpackFileSystem.LoadBundleFile(bundle);
|
||||
}
|
||||
@@ -126,20 +124,17 @@ namespace YooAsset
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
{
|
||||
var operation = new DBFSLoadRawBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"{nameof(DefaultBuildinFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||
var operation = new FSLoadBundleCompleteOperation(error);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
@@ -193,9 +188,8 @@ namespace YooAsset
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||
_unpackFileSystem.OnCreate(packageName, null);
|
||||
}
|
||||
public virtual void OnUpdate()
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
_unpackFileSystem.OnUpdate();
|
||||
}
|
||||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
@@ -216,11 +210,7 @@ namespace YooAsset
|
||||
}
|
||||
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||
{
|
||||
if (Belong(bundle) == false)
|
||||
return false;
|
||||
|
||||
#if UNITY_ANDROID
|
||||
if (bundle.BundleType == (int)EBuildBundleType.RawBundle || bundle.Encrypted)
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
{
|
||||
return _unpackFileSystem.Exists(bundle) == false;
|
||||
}
|
||||
@@ -228,9 +218,6 @@ namespace YooAsset
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
public virtual bool NeedImport(PackageBundle bundle)
|
||||
{
|
||||
@@ -239,14 +226,14 @@ namespace YooAsset
|
||||
|
||||
public virtual string GetBundleFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (NeedUnpack(bundle))
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
return _unpackFileSystem.GetBundleFilePath(bundle);
|
||||
|
||||
return GetBuildinFileLoadPath(bundle);
|
||||
}
|
||||
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
|
||||
{
|
||||
if (NeedUnpack(bundle))
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
return _unpackFileSystem.ReadBundleFileData(bundle);
|
||||
|
||||
if (Exists(bundle) == false)
|
||||
@@ -277,7 +264,7 @@ namespace YooAsset
|
||||
}
|
||||
public virtual string ReadBundleFileText(PackageBundle bundle)
|
||||
{
|
||||
if (NeedUnpack(bundle))
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
return _unpackFileSystem.ReadBundleFileText(bundle);
|
||||
|
||||
if (Exists(bundle) == false)
|
||||
@@ -315,10 +302,10 @@ namespace YooAsset
|
||||
}
|
||||
public string GetBuildinFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_buildinFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_buildinFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_packageRoot, bundle.FileName);
|
||||
_buildinFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_buildinFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
@@ -343,6 +330,27 @@ namespace YooAsset
|
||||
return YooAssetSettingsData.GetYooResourcesLoadPath(PackageName, fileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否属于解压资源包文件
|
||||
/// </summary>
|
||||
protected bool IsUnpackBundleFile(PackageBundle bundle)
|
||||
{
|
||||
if (Belong(bundle) == false)
|
||||
return false;
|
||||
|
||||
#if UNITY_ANDROID
|
||||
if (bundle.Encrypted)
|
||||
return true;
|
||||
|
||||
if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录文件信息
|
||||
/// </summary>
|
||||
|
||||
@@ -18,9 +18,8 @@ namespace YooAsset
|
||||
YooLogger.Log("Begin to create catalog file !");
|
||||
|
||||
string savePath = YooAssetSettingsData.GetYooResourcesFullPath();
|
||||
DirectoryInfo saveDirectory = new DirectoryInfo(savePath);
|
||||
if (saveDirectory.Exists)
|
||||
saveDirectory.Delete(true);
|
||||
if (UnityEditor.AssetDatabase.DeleteAsset(savePath))
|
||||
UnityEditor.AssetDatabase.Refresh();
|
||||
|
||||
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_steps = ESteps.Done;
|
||||
@@ -37,7 +37,7 @@ namespace YooAsset
|
||||
_steps = ESteps.InitUnpackFileSystem;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -47,9 +47,11 @@ namespace YooAsset
|
||||
if (_copyBuildinPackageManifestOp == null)
|
||||
{
|
||||
_copyBuildinPackageManifestOp = new CopyBuildinPackageManifestOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _copyBuildinPackageManifestOp);
|
||||
_copyBuildinPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_copyBuildinPackageManifestOp);
|
||||
}
|
||||
|
||||
_copyBuildinPackageManifestOp.UpdateOperation();
|
||||
if (_copyBuildinPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -68,8 +70,13 @@ namespace YooAsset
|
||||
if (_steps == ESteps.InitUnpackFileSystem)
|
||||
{
|
||||
if (_initUnpackFIleSystemOp == null)
|
||||
{
|
||||
_initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem();
|
||||
_initUnpackFIleSystemOp.StartOperation();
|
||||
AddChildOperation(_initUnpackFIleSystemOp);
|
||||
}
|
||||
|
||||
_initUnpackFIleSystemOp.UpdateOperation();
|
||||
Progress = _initUnpackFIleSystemOp.Progress;
|
||||
if (_initUnpackFIleSystemOp.IsDone == false)
|
||||
return;
|
||||
@@ -113,9 +120,11 @@ namespace YooAsset
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||
_loadCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadCatalogFileOp);
|
||||
}
|
||||
|
||||
_loadCatalogFileOp.UpdateOperation();
|
||||
if (_loadCatalogFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -29,13 +29,13 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadAssetBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -139,9 +139,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -166,13 +163,13 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
_steps = ESteps.LoadBuildinRawBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -206,8 +203,5 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestBuildinPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -37,9 +37,11 @@ namespace YooAsset
|
||||
if (_requestBuildinPackageHashOp == null)
|
||||
{
|
||||
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageHashOp);
|
||||
_requestBuildinPackageHashOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageHashOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageHashOp.UpdateOperation();
|
||||
if (_requestBuildinPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -61,9 +63,11 @@ namespace YooAsset
|
||||
{
|
||||
string packageHash = _requestBuildinPackageHashOp.PackageHash;
|
||||
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadBuildinPackageManifestOp);
|
||||
_loadBuildinPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadBuildinPackageManifestOp);
|
||||
}
|
||||
|
||||
_loadBuildinPackageManifestOp.UpdateOperation();
|
||||
if (_loadBuildinPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -33,9 +33,11 @@ namespace YooAsset
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -43,9 +43,11 @@ namespace YooAsset
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp);
|
||||
_requestBuildinPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
_requestBuildinPackageVersionOp.UpdateOperation();
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -82,9 +84,11 @@ namespace YooAsset
|
||||
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _hashFileRequestOp);
|
||||
_hashFileRequestOp.StartOperation();
|
||||
AddChildOperation(_hashFileRequestOp);
|
||||
}
|
||||
|
||||
_hashFileRequestOp.UpdateOperation();
|
||||
if (_hashFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -121,9 +125,11 @@ namespace YooAsset
|
||||
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _manifestFileRequestOp);
|
||||
_manifestFileRequestOp.StartOperation();
|
||||
AddChildOperation(_manifestFileRequestOp);
|
||||
}
|
||||
|
||||
_manifestFileRequestOp.UpdateOperation();
|
||||
if (_manifestFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadCatalog;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace YooAsset
|
||||
_packageVersion = packageVersion;
|
||||
_packageHash = packageHash;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestFileData;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -47,9 +47,11 @@ namespace YooAsset
|
||||
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webDataRequestOp);
|
||||
_webDataRequestOp.StartOperation();
|
||||
AddChildOperation(_webDataRequestOp);
|
||||
}
|
||||
|
||||
_webDataRequestOp.UpdateOperation();
|
||||
if (_webDataRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -85,9 +87,11 @@ namespace YooAsset
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _deserializer);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
_deserializer.UpdateOperation();
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -42,9 +42,11 @@ namespace YooAsset
|
||||
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -40,9 +40,11 @@ namespace YooAsset
|
||||
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,17 +11,22 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
internal class DefaultCacheFileSystem : IFileSystem
|
||||
{
|
||||
protected readonly Dictionary<string, RecordFileElement> _wrappers = new Dictionary<string, RecordFileElement>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleDataFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _bundleInfoFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _tempFilePaths = new Dictionary<string, string>(10000);
|
||||
protected DefaultCacheDownloadCenter _downloadCenter;
|
||||
protected readonly Dictionary<string, RecordFileElement> _records = new Dictionary<string, RecordFileElement>(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> _tempFilePathMapping = new Dictionary<string, string>(10000);
|
||||
|
||||
protected string _packageRoot;
|
||||
protected string _tempFilesRoot;
|
||||
protected string _cacheBundleFilesRoot;
|
||||
protected string _cacheManifestFilesRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 下载中心
|
||||
/// 说明:当异步操作任务终止的时候,所有下载子任务都会一同被终止!
|
||||
/// </summary>
|
||||
public DownloadCenterOperation DownloadCenter { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
@@ -45,7 +50,7 @@ namespace YooAsset
|
||||
{
|
||||
get
|
||||
{
|
||||
return _wrappers.Count;
|
||||
return _records.Count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,19 +103,16 @@ namespace YooAsset
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
{
|
||||
var operation = new DCFSInitializeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DCFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
||||
@@ -118,64 +120,60 @@ namespace YooAsset
|
||||
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||
{
|
||||
var operation = new ClearAllCacheBundleFilesOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||
{
|
||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
||||
{
|
||||
var operation = new ClearAllCacheManifestFilesOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"Invalid clear mode : {clearMode}";
|
||||
var operation = new FSClearCacheFilesCompleteOperation(error);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
{
|
||||
var operation = new DCFSLoadRawBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"{nameof(DefaultCacheFileSystem)} not support load bundle type : {bundle.BundleType}";
|
||||
var operation = new FSLoadBundleCompleteOperation(error);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
@@ -231,11 +229,14 @@ namespace YooAsset
|
||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||
_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)
|
||||
@@ -245,7 +246,7 @@ namespace YooAsset
|
||||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
return _records.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
{
|
||||
@@ -330,60 +331,60 @@ namespace YooAsset
|
||||
#region 缓存相关
|
||||
public List<string> GetAllCachedBundleGUIDs()
|
||||
{
|
||||
return _wrappers.Keys.ToList();
|
||||
return _records.Keys.ToList();
|
||||
}
|
||||
|
||||
public string GetTempFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_tempFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_tempFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
filePath = PathUtility.Combine(_tempFilesRoot, bundle.BundleGUID);
|
||||
_tempFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_tempFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBundleDataFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_bundleDataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_bundleDataFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleDataFileName);
|
||||
if (AppendFileExtension)
|
||||
filePath += bundle.FileExtension;
|
||||
_bundleDataFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_bundleDataFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetBundleInfoFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_bundleInfoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
if (_bundleInfoFilePathMapping.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheBundleFilesRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.BundleInfoFileName);
|
||||
_bundleInfoFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
_bundleInfoFilePathMapping.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public bool IsRecordBundleFile(string bundleGUID)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundleGUID);
|
||||
return _records.ContainsKey(bundleGUID);
|
||||
}
|
||||
public bool RecordBundleFile(string bundleGUID, RecordFileElement element)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
if (_records.ContainsKey(bundleGUID))
|
||||
{
|
||||
YooLogger.Error($"{nameof(DefaultCacheFileSystem)} has element : {bundleGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
_wrappers.Add(bundleGUID, element);
|
||||
_records.Add(bundleGUID, element);
|
||||
return true;
|
||||
}
|
||||
|
||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
||||
return EFileVerifyResult.CacheNotFound;
|
||||
|
||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||
@@ -391,7 +392,7 @@ namespace YooAsset
|
||||
}
|
||||
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundle.BundleGUID))
|
||||
if (_records.ContainsKey(bundle.BundleGUID))
|
||||
{
|
||||
throw new Exception("Should never get here !");
|
||||
}
|
||||
@@ -426,7 +427,7 @@ namespace YooAsset
|
||||
}
|
||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -434,7 +435,7 @@ namespace YooAsset
|
||||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
||||
if (fileInfo.Exists)
|
||||
fileInfo.Directory.Delete(true);
|
||||
_wrappers.Remove(bundleGUID);
|
||||
_records.Remove(bundleGUID);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace YooAsset
|
||||
CheckAppFootPrint,
|
||||
SearchCacheFiles,
|
||||
VerifyCacheFiles,
|
||||
CreateDownloadCenter,
|
||||
Done,
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
_steps = ESteps.Done;
|
||||
@@ -32,7 +33,7 @@ namespace YooAsset
|
||||
_steps = ESteps.CheckAppFootPrint;
|
||||
#endif
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -58,9 +59,11 @@ namespace YooAsset
|
||||
if (_searchCacheFilesOp == null)
|
||||
{
|
||||
_searchCacheFilesOp = new SearchCacheFilesOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _searchCacheFilesOp);
|
||||
_searchCacheFilesOp.StartOperation();
|
||||
AddChildOperation(_searchCacheFilesOp);
|
||||
}
|
||||
|
||||
_searchCacheFilesOp.UpdateOperation();
|
||||
Progress = _searchCacheFilesOp.Progress;
|
||||
if (_searchCacheFilesOp.IsDone == false)
|
||||
return;
|
||||
@@ -73,17 +76,18 @@ namespace YooAsset
|
||||
if (_verifyCacheFilesOp == null)
|
||||
{
|
||||
_verifyCacheFilesOp = new VerifyCacheFilesOperation(_fileSystem, _searchCacheFilesOp.Result);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyCacheFilesOp);
|
||||
_verifyCacheFilesOp.StartOperation();
|
||||
AddChildOperation(_verifyCacheFilesOp);
|
||||
}
|
||||
|
||||
_verifyCacheFilesOp.UpdateOperation();
|
||||
Progress = _verifyCacheFilesOp.Progress;
|
||||
if (_verifyCacheFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_verifyCacheFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.CreateDownloadCenter;
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' cached files count : {_fileSystem.FileCount}");
|
||||
}
|
||||
else
|
||||
@@ -93,6 +97,19 @@ namespace YooAsset
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,11 +29,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckExist;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -54,15 +54,19 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
// 注意:边玩边下下载器引用计数没有Release
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
DownloadProgress = _downloadFileOp.DownloadProgress;
|
||||
DownloadedBytes = _downloadFileOp.DownloadedBytes;
|
||||
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
|
||||
@@ -251,11 +247,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckExist;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -276,15 +272,19 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
// 注意:边玩边下下载器引用计数没有Release
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
_downloadFileOp.UpdateOperation();
|
||||
DownloadProgress = _downloadFileOp.DownloadProgress;
|
||||
DownloadedBytes = _downloadFileOp.DownloadedBytes;
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
@@ -335,13 +335,5 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadFileOp != null)
|
||||
_downloadFileOp.SetAbort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,11 @@ namespace YooAsset
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.DownloadPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -44,9 +44,11 @@ namespace YooAsset
|
||||
if (_downloadPackageHashOp == null)
|
||||
{
|
||||
_downloadPackageHashOp = new DownloadPackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadPackageHashOp);
|
||||
_downloadPackageHashOp.StartOperation();
|
||||
AddChildOperation(_downloadPackageHashOp);
|
||||
}
|
||||
|
||||
_downloadPackageHashOp.UpdateOperation();
|
||||
if (_downloadPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -67,9 +69,11 @@ namespace YooAsset
|
||||
if (_downloadPackageManifestOp == null)
|
||||
{
|
||||
_downloadPackageManifestOp = new DownloadPackageManifestOperation(_fileSystem, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadPackageManifestOp);
|
||||
_downloadPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_downloadPackageManifestOp);
|
||||
}
|
||||
|
||||
_downloadPackageManifestOp.UpdateOperation();
|
||||
if (_downloadPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -90,9 +94,11 @@ namespace YooAsset
|
||||
if (_loadCachePackageHashOp == null)
|
||||
{
|
||||
_loadCachePackageHashOp = new LoadCachePackageHashOperation(_fileSystem, _packageVersion);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCachePackageHashOp);
|
||||
_loadCachePackageHashOp.StartOperation();
|
||||
AddChildOperation(_loadCachePackageHashOp);
|
||||
}
|
||||
|
||||
_loadCachePackageHashOp.UpdateOperation();
|
||||
if (_loadCachePackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -115,9 +121,11 @@ namespace YooAsset
|
||||
{
|
||||
string packageHash = _loadCachePackageHashOp.PackageHash;
|
||||
_loadCachePackageManifestOp = new LoadCachePackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCachePackageManifestOp);
|
||||
_loadCachePackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadCachePackageManifestOp);
|
||||
}
|
||||
|
||||
_loadCachePackageManifestOp.UpdateOperation();
|
||||
Progress = _loadCachePackageManifestOp.Progress;
|
||||
if (_loadCachePackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace YooAsset
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.GetPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -37,9 +37,11 @@ namespace YooAsset
|
||||
if (_requestRemotePackageVersionOp == null)
|
||||
{
|
||||
_requestRemotePackageVersionOp = new RequestRemotePackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestRemotePackageVersionOp);
|
||||
_requestRemotePackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestRemotePackageVersionOp);
|
||||
}
|
||||
|
||||
_requestRemotePackageVersionOp.UpdateOperation();
|
||||
Progress = _requestRemotePackageVersionOp.Progress;
|
||||
if (_requestRemotePackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.GetAllCacheFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -20,11 +20,11 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.ClearAllCacheFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace YooAsset
|
||||
_manifest = manifest;
|
||||
_clearParam = clearParam;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CheckArgs;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_manifest = manifest;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.GetUnusedCacheFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_manifest = manifest;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnusedCacheFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -3,33 +3,33 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DefaultCacheDownloadCenter
|
||||
internal class DownloadCenterOperation : AsyncOperationBase
|
||||
{
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
protected readonly Dictionary<string, DefaultDownloadFileOperation> _downloaders = new Dictionary<string, DefaultDownloadFileOperation>(1000);
|
||||
protected readonly List<string> _removeDownloadList = new List<string>(1000);
|
||||
|
||||
public DefaultCacheDownloadCenter(DefaultCacheFileSystem fileSystem)
|
||||
public DownloadCenterOperation(DefaultCacheFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新下载中心
|
||||
/// </summary>
|
||||
public void Update()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
// 获取可移除的下载器集合
|
||||
_removeDownloadList.Clear();
|
||||
foreach (var valuePair in _downloaders)
|
||||
{
|
||||
var downloader = valuePair.Value;
|
||||
downloader.UpdateOperation();
|
||||
|
||||
// 注意:主动终止引用计数为零的下载任务
|
||||
if (downloader.RefCount <= 0)
|
||||
{
|
||||
_removeDownloadList.Add(valuePair.Key);
|
||||
downloader.SetAbort();
|
||||
downloader.AbortOperation();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
var operation = operationPair.Value;
|
||||
if (operation.Status == EOperationStatus.None)
|
||||
{
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
|
||||
operation.StartOperation();
|
||||
startCount--;
|
||||
if (startCount <= 0)
|
||||
break;
|
||||
@@ -79,7 +79,6 @@ namespace YooAsset
|
||||
// 查询旧的下载器
|
||||
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
|
||||
{
|
||||
oldDownloader.Reference();
|
||||
return oldDownloader;
|
||||
}
|
||||
|
||||
@@ -101,13 +100,13 @@ namespace YooAsset
|
||||
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
|
||||
{
|
||||
newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, param);
|
||||
newDownloader.Reference();
|
||||
AddChildOperation(newDownloader);
|
||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||
}
|
||||
else
|
||||
{
|
||||
newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, param);
|
||||
newDownloader.Reference();
|
||||
AddChildOperation(newDownloader);
|
||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||
}
|
||||
return newDownloader;
|
||||
@@ -16,13 +16,13 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
|
||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -89,7 +89,8 @@ namespace YooAsset
|
||||
{
|
||||
var element = new TempFileElement(_tempFilePath, Bundle.FileCRC, Bundle.FileSize);
|
||||
_verifyOperation = new VerifyTempFileOperation(element);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
||||
_verifyOperation.StartOperation();
|
||||
AddChildOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyTempFile;
|
||||
}
|
||||
|
||||
@@ -99,6 +100,7 @@ namespace YooAsset
|
||||
if (IsWaitForAsyncComplete)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
_verifyOperation.UpdateOperation();
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -157,25 +159,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
//TODO 防止下载器挂起陷入无限死循环!
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
InternalOnStart();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
//TODO 如果是导入或解压本地文件,执行等待完毕
|
||||
if (_isReuqestLocalFile)
|
||||
{
|
||||
InternalOnUpdate();
|
||||
InternalUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace YooAsset
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(DownloadPackageHashOperation));
|
||||
_steps = ESteps.CheckExist;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -58,9 +58,11 @@ namespace YooAsset
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, _packageVersion);
|
||||
string webURL = GetWebRequestURL(fileName);
|
||||
_webFileRequestOp = new UnityWebFileRequestOperation(webURL, savePath, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webFileRequestOp);
|
||||
_webFileRequestOp.StartOperation();
|
||||
AddChildOperation(_webFileRequestOp);
|
||||
}
|
||||
|
||||
_webFileRequestOp.UpdateOperation();
|
||||
if (_webFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace YooAsset
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(DownloadPackageManifestOperation));
|
||||
_steps = ESteps.CheckExist;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -58,9 +58,11 @@ namespace YooAsset
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
|
||||
string webURL = GetDownloadRequestURL(fileName);
|
||||
_webFileRequestOp = new UnityWebFileRequestOperation(webURL, savePath, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webFileRequestOp);
|
||||
_webFileRequestOp.StartOperation();
|
||||
AddChildOperation(_webFileRequestOp);
|
||||
}
|
||||
|
||||
_webFileRequestOp.UpdateOperation();
|
||||
if (_webFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
@@ -20,13 +19,13 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
|
||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -110,7 +109,8 @@ namespace YooAsset
|
||||
{
|
||||
var element = new TempFileElement(_tempFilePath, Bundle.FileCRC, Bundle.FileSize);
|
||||
_verifyOperation = new VerifyTempFileOperation(element);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
||||
_verifyOperation.StartOperation();
|
||||
AddChildOperation(_verifyOperation);
|
||||
_steps = ESteps.CheckVerifyTempFile;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace YooAsset
|
||||
if (IsWaitForAsyncComplete)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
_verifyOperation.UpdateOperation();
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -177,25 +178,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
//TODO 防止下载器挂起陷入无限死循环!
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
InternalOnStart();
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
//TODO 如果是导入或解压本地文件,执行等待完毕
|
||||
if (_isReuqestLocalFile)
|
||||
{
|
||||
InternalOnUpdate();
|
||||
InternalUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace YooAsset
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace YooAsset
|
||||
_packageVersion = packageVersion;
|
||||
_packageHash = packageHash;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.LoadFileData;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -77,9 +77,11 @@ namespace YooAsset
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_fileData);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _deserializer);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
_deserializer.UpdateOperation();
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace YooAsset
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestRemotePackageVersionOperation));
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
@@ -46,9 +46,11 @@ namespace YooAsset
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_fileSystem.PackageName);
|
||||
string url = GetWebRequestURL(fileName);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||
_webTextRequestOp.StartOperation();
|
||||
AddChildOperation(_webTextRequestOp);
|
||||
}
|
||||
|
||||
_webTextRequestOp.UpdateOperation();
|
||||
Progress = _webTextRequestOp.Progress;
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -30,12 +30,12 @@ namespace YooAsset
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.Prepare;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace YooAsset
|
||||
_waitingList = elements;
|
||||
_fileVerifyLevel = fileSystem.FileVerifyLevel;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.InitVerify;
|
||||
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user