Compare commits

...

32 Commits

Author SHA1 Message Date
何冠峰
fcc729a0bf Update CHANGELOG.md 2025-03-08 15:53:46 +08:00
何冠峰
d10e54248b Update package.json 2025-03-08 15:53:35 +08:00
何冠峰
b84800a905 update assembly 2025-03-08 15:51:27 +08:00
何冠峰
8ccd7e552c fix #498 2025-03-08 15:41:03 +08:00
何冠峰
772ba484eb Update HandleFactory.cs 2025-03-08 15:01:19 +08:00
何冠峰
cdbedee705 update asmdef
YooAsset版本宏定义
2025-03-08 14:34:41 +08:00
何冠峰
10cce48e71 Merge pull request #497 from Y-way/support-macros
Support DefineConstants for YooAsset Package
2025-03-08 12:05:07 +08:00
何冠峰
13e8410d80 fix #389 2025-03-08 11:50:35 +08:00
何冠峰
6f07faf4da fix #495 2025-03-08 11:24:17 +08:00
何冠峰
e3228d406e update resource manager
优化Handle生成和移除逻辑
2025-03-08 10:58:19 +08:00
何冠峰
daf2133535 fix #496 2025-03-07 15:03:13 +08:00
Y-way
9bcbc10862 Support DefineConstants for YooAsset Package
自定义YOO_VERSION_2  以及版本管理宏,用于YooAsset升级时的宏定义处理
2025-03-07 15:00:20 +08:00
何冠峰
e6958d205e Update CHANGELOG.md 2025-03-06 15:05:52 +08:00
何冠峰
b03d9db2b0 Update package.json 2025-03-06 15:05:39 +08:00
何冠峰
30853b6d62 update space shooter 2025-03-06 14:31:40 +08:00
何冠峰
a7cafcb328 update UIElements
展示单位Units
2025-03-06 14:31:26 +08:00
何冠峰
d03bca5512 update asset bundle debugger 2025-03-06 12:20:45 +08:00
何冠峰
af3fc50188 update UIElements 2025-03-06 12:20:13 +08:00
何冠峰
b71eeeb855 update UIElements 2025-03-06 11:45:51 +08:00
何冠峰
317c42521a update test sample 2025-03-06 11:39:26 +08:00
何冠峰
064d69269e Update PakcageInvokeBuildParam.cs 2025-03-06 11:17:20 +08:00
何冠峰
9e6401d3c0 update space shooter 2025-03-06 11:17:00 +08:00
何冠峰
2aaba328ee fix #488 2025-03-06 11:16:21 +08:00
何冠峰
62fdc93a82 update test sample 2025-03-06 10:55:54 +08:00
何冠峰
408f0942ee update test sample 2025-03-05 20:00:02 +08:00
何冠峰
ddda9e29db fix #491 2025-03-05 17:39:33 +08:00
何冠峰
c2b33f5ec4 fix #492 2025-03-05 17:29:52 +08:00
何冠峰
e58999e484 update asset bundle debugger 2025-03-05 17:26:58 +08:00
何冠峰
ed9692574c Update AssetBundleSimulateBuilder.cs
模拟构建默认启用依赖关系数据库
2025-03-05 10:54:33 +08:00
何冠峰
f7e078e064 update file system 2025-03-05 10:54:02 +08:00
何冠峰
b74a44dc36 update UIElements 2025-03-03 20:57:50 +08:00
何冠峰
6b36cdb5ee update AssetBundleDebugger
内置了新的UIElments的TreeViewer组件。
2025-03-03 18:28:02 +08:00
165 changed files with 2526 additions and 490 deletions

View File

@@ -2,6 +2,47 @@
All notable changes to this package will be documented in this file.
## [2.3.4-preview] - 2025-03-08
### Improvements
- YooAsset支持了版本宏定义。
```csharp
YOO_ASSET_2
YOO_ASSET_2_3
YOO_ASSET_2_3_OR_NEWER
```
### Fixed
- (#389) 修复了禁用域重载(Reload Domain)的情况下,再次启动游戏报错的问题。
- (#496) 修复了文件系统参数RESUME_DOWNLOAD_MINMUM_SIZE传入int值会导致异常的错误。
- (#498) 修复了v2.3版本尝试加载安卓包内的原生资源包失败的问题。
### Added
- 新增了YooAssets.GetAllPackages()方法
```csharp
/// <summary>
/// 获取所有资源包裹
/// </summary>
public static List<ResourcePackage> GetAllPackages()
```
## [2.3.3-preview] - 2025-03-06
### Improvements
- 新增了异步操作任务调试器AssetBundleDebugger窗口-->OperationView视图模式
- 编辑器下模拟构建默认启用依赖关系数据库,可以大幅降低编辑器下启动游戏的时间。
- 单元测试用例增加加密解密测试用例。
### Fixed
- (#492) 修复了发布的MAC平台应用在启动的时候提示权限无法获取的问题。
## [2.3.2-preview] - 2025-02-27
### Fixed

View File

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

View File

@@ -0,0 +1,109 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using UnityEditor;
namespace YooAsset.Editor
{
[InitializeOnLoad]
public class MacrosProcessor : AssetPostprocessor
{
static MacrosProcessor()
{
}
/// <summary>
/// YooAsset版本宏定义
/// </summary>
private static readonly List<string> YooAssetMacros = new List<string>()
{
"YOO_ASSET_2",
"YOO_ASSET_2_3",
"YOO_ASSET_2_3_OR_NEWER",
};
static string OnGeneratedCSProject(string path, string content)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(content);
if (IsCSProjectReferenced(xmlDoc.DocumentElement) == false)
return content;
if (ProcessDefineConstants(xmlDoc.DocumentElement) == false)
return content;
// 将修改后的XML结构重新输出为文本
var stringWriter = new StringWriter();
var writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
var xmlWriter = XmlWriter.Create(stringWriter, writerSettings);
xmlDoc.WriteTo(xmlWriter);
xmlWriter.Flush();
return stringWriter.ToString();
}
/// <summary>
/// 处理宏定义
/// </summary>
private static bool ProcessDefineConstants(XmlElement element)
{
if (element == null)
return false;
bool processed = false;
foreach (XmlNode node in element.ChildNodes)
{
if (node.Name != "PropertyGroup")
continue;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.Name != "DefineConstants")
continue;
string[] defines = childNode.InnerText.Split(';');
HashSet<string> hashSets = new HashSet<string>(defines);
foreach (string yooMacro in YooAssetMacros)
{
string tmpMacro = yooMacro.Trim();
if (hashSets.Contains(tmpMacro) == false)
hashSets.Add(tmpMacro);
}
childNode.InnerText = string.Join(";", hashSets.ToArray());
processed = true;
}
}
return processed;
}
/// <summary>
/// 检测工程是否引用了YooAsset
/// </summary>
private static bool IsCSProjectReferenced(XmlElement element)
{
if (element == null)
return false;
foreach (XmlNode node in element.ChildNodes)
{
if (node.Name != "ItemGroup")
continue;
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.Name != "Reference" && childNode.Name != "ProjectReference")
continue;
string include = childNode.Attributes["Include"].Value;
if (include.Contains("YooAsset"))
return true;
}
}
return false;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 07f7c95e8e42fd04f81b9925b2dcf0d0
guid: 88d5a41d078a82e40b82265ed4c3631a
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -97,7 +97,7 @@ namespace YooAsset.Editor
private Button _passesVisibleBtn;
private Label _titleLabel;
private Label _descLabel;
private TableView _elementTableView;
private TableViewer _elementTableView;
private ScanReportCombiner _reportCombiner;
private string _lastestOpenFolder;
@@ -152,7 +152,7 @@ namespace YooAsset.Editor
_descLabel = root.Q<Label>("ReportDesc");
// 列表相关
_elementTableView = root.Q<TableView>("TopTableView");
_elementTableView = root.Q<TableViewer>("TopTableView");
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
_lastestOpenFolder = EditorTools.GetProjectPath();
@@ -441,6 +441,8 @@ namespace YooAsset.Editor
columnStyle.Stretchable = header.Stretchable;
columnStyle.Searchable = header.Searchable;
columnStyle.Sortable = header.Sortable;
columnStyle.Counter = header.Counter;
columnStyle.Units = header.Units;
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
column.MakeCell = () =>
{

View File

@@ -17,6 +17,6 @@
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
</uie:Toolbar>
<ui:VisualElement name="AssetGroup" 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.TableViewer name="TopTableView" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -43,6 +43,16 @@ namespace YooAsset.Editor
/// </summary>
public bool Sortable = false;
/// <summary>
/// 统计数量
/// </summary>
public bool Counter = false;
/// <summary>
/// 展示单位
/// </summary>
public string Units = string.Empty;
/// <summary>
/// 数值类型
/// </summary>
@@ -89,6 +99,16 @@ namespace YooAsset.Editor
Sortable = true;
return this;
}
public ReportHeader SetCounter()
{
Counter = true;
return this;
}
public ReportHeader SetUnits(string units)
{
Units = units;
return this;
}
public ReportHeader SetHeaderType(EHeaderType value)
{
HeaderType = value;

View File

@@ -26,6 +26,7 @@ namespace YooAsset.Editor
buildParameters.FileNameStyle = EFileNameStyle.HashName;
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
buildParameters.BuildinFileCopyParams = string.Empty;
buildParameters.UseAssetDependencyDB = true;
var pipeline = new EditorSimulateBuildPipeline();
BuildResult buildResult = pipeline.Run(buildParameters, false);

View File

@@ -59,6 +59,10 @@ namespace YooAsset.Editor
private string _searchKeyWord;
private DebugReport _currentReport;
private RemotePlayerSession _currentPlayerSession;
private double _lastRepaintTime = 0;
private int _nextRepaintIndex = -1;
private int _lastRepaintIndex = 0;
private int _rangeIndex = 0;
@@ -161,6 +165,19 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor);
_playerSessions.Clear();
}
public void Update()
{
// 每间隔1秒绘制一次页面
if (EditorApplication.timeSinceStartup - _lastRepaintTime > 1f)
{
_lastRepaintTime = EditorApplication.timeSinceStartup;
if (_nextRepaintIndex >= 0)
{
RepaintFrame(_nextRepaintIndex);
_nextRepaintIndex = -1;
}
}
}
private void OnHandleConnectionEvent(int playerId)
{
@@ -174,21 +191,27 @@ namespace YooAsset.Editor
}
private void OnHandlePlayerMessage(MessageEventArgs args)
{
var debugReport = DebugReport.Deserialize(args.data);
int playerId = args.playerId;
Debug.Log($"Handle player {playerId} debug report !");
var debugReport = DebugReport.Deserialize(args.data);
if (debugReport.DebuggerVersion != RemoteDebuggerDefine.DebuggerVersion)
{
Debug.LogWarning($"Debugger versions are inconsistent : {debugReport.DebuggerVersion} != {RemoteDebuggerDefine.DebuggerVersion}");
return;
}
//Debug.Log($"Handle player {playerId} debug report !");
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
_currentPlayerSession.AddDebugReport(debugReport);
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
UpdateFrameView(_currentPlayerSession);
_nextRepaintIndex = _currentPlayerSession.MaxRangeValue;
}
private void OnFrameSliderChange(int sliderValue)
{
if (_currentPlayerSession != null)
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
RepaintFrame(_rangeIndex);
}
}
private void OnFrameLast_clicked()
@@ -197,7 +220,7 @@ namespace YooAsset.Editor
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
_frameSlider.value = _rangeIndex;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
RepaintFrame(_rangeIndex);
}
}
private void OnFrameNext_clicked()
@@ -206,21 +229,26 @@ namespace YooAsset.Editor
{
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
_frameSlider.value = _rangeIndex;
UpdateFrameView(_currentPlayerSession, _rangeIndex);
RepaintFrame(_rangeIndex);
}
}
private void OnFrameClear_clicked()
{
_nextRepaintIndex = -1;
_lastRepaintIndex = 0;
_rangeIndex = 0;
_frameSlider.label = $"Frame:";
_frameSlider.value = 0;
_frameSlider.lowValue = 0;
_frameSlider.highValue = 0;
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
_operationListViewer.ClearView();
if (_currentPlayerSession != null)
{
_frameSlider.label = $"Frame:";
_frameSlider.value = 0;
_frameSlider.lowValue = 0;
_frameSlider.highValue = 0;
_currentPlayerSession.ClearDebugReport();
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
_operationListViewer.ClearView();
}
}
private void OnRecordToggleValueChange(ChangeEvent<bool> evt)
@@ -234,42 +262,6 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
{
return session;
}
else
{
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
_playerSessions.Add(playerId, newSession);
return newSession;
}
}
private void UpdateFrameView(RemotePlayerSession playerSession)
{
if (playerSession != null)
{
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
}
}
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
{
if (playerSession == null)
return;
var debugReport = playerSession.GetDebugReport(rangeIndex);
if (debugReport != null)
{
_currentReport = debugReport;
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
_assetListViewer.FillViewData(debugReport);
_bundleListViewer.FillViewData(debugReport);
_operationListViewer.FillViewData(debugReport);
}
}
private void SampleBtn_onClick()
{
// 发送采集数据的命令
@@ -347,6 +339,9 @@ namespace YooAsset.Editor
{
throw new NotImplementedException(viewMode.ToString());
}
// 重新绘制该帧数据
RepaintFrame(_lastRepaintIndex);
}
}
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
@@ -357,6 +352,63 @@ namespace YooAsset.Editor
else
return DropdownMenuAction.Status.Normal;
}
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
{
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
{
return session;
}
else
{
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
_playerSessions.Add(playerId, newSession);
return newSession;
}
}
private void RepaintFrame(int repaintIndex)
{
if (_currentPlayerSession == null)
{
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
_operationListViewer.ClearView();
return;
}
var debugReport = _currentPlayerSession.GetDebugReport(repaintIndex);
if (debugReport != null)
{
_lastRepaintIndex = repaintIndex;
_currentReport = debugReport;
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
_frameSlider.value = repaintIndex;
if (_viewMode == EViewMode.AssetView)
{
_assetListViewer.FillViewData(debugReport);
_bundleListViewer.ClearView();
_operationListViewer.ClearView();
}
else if (_viewMode == EViewMode.BundleView)
{
_assetListViewer.ClearView();
_bundleListViewer.FillViewData(debugReport);
_operationListViewer.ClearView();
}
else if (_viewMode == EViewMode.OperationView)
{
_assetListViewer.ClearView();
_bundleListViewer.ClearView();
_operationListViewer.FillViewData(debugReport);
}
else
{
throw new System.NotImplementedException(_viewMode.ToString());
}
}
}
}
}
#endif

View File

@@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace YooAsset.Editor
{
internal class RemotePlayerSession
{
private readonly List<DebugReport> _reportList = new List<DebugReport>();
private readonly Queue<DebugReport> _reports = new Queue<DebugReport>();
/// <summary>
/// 用户ID
@@ -29,7 +30,7 @@ namespace YooAsset.Editor
{
get
{
int index = _reportList.Count - 1;
int index = _reports.Count - 1;
if (index < 0)
index = 0;
return index;
@@ -37,7 +38,7 @@ namespace YooAsset.Editor
}
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
public RemotePlayerSession(int playerId, int maxReportCount = 500)
{
PlayerId = playerId;
MaxReportCount = maxReportCount;
@@ -48,7 +49,7 @@ namespace YooAsset.Editor
/// </summary>
public void ClearDebugReport()
{
_reportList.Clear();
_reports.Clear();
}
/// <summary>
@@ -59,9 +60,9 @@ namespace YooAsset.Editor
if (report == null)
Debug.LogWarning("Invalid debug report data !");
if (_reportList.Count >= MaxReportCount)
_reportList.RemoveAt(0);
_reportList.Add(report);
if (_reports.Count >= MaxReportCount)
_reports.Dequeue();
_reports.Enqueue(report);
}
/// <summary>
@@ -69,11 +70,11 @@ namespace YooAsset.Editor
/// </summary>
public DebugReport GetDebugReport(int rangeIndex)
{
if (_reportList.Count == 0)
if (_reports.Count == 0)
return null;
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
if (rangeIndex < 0 || rangeIndex >= _reports.Count)
return null;
return _reportList[rangeIndex];
return _reports.ElementAt(rangeIndex);
}
/// <summary>

View File

@@ -24,8 +24,8 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _providerTableView;
private TableView _dependTableView;
private TableViewer _providerTableView;
private TableViewer _dependTableView;
private List<ITableData> _sourceDatas;
@@ -44,12 +44,12 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f;
// 资源列表
_providerTableView = _root.Q<TableView>("TopTableView");
_providerTableView = _root.Q<TableViewer>("TopTableView");
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
CreateAssetTableViewColumns();
// 依赖列表
_dependTableView = _root.Q<TableView>("BottomTableView");
_dependTableView = _root.Q<TableViewer>("BottomTableView");
CreateDependTableViewColumns();
// 面板分屏
@@ -148,10 +148,11 @@ namespace YooAsset.Editor
// LoadingTime
{
var columnStyle = new ColumnStyle(100);
var columnStyle = new ColumnStyle(130);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
columnStyle.Units = "ms";
var column = new TableColumn("LoadingTime", "Loading Time", columnStyle);
column.MakeCell = () =>
{
@@ -279,7 +280,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var dependTableData = data as DependTableData;
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed)
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@@ -332,8 +333,10 @@ namespace YooAsset.Editor
public void ClearView()
{
_providerTableView.ClearAll(false, true);
_providerTableView.RebuildView();
_dependTableView.ClearAll(false, true);
RebuildView(null);
_dependTableView.RebuildView();
}
/// <summary>
@@ -342,10 +345,12 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
if (_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_providerTableView.RebuildView();
_dependTableView.RebuildView();
}
/// <summary>

View File

@@ -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.TableViewer 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; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" />
<YooAsset.Editor.TableViewer name="BottomTableView" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -28,9 +28,9 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _bundleTableView;
private TableView _usingTableView;
private TableView _referenceTableView;
private TableViewer _bundleTableView;
private TableViewer _usingTableView;
private TableViewer _referenceTableView;
private List<ITableData> _sourceDatas;
@@ -48,16 +48,16 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f;
// 资源包列表
_bundleTableView = _root.Q<TableView>("BundleTableView");
_bundleTableView = _root.Q<TableViewer>("BundleTableView");
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
CreateBundleTableViewColumns();
// 使用列表
_usingTableView = _root.Q<TableView>("UsingTableView");
_usingTableView = _root.Q<TableViewer>("UsingTableView");
CreateUsingTableViewColumns();
// 引用列表
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
_referenceTableView = _root.Q<TableViewer>("ReferenceTableView");
CreateReferenceTableViewColumns();
// 面板分屏
@@ -151,7 +151,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var bundleTableData = data as BundleTableData;
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed)
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@@ -341,7 +341,7 @@ namespace YooAsset.Editor
{
StyleColor textColor;
var feferenceTableData = data as ReferenceTableData;
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow);
else
textColor = new StyleColor(Color.white);
@@ -393,8 +393,10 @@ namespace YooAsset.Editor
{
_bundleTableView.ClearAll(false, true);
_bundleTableView.RebuildView();
_usingTableView.ClearAll(false, true);
_usingTableView.RebuildView();
_referenceTableView.ClearAll(false, true);
_referenceTableView.RebuildView();
}
@@ -405,10 +407,13 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_bundleTableView.RebuildView();
_usingTableView.RebuildView();
_referenceTableView.RebuildView();
}
/// <summary>

View File

@@ -1,9 +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="BundleTableView" />
<YooAsset.Editor.TableViewer name="BundleTableView" />
</ui:VisualElement>
<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" />
<YooAsset.Editor.TableViewer name="UsingTableView" />
<YooAsset.Editor.TableViewer name="ReferenceTableView" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -20,13 +20,10 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _operationTableView;
private TableViewer _operationTableView;
private Toolbar _bottomToolbar;
#if UNITY_2022_3_OR_NEWER
private TreeView _childTreeView;
#endif
private TreeViewer _childTreeView;
private int _treeItemID = 0;
private List<ITableData> _sourceDatas;
@@ -44,7 +41,7 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f;
// 任务列表
_operationTableView = _root.Q<TableView>("TopTableView");
_operationTableView = _root.Q<TableViewer>("TopTableView");
_operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged;
CreateOperationTableViewColumns();
@@ -53,11 +50,9 @@ namespace YooAsset.Editor
CreateBottomToolbarHeaders();
// 子列表
#if UNITY_2022_3_OR_NEWER
_childTreeView = _root.Q<TreeView>("BottomTreeView");
_childTreeView = _root.Q<TreeViewer>("BottomTreeView");
_childTreeView.makeItem = MakeTreeViewItem;
_childTreeView.bindItem = BindTreeViewItem;
#endif
// 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup");
@@ -175,10 +170,11 @@ namespace YooAsset.Editor
// ProcessTime
{
var columnStyle = new ColumnStyle(100);
var columnStyle = new ColumnStyle(130);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
columnStyle.Units = "ms";
var column = new TableColumn("ProcessTime", "Process Time", columnStyle);
column.MakeCell = () =>
{
@@ -275,9 +271,9 @@ namespace YooAsset.Editor
// ProcessTime
{
ToolbarButton button = new ToolbarButton();
button.text = "ProcessTime";
button.text = "ProcessTime (ms)";
button.style.flexGrow = 0;
button.style.width = 100;
button.style.width = 130;
_bottomToolbar.Add(button);
}
@@ -307,11 +303,8 @@ namespace YooAsset.Editor
{
// 清空旧数据
_operationTableView.ClearAll(false, true);
#if UNITY_2022_3_OR_NEWER
_childTreeView.SetRootItems(new List<TreeViewItemData<DebugOperationInfo>>());
_childTreeView.Rebuild();
#endif
_childTreeView.ClearAll();
_childTreeView.RebuildView();
// 填充数据源
_sourceDatas = new List<ITableData>(1000);
@@ -345,11 +338,10 @@ namespace YooAsset.Editor
public void ClearView()
{
_operationTableView.ClearAll(false, true);
#if UNITY_2022_3_OR_NEWER
_childTreeView.SetRootItems(new List<TreeViewItemData<DebugOperationInfo>>());
_childTreeView.Rebuild();
#endif
RebuildView(null);
_operationTableView.RebuildView();
_childTreeView.ClearAll();
_childTreeView.RebuildView();
}
/// <summary>
@@ -358,10 +350,12 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_operationTableView.RebuildView();
_childTreeView.RebuildView();
}
/// <summary>
@@ -380,23 +374,20 @@ namespace YooAsset.Editor
_root.RemoveFromHierarchy();
}
#if UNITY_2022_3_OR_NEWER
private void OnOperationTableViewSelectionChanged(ITableData data)
{
var operationTableData = data as OperationTableData;
DebugPackageData packageData = operationTableData.PackageData;
DebugOperationInfo operationInfo = operationTableData.OperationInfo;
_treeItemID = 0;
var rootItems = CreateTreeData(operationInfo);
_childTreeView.SetRootItems(rootItems);
_childTreeView.Rebuild();
TreeNode rootNode = new TreeNode(operationInfo);
FillTreeData(operationInfo, rootNode);
_childTreeView.ClearAll();
_childTreeView.SetRootItem(rootNode);
_childTreeView.RebuildView();
}
private VisualElement MakeTreeViewItem()
private void MakeTreeViewItem(VisualElement container)
{
VisualElement treeViewElement = new VisualElement();
treeViewElement.style.flexDirection = FlexDirection.Row;
// OperationName
{
Label label = new Label();
@@ -404,7 +395,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f;
label.style.width = 300;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
// Progress
@@ -414,7 +405,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
// BeginTime
@@ -424,7 +415,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
// ProcessTime
@@ -432,9 +423,9 @@ namespace YooAsset.Editor
var label = new Label();
label.name = "ProcessTime";
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.width = 130;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
// Status
@@ -444,7 +435,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f;
label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
// Desc
@@ -454,36 +445,34 @@ namespace YooAsset.Editor
label.style.flexGrow = 1f;
label.style.width = 500;
label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label);
container.Add(label);
}
return treeViewElement;
}
private void BindTreeViewItem(VisualElement element, int index)
private void BindTreeViewItem(VisualElement container, object userData)
{
var operationInfo = _childTreeView.GetItemDataForIndex<DebugOperationInfo>(index);
var operationInfo = (DebugOperationInfo)userData;
// OperationName
{
var label = element.Q<Label>("OperationName");
var label = container.Q<Label>("OperationName");
label.text = operationInfo.OperationName;
}
// Progress
{
var label = element.Q<Label>("Progress");
var label = container.Q<Label>("Progress");
label.text = operationInfo.Progress.ToString();
}
// BeginTime
{
var label = element.Q<Label>("BeginTime");
var label = container.Q<Label>("BeginTime");
label.text = operationInfo.BeginTime;
}
// ProcessTime
{
var label = element.Q<Label>("ProcessTime");
var label = container.Q<Label>("ProcessTime");
label.text = operationInfo.ProcessTime.ToString();
}
@@ -495,33 +484,26 @@ namespace YooAsset.Editor
else
textColor = new StyleColor(Color.white);
var label = element.Q<Label>("Status");
var label = container.Q<Label>("Status");
label.text = operationInfo.Status;
label.style.color = textColor;
}
// Desc
{
var label = element.Q<Label>("Desc");
var label = container.Q<Label>("Desc");
label.text = operationInfo.OperationDesc;
}
}
private List<TreeViewItemData<DebugOperationInfo>> CreateTreeData(DebugOperationInfo parentOperation)
private void FillTreeData(DebugOperationInfo parentOperation, TreeNode rootNode)
{
var rootItemList = new List<TreeViewItemData<DebugOperationInfo>>();
foreach (var childOperation in parentOperation.Childs)
{
var childItemList = CreateTreeData(childOperation);
var treeItem = new TreeViewItemData<DebugOperationInfo>(_treeItemID++, childOperation, childItemList);
rootItemList.Add(treeItem);
var childNode = new TreeNode(childOperation);
rootNode.AddChild(childNode);
FillTreeData(childOperation, childNode);
}
return rootItemList;
}
#else
private void OnOperationTableViewSelectionChanged(ITableData data)
{
}
#endif
}
}
#endif

View File

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

View File

@@ -24,8 +24,8 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _assetTableView;
private TableView _dependTableView;
private TableViewer _assetTableView;
private TableViewer _dependTableView;
private BuildReport _buildReport;
private string _reportFilePath;
@@ -46,13 +46,13 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f;
// 资源列表
_assetTableView = _root.Q<TableView>("TopTableView");
_assetTableView = _root.Q<TableViewer>("TopTableView");
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
CreateAssetTableViewColumns();
// 依赖列表
_dependTableView = _root.Q<TableView>("BottomTableView");
_dependTableView = _root.Q<TableViewer>("BottomTableView");
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
CreateDependTableViewColumns();

View File

@@ -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" style="flex-grow: 1;" />
<YooAsset.Editor.TableViewer 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; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -24,8 +24,8 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableView _bundleTableView;
private TableView _includeTableView;
private TableViewer _bundleTableView;
private TableViewer _includeTableView;
private BuildReport _buildReport;
private string _reportFilePath;
@@ -46,13 +46,13 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f;
// 资源包列表
_bundleTableView = _root.Q<TableView>("TopTableView");
_bundleTableView = _root.Q<TableViewer>("TopTableView");
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
CreateBundleTableViewColumns();
// 包含列表
_includeTableView = _root.Q<TableView>("BottomTableView");
_includeTableView = _root.Q<TableViewer>("BottomTableView");
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
CreateIncludeTableViewColumns();

View File

@@ -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" style="flex-grow: 1;" />
<YooAsset.Editor.TableViewer 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; flex-grow: 1;">
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>

View File

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

View File

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

View File

@@ -46,6 +46,11 @@ namespace YooAsset.Editor
/// </summary>
public bool Counter = false;
/// <summary>
/// 展示单位
/// </summary>
public string Units = string.Empty;
public ColumnStyle(Length width)
{
if (width.value > MaxValue)

View File

@@ -13,9 +13,9 @@ namespace YooAsset.Editor
/// <summary>
/// Unity2022版本以上推荐官方类MultiColumnListView组件
/// </summary>
public class TableView : VisualElement
public class TableViewer : VisualElement
{
public new class UxmlFactory : UxmlFactory<TableView, UxmlTraits>
public new class UxmlFactory : UxmlFactory<TableViewer, UxmlTraits>
{
}
@@ -82,7 +82,7 @@ namespace YooAsset.Editor
public Action<ITableData> SelectionChangedEvent;
public TableView()
public TableViewer()
{
this.style.flexShrink = 1f;
this.style.flexGrow = 1f;
@@ -214,6 +214,16 @@ namespace YooAsset.Editor
}
}
// 设置展示单位
foreach (var column in _columns)
{
if (string.IsNullOrEmpty(column.ColumnStyle.Units) == false)
{
var toobarButton = GetHeaderElement(column.ElementName) as ToolbarButton;
toobarButton.text = $"{toobarButton.text} ({column.ColumnStyle.Units})";
}
}
// 设置升降符号
if (string.IsNullOrEmpty(_sortingHeader) == false)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -10,6 +10,14 @@ namespace YooAsset.Editor
public const string RecordOn = "d_Record On@2x";
public const string RecordOff = "d_Record Off@2x";
#if UNITY_2019
public const string FoldoutOn = "IN foldout on";
public const string FoldoutOff = "IN foldout";
#else
public const string FoldoutOn = "d_IN_foldout_on@2x";
public const string FoldoutOff = "d_IN_foldout@2x";
#endif
public const string VisibilityToggleOff = "animationvisibilitytoggleoff@2x";
public const string VisibilityToggleOn = "animationvisibilitytoggleon@2x";
}

View File

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

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal class DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
internal struct DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
{
/// <summary>
/// 资源包名称
@@ -20,7 +20,7 @@ namespace YooAsset
/// <summary>
/// 加载状态
/// </summary>
public EOperationStatus Status;
public string Status;
/// <summary>
/// 谁引用了该资源包

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal class DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
internal struct DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
{
/// <summary>
/// 任务名称

View File

@@ -47,7 +47,7 @@ namespace YooAsset
else
{
UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}");
return null;
return default;
}
}
}

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset
{
[Serializable]
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
internal struct DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
{
/// <summary>
/// 包裹名

View File

@@ -12,6 +12,11 @@ namespace YooAsset
[Serializable]
internal class DebugReport
{
/// <summary>
/// 调试器版本
/// </summary>
public string DebuggerVersion = RemoteDebuggerDefine.DebuggerVersion;
/// <summary>
/// 游戏帧
/// </summary>

View File

@@ -1,10 +1,10 @@
using System;
using System.Text;
namespace YooAsset
{
internal class RemoteDebuggerDefine
{
public const string DebuggerVersion = "2.3.3";
public static readonly Guid kMsgPlayerSendToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3");
public static readonly Guid kMsgEditorSendToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a");
}

View File

@@ -7,6 +7,15 @@ namespace YooAsset
{
internal class RemoteDebuggerInRuntime : MonoBehaviour
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_sampleOnce = false;
_autoSample = false;
}
#endif
private static bool _sampleOnce = false;
private static bool _autoSample = false;

View File

@@ -8,6 +8,14 @@ namespace YooAsset
{
internal class RemoteEditorConnection
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_instance = null;
}
#endif
private static RemoteEditorConnection _instance;
public static RemoteEditorConnection Instance
{

View File

@@ -8,6 +8,14 @@ namespace YooAsset
{
internal class RemotePlayerConnection
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_instance = null;
}
#endif
private static RemotePlayerConnection _instance;
public static RemotePlayerConnection Instance
{
@@ -23,12 +31,10 @@ namespace YooAsset
public void Initialize()
{
Debug.LogWarning("X=Initialize");
_messageCallbacks.Clear();
}
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{
Debug.LogWarning("X=Register");
if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !");
@@ -37,7 +43,6 @@ namespace YooAsset
}
public void Unregister(Guid messageID)
{
Debug.LogWarning("X=Unregister");
if (_messageCallbacks.ContainsKey(messageID))
_messageCallbacks.Remove(messageID);
}

View File

@@ -1,4 +1,5 @@
using UnityEngine.Networking;
using UnityEngine;
namespace YooAsset
{
@@ -9,6 +10,14 @@ namespace YooAsset
internal class DownloadSystemHelper
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
UnityWebRequestCreater = null;
}
#endif
public static UnityWebRequestDelegate UnityWebRequestCreater = null;
public static UnityWebRequest NewUnityWebRequestGet(string requestURL)
{

View File

@@ -6,6 +6,14 @@ namespace YooAsset
{
internal class WebRequestCounter
{
#if UNITY_EDITOR
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_requestFailedRecorder.Clear();
}
#endif
/// <summary>
/// 记录网络请求失败事件的次数
/// </summary>

View File

@@ -147,15 +147,15 @@ namespace YooAsset
}
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
{
AppendFileExtension = (bool)value;
AppendFileExtension = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.DISABLE_CATALOG_FILE)
{
DisableCatalogFile = (bool)value;
DisableCatalogFile = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST)
{
CopyBuildinPackageManifest = (bool)value;
CopyBuildinPackageManifest = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT)
{
@@ -239,6 +239,11 @@ namespace YooAsset
if (Exists(bundle) == false)
return null;
#if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
YooLogger.Error($"Android platform not support read buildin bundle file data !");
return null;
#else
if (bundle.Encrypted)
{
if (DecryptionServices == null)
@@ -261,6 +266,7 @@ namespace YooAsset
string filePath = GetBuildinFileLoadPath(bundle);
return FileUtility.ReadAllBytes(filePath);
}
#endif
}
public virtual string ReadBundleFileText(PackageBundle bundle)
{
@@ -270,6 +276,11 @@ namespace YooAsset
if (Exists(bundle) == false)
return null;
#if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
YooLogger.Error($"Android platform not support read buildin bundle file text !");
return null;
#else
if (bundle.Encrypted)
{
if (DecryptionServices == null)
@@ -292,6 +303,7 @@ namespace YooAsset
string filePath = GetBuildinFileLoadPath(bundle);
return FileUtility.ReadAllText(filePath);
}
#endif
}
#region

View File

@@ -176,6 +176,12 @@ namespace YooAsset
if (_steps == ESteps.LoadBuildinRawBundle)
{
#if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
_steps = ESteps.Done;
Result = new RawBundleResult(_fileSystem, _bundle);
Status = EOperationStatus.Succeed;
#else
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
if (File.Exists(filePath))
{
@@ -190,6 +196,7 @@ namespace YooAsset
Error = $"Can not found buildin raw bundle file : {filePath}";
YooLogger.Error(Error);
}
#endif
}
}
internal override void InternalWaitForAsyncComplete()

View File

@@ -190,19 +190,19 @@ namespace YooAsset
}
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
{
AppendFileExtension = (bool)value;
AppendFileExtension = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
{
DownloadMaxConcurrency = (int)value;
DownloadMaxConcurrency = Convert.ToInt32(value);
}
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME)
{
DownloadMaxRequestPerFrame = (int)value;
DownloadMaxRequestPerFrame = Convert.ToInt32(value);
}
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
{
ResumeDownloadMinimumSize = (long)value;
ResumeDownloadMinimumSize = Convert.ToInt64(value);
}
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_RESPONSE_CODES)
{

View File

@@ -94,11 +94,11 @@ namespace YooAsset
{
if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME)
{
_asyncSimulateMinFrame = (int)value;
_asyncSimulateMinFrame = Convert.ToInt32(value);
}
else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME)
{
_asyncSimulateMaxFrame = (int)value;
_asyncSimulateMaxFrame = Convert.ToInt32(value);
}
else
{

View File

@@ -101,7 +101,7 @@ namespace YooAsset
{
if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE)
{
DisableUnityWebCache = (bool)value;
DisableUnityWebCache = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.REMOTE_SERVICES)
{

View File

@@ -110,7 +110,7 @@ namespace YooAsset
{
if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE)
{
DisableUnityWebCache = (bool)value;
DisableUnityWebCache = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
{

View File

@@ -35,6 +35,11 @@ namespace YooAsset
DownloadProgress = 0;
}
internal override string InternalGetDesc()
{
return $"RefCount : {RefCount}";
}
/// <summary>
/// 减少引用计数
/// </summary>

View File

@@ -6,6 +6,14 @@ namespace YooAsset
{
internal class OperationSystem
{
#if UNITY_EDITOR
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
DestroyAll();
}
#endif
private static readonly List<AsyncOperationBase> _operations = new List<AsyncOperationBase>(1000);
private static readonly List<AsyncOperationBase> _newList = new List<AsyncOperationBase>(1000);

View File

@@ -13,6 +13,11 @@ namespace YooAsset
/// </summary>
public string BuildPipelineName;
/// <summary>
/// 用户数据
/// </summary>
public object BuildUserData;
/// <summary>
/// 构建类所属程序集名称
/// </summary>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
namespace YooAsset
{
internal static class HandleFactory
{
private static readonly Dictionary<Type, Func<ProviderOperation, HandleBase>> _handleFactory = new Dictionary<Type, Func<ProviderOperation, HandleBase>>()
{
{ typeof(AssetHandle), op => new AssetHandle(op) },
{ typeof(SceneHandle), op => new SceneHandle(op) },
{ typeof(SubAssetsHandle), op => new SubAssetsHandle(op) },
{ typeof(AllAssetsHandle), op => new AllAssetsHandle(op) },
{ typeof(RawFileHandle), op => new RawFileHandle(op) }
};
public static HandleBase CreateHandle(ProviderOperation operation, Type type)
{
if (_handleFactory.TryGetValue(type, out var factory) == false)
{
throw new NotImplementedException($"Handle type {type.FullName} is not supported.");
}
return factory(operation);
}
}
}

View File

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

View File

@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System;
using System.Linq;
namespace YooAsset
{
@@ -69,8 +69,8 @@ namespace YooAsset
private ESteps _steps = ESteps.None;
private readonly LoadBundleFileOperation _mainBundleLoader;
private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>();
private readonly List<HandleBase> _handles = new List<HandleBase>();
private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>(10);
private readonly HashSet<HandleBase> _handles = new HashSet<HandleBase>();
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
@@ -220,20 +220,7 @@ namespace YooAsset
// 引用计数增加
RefCount++;
HandleBase handle;
if (typeof(T) == typeof(AssetHandle))
handle = new AssetHandle(this);
else if (typeof(T) == typeof(SceneHandle))
handle = new SceneHandle(this);
else if (typeof(T) == typeof(SubAssetsHandle))
handle = new SubAssetsHandle(this);
else if (typeof(T) == typeof(AllAssetsHandle))
handle = new AllAssetsHandle(this);
else if (typeof(T) == typeof(RawFileHandle))
handle = new RawFileHandle(this);
else
throw new System.NotImplementedException();
HandleBase handle = HandleFactory.CreateHandle(this, typeof(T));
_handles.Add(handle);
return handle as T;
}
@@ -258,9 +245,9 @@ namespace YooAsset
/// </summary>
public void ReleaseAllHandles()
{
for (int i = _handles.Count - 1; i >= 0; i--)
List<HandleBase> tempers = _handles.ToList();
foreach (var handle in tempers)
{
var handle = _handles[i];
handle.Release();
}
}
@@ -276,7 +263,7 @@ namespace YooAsset
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
List<HandleBase> tempers = new List<HandleBase>(_handles);
List<HandleBase> tempers = _handles.ToList();
foreach (var hande in tempers)
{
if (hande.IsValid)

View File

@@ -385,7 +385,7 @@ namespace YooAsset
var bundleInfo = new DebugBundleInfo();
bundleInfo.BundleName = packageBundle.BundleName;
bundleInfo.RefCount = bundleLoader.RefCount;
bundleInfo.Status = bundleLoader.Status;
bundleInfo.Status = bundleLoader.Status.ToString();
bundleInfo.ReferenceBundles = FilterReferenceBundles(packageBundle);
result.Add(bundleInfo);
}

View File

@@ -3,10 +3,18 @@ using UnityEngine;
namespace YooAsset
{
internal static class YooAssetSettingsData
public static class YooAssetSettingsData
{
#if UNITY_EDITOR
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_setting = null;
}
#endif
private static YooAssetSettings _setting = null;
public static YooAssetSettings Setting
internal static YooAssetSettings Setting
{
get
{
@@ -33,6 +41,15 @@ namespace YooAsset
}
}
/// <summary>
/// 获取YooAsset文件夹名称
/// </summary>
public static string GetDefaultYooFolderName()
{
return Setting.DefaultYooFolderName;
}
/// <summary>
/// 获取构建报告文件名
/// </summary>
@@ -92,7 +109,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的Resources目录的加载路径
/// </summary>
public static string GetYooResourcesLoadPath(string packageName, string fileName)
internal static string GetYooResourcesLoadPath(string packageName, string fileName)
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return PathUtility.Combine(packageName, fileName);
@@ -103,7 +120,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的Resources目录的全路径
/// </summary>
public static string GetYooResourcesFullPath()
internal static string GetYooResourcesFullPath()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return $"Assets/Resources";
@@ -114,7 +131,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO的编辑器下缓存文件根目录
/// </summary>
public static string GetYooEditorCacheRoot()
internal static string GetYooEditorCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
{
@@ -132,9 +149,9 @@ namespace YooAsset
}
/// <summary>
/// 获取YOO的PC缓存文件根目录
/// 获取YOO的PC平台缓存文件根目录
/// </summary>
public static string GetYooStandaloneCacheRoot()
internal static string GetYooStandaloneWinCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.dataPath;
@@ -143,9 +160,31 @@ namespace YooAsset
}
/// <summary>
/// 获取YOO的移动端缓存文件根目录
/// 获取YOO的Linux平台缓存文件根目录
/// </summary>
public static string GetYooMobileCacheRoot()
internal static string GetYooStandaloneLinuxCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.dataPath;
else
return PathUtility.Combine(Application.dataPath, Setting.DefaultYooFolderName);
}
/// <summary>
/// 获取YOO的Mac平台缓存文件根目录
/// </summary>
internal static string GetYooStandaloneMacCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.persistentDataPath;
else
return PathUtility.Combine(Application.persistentDataPath, Setting.DefaultYooFolderName);
}
/// <summary>
/// 获取YOO的移动平台缓存文件根目录
/// </summary>
internal static string GetYooMobileCacheRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.persistentDataPath;
@@ -156,12 +195,16 @@ namespace YooAsset
/// <summary>
/// 获取YOO默认的缓存文件根目录
/// </summary>
public static string GetYooDefaultCacheRoot()
internal static string GetYooDefaultCacheRoot()
{
#if UNITY_EDITOR
return GetYooEditorCacheRoot();
#elif UNITY_STANDALONE
return GetYooStandaloneCacheRoot();
#elif UNITY_STANDALONE_WIN
return GetYooStandaloneWinCacheRoot();
#elif UNITY_STANDALONE_LINUX
return GetYooStandaloneLinuxCacheRoot();
#elif UNITY_STANDALONE_OSX
return GetYooStandaloneMacCacheRoot();
#else
return GetYooMobileCacheRoot();
#endif
@@ -170,7 +213,7 @@ namespace YooAsset
/// <summary>
/// 获取YOO默认的内置文件根目录
/// </summary>
public static string GetYooDefaultBuildinRoot()
internal static string GetYooDefaultBuildinRoot()
{
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
return Application.streamingAssetsPath;

View File

@@ -9,6 +9,22 @@
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"versionDefines": [
{
"name": "com.tuyoogame.yooasset",
"expression": "",
"define": "YOO_ASSET_2"
},
{
"name": "com.tuyoogame.yooasset",
"expression": "2.3",
"define": "YOO_ASSET_2_3"
},
{
"name": "com.tuyoogame.yooasset",
"expression": "2.3",
"define": "YOO_ASSET_2_3_OR_NEWER"
}
],
"noEngineReferences": false
}

View File

@@ -2,12 +2,23 @@ using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace YooAsset
{
public static partial class YooAssets
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_isInitialize = false;
_packages.Clear();
_defaultPackage = null;
}
#endif
private static bool _isInitialize = false;
private static GameObject _driver = null;
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
@@ -77,9 +88,9 @@ namespace YooAsset
}
/// <summary>
/// 创建资源包
/// 创建资源包
/// </summary>
/// <param name="packageName">资源包名称</param>
/// <param name="packageName">包名称</param>
public static ResourcePackage CreatePackage(string packageName)
{
CheckException(packageName);
@@ -93,9 +104,9 @@ namespace YooAsset
}
/// <summary>
/// 获取资源包
/// 获取资源包
/// </summary>
/// <param name="packageName">资源包名称</param>
/// <param name="packageName">包名称</param>
public static ResourcePackage GetPackage(string packageName)
{
CheckException(packageName);
@@ -106,9 +117,9 @@ namespace YooAsset
}
/// <summary>
/// 尝试获取资源包
/// 尝试获取资源包
/// </summary>
/// <param name="packageName">资源包名称</param>
/// <param name="packageName">包名称</param>
public static ResourcePackage TryGetPackage(string packageName)
{
CheckException(packageName);
@@ -116,9 +127,17 @@ namespace YooAsset
}
/// <summary>
/// 移除资源包
/// 获取所有资源包
/// </summary>
/// <param name="packageName">资源包名称</param>
public static List<ResourcePackage> GetAllPackages()
{
return _packages.ToList();
}
/// <summary>
/// 移除资源包裹
/// </summary>
/// <param name="packageName">包裹名称</param>
public static bool RemovePackage(string packageName)
{
CheckException(packageName);
@@ -130,9 +149,9 @@ namespace YooAsset
}
/// <summary>
/// 移除资源包
/// 移除资源包
/// </summary>
/// <param name="package">资源包实例对象</param>
/// <param name="package">包实例对象</param>
public static bool RemovePackage(ResourcePackage package)
{
CheckException(package);
@@ -149,9 +168,9 @@ namespace YooAsset
}
/// <summary>
/// 检测资源包是否存在
/// 检测资源包是否存在
/// </summary>
/// <param name="packageName">资源包名称</param>
/// <param name="packageName">包名称</param>
public static bool ContainsPackage(string packageName)
{
CheckException(packageName);

View File

@@ -5,6 +5,14 @@ namespace YooAsset
{
internal class YooAssetsDriver : MonoBehaviour
{
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
LastestUpdateFrame = 0;
}
#endif
private static int LastestUpdateFrame = 0;
void Update()

View File

@@ -44,10 +44,10 @@ public class TextureSchema : ScannerSchema
string name = "扫描所有纹理资产";
string desc = GetUserGuide();
var report = new ScanReport(name, desc);
report.AddHeader("资源路径", 600, 500, 1000).SetStretchable().SetSearchable().SetSortable().SetHeaderType(EHeaderType.AssetPath);
report.AddHeader("资源路径", 600, 500, 1000).SetStretchable().SetSearchable().SetSortable().SetCounter().SetHeaderType(EHeaderType.AssetPath);
report.AddHeader("图片宽度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue);
report.AddHeader("图片高度", 100).SetSortable().SetHeaderType(EHeaderType.LongValue);
report.AddHeader("内存大小", 100).SetSortable().SetHeaderType(EHeaderType.LongValue);
report.AddHeader("内存大小", 120).SetSortable().SetUnits("bytes").SetHeaderType(EHeaderType.LongValue);
report.AddHeader("苹果格式", 100);
report.AddHeader("安卓格式", 100);
report.AddHeader("错误信息", 500).SetStretchable();

View File

@@ -70,17 +70,19 @@ internal class FsmInitializePackage : IStateNode
// WebGL运行模式
if (playMode == EPlayMode.WebPlayMode)
{
var createParameters = new WebPlayModeParameters();
#if UNITY_WEBGL && WEIXINMINIGAME && !UNITY_EDITOR
var createParameters = new WebPlayModeParameters();
string defaultHostServer = GetHostServerURL();
string fallbackHostServer = GetHostServerURL();
string packageRoot = $"{WeChatWASM.WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE"; //注意:如果有子目录,请修改此处!
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
createParameters.WebServerFileSystemParameters = WechatFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteServices);
#else
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters(new WebDecryption());
#endif
initializationOperation = package.InitializeAsync(createParameters);
#else
var createParameters = new WebPlayModeParameters();
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
initializationOperation = package.InitializeAsync(createParameters);
#endif
}
yield return initializationOperation;
@@ -149,24 +151,4 @@ internal class FsmInitializePackage : IStateNode
return $"{_fallbackHostServer}/{fileName}";
}
}
private class WebDecryption : IWebDecryptionServices
{
public const byte KEY = 64;
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
{
byte[] copyData = new byte[fileInfo.FileData.Length];
Buffer.BlockCopy(fileInfo.FileData, 0, copyData, 0, fileInfo.FileData.Length);
for (int i = 0; i < copyData.Length; i++)
{
copyData[i] ^= KEY;
}
WebDecryptResult decryptResult = new WebDecryptResult();
decryptResult.Result = AssetBundle.LoadFromMemory(copyData);
return decryptResult;
}
}
}

View File

@@ -15,17 +15,22 @@ public static class TestPackageBuilder
if (buildPipelineName == EBuildPipeline.EditorSimulateBuildPipeline.ToString())
{
string projectPath = EditorTools.GetProjectPath();
string outputRoot = $"{projectPath}/Bundles/Tester_ESBP";
var buildParameters = new EditorSimulateBuildParameters();
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildOutputRoot = outputRoot;
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.PackageName = packageName;
buildParameters.PackageVersion = "ESBP_Simulate";
buildParameters.PackageVersion = "TestVersion";
buildParameters.FileNameStyle = EFileNameStyle.HashName;
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
buildParameters.BuildinFileCopyParams = string.Empty;
buildParameters.ClearBuildCacheFiles = true;
buildParameters.UseAssetDependencyDB = true;
var pipeline = new EditorSimulateBuildPipeline();
BuildResult buildResult = pipeline.Run(buildParameters, false);
@@ -43,16 +48,20 @@ public static class TestPackageBuilder
}
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
{
string projectPath = EditorTools.GetProjectPath();
string outputRoot = $"{projectPath}/Bundles/Tester_SBP";
// 内置着色器资源包名称
var builtinShaderBundleName = GetBuiltinShaderBundleName(packageName);
var buildParameters = new ScriptableBuildParameters();
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildOutputRoot = outputRoot;
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
buildParameters.BuildPipeline = EBuildPipeline.ScriptableBuildPipeline.ToString();
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.PackageName = packageName;
buildParameters.PackageVersion = "SBP_Simulate";
buildParameters.PackageVersion = "TestVersion";
buildParameters.EnableSharePackRule = true;
buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = EFileNameStyle.HashName;
@@ -62,6 +71,7 @@ public static class TestPackageBuilder
buildParameters.ClearBuildCacheFiles = true;
buildParameters.UseAssetDependencyDB = true;
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
buildParameters.EncryptionServices = new FileStreamEncryption();
var pipeline = new ScriptableBuildPipeline();
BuildResult buildResult = pipeline.Run(buildParameters, false);
@@ -79,14 +89,17 @@ public static class TestPackageBuilder
}
else if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
{
string projectPath = EditorTools.GetProjectPath();
string outputRoot = $"{projectPath}/Bundles/Tester_BBP";
var buildParameters = new BuiltinBuildParameters();
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildOutputRoot = outputRoot;
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
buildParameters.BuildPipeline = EBuildPipeline.ScriptableBuildPipeline.ToString();
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.PackageName = packageName;
buildParameters.PackageVersion = "BBP_Simulate";
buildParameters.PackageVersion = "TestVersion";
buildParameters.EnableSharePackRule = true;
buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = EFileNameStyle.HashName;
@@ -95,6 +108,7 @@ public static class TestPackageBuilder
buildParameters.CompressOption = ECompressOption.LZ4;
buildParameters.ClearBuildCacheFiles = true;
buildParameters.UseAssetDependencyDB = true;
buildParameters.EncryptionServices = new FileStreamEncryption();
var pipeline = new BuiltinBuildPipeline();
BuildResult buildResult = pipeline.Run(buildParameters, false);
@@ -112,14 +126,17 @@ public static class TestPackageBuilder
}
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
{
string projectPath = EditorTools.GetProjectPath();
string outputRoot = $"{projectPath}/Bundles/Tester_RFBP";
var buildParameters = new RawFileBuildParameters();
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildOutputRoot = outputRoot;
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
buildParameters.BuildPipeline = EBuildPipeline.RawFileBuildPipeline.ToString();
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.PackageName = packageName;
buildParameters.PackageVersion = "RFBP_Simulate";
buildParameters.PackageVersion = "TestVersion";
buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = EFileNameStyle.HashName;
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;

View File

@@ -1,6 +0,0 @@

public class AssetBundleCollectorDefine
{
public const string TestPackageName = "TestPackage";
public const string RawPackageName = "RawPackage";
}

View File

@@ -1,28 +0,0 @@
using System;
using System.IO;
using System.Text;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.U2D;
using UnityEngine.TestTools;
using NUnit.Framework;
using YooAsset;
public class AssetBundleCollectorPreapre : IPrebuildSetup, IPostBuildCleanup
{
void IPrebuildSetup.Setup()
{
AssetBundleCollectorMaker.MakeCollectorSettingData();
}
void IPostBuildCleanup.Cleanup()
{
}
[Test]
public void InitializeYooAssets()
{
// 初始化YooAsset
YooAssets.Initialize();
}
}

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