mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-15 20:20:08 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15dc047488 | ||
|
|
91b25400dc | ||
|
|
d316c5000a | ||
|
|
d8692c836f | ||
|
|
0a4a3d8f2e | ||
|
|
5484b604a7 | ||
|
|
66c3c4862a | ||
|
|
e9d31bbf94 | ||
|
|
55bcd502e2 | ||
|
|
9bf22f2c79 | ||
|
|
cbf142dbf8 | ||
|
|
a6e94acefb |
167
Assets/UniTask.YooAsset~/OperationHandleBaseExtensions.cs
Normal file
167
Assets/UniTask.YooAsset~/OperationHandleBaseExtensions.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using YooAsset;
|
||||
using static Cysharp.Threading.Tasks.Internal.Error;
|
||||
|
||||
namespace Cysharp.Threading.Tasks
|
||||
{
|
||||
public static class OperationHandleBaseExtensions
|
||||
{
|
||||
public static UniTask.Awaiter GetAwaiter(this OperationHandleBase handle)
|
||||
{
|
||||
return ToUniTask(handle).GetAwaiter();
|
||||
}
|
||||
|
||||
public static UniTask ToUniTask(this OperationHandleBase handle,
|
||||
IProgress<float> progress = null,
|
||||
PlayerLoopTiming timing = PlayerLoopTiming.Update)
|
||||
{
|
||||
ThrowArgumentNullException(handle, nameof(handle));
|
||||
|
||||
if(!handle.IsValid)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
return new UniTask(
|
||||
OperationHandleBaserConfiguredSource.Create(
|
||||
handle,
|
||||
timing,
|
||||
progress,
|
||||
out var token
|
||||
),
|
||||
token
|
||||
);
|
||||
}
|
||||
|
||||
sealed class OperationHandleBaserConfiguredSource : IUniTaskSource,
|
||||
IPlayerLoopItem,
|
||||
ITaskPoolNode<OperationHandleBaserConfiguredSource>
|
||||
{
|
||||
private static TaskPool<OperationHandleBaserConfiguredSource> pool;
|
||||
|
||||
private OperationHandleBaserConfiguredSource nextNode;
|
||||
|
||||
public ref OperationHandleBaserConfiguredSource NextNode => ref nextNode;
|
||||
|
||||
static OperationHandleBaserConfiguredSource()
|
||||
{
|
||||
TaskPool.RegisterSizeGetter(typeof(OperationHandleBaserConfiguredSource), () => pool.Size);
|
||||
}
|
||||
|
||||
private readonly Action<OperationHandleBase> continuationAction;
|
||||
private OperationHandleBase handle;
|
||||
private IProgress<float> progress;
|
||||
private bool completed;
|
||||
private UniTaskCompletionSourceCore<AsyncUnit> core;
|
||||
|
||||
OperationHandleBaserConfiguredSource() { continuationAction = Continuation; }
|
||||
|
||||
public static IUniTaskSource Create(OperationHandleBase handle,
|
||||
PlayerLoopTiming timing,
|
||||
IProgress<float> progress,
|
||||
out short token)
|
||||
{
|
||||
if(!pool.TryPop(out var result))
|
||||
{
|
||||
result = new OperationHandleBaserConfiguredSource();
|
||||
}
|
||||
|
||||
result.handle = handle;
|
||||
result.progress = progress;
|
||||
result.completed = false;
|
||||
TaskTracker.TrackActiveTask(result, 3);
|
||||
|
||||
if(progress is not null)
|
||||
{
|
||||
PlayerLoopHelper.AddAction(timing, result);
|
||||
}
|
||||
|
||||
switch(handle)
|
||||
{
|
||||
case AssetOperationHandle asset_handle:
|
||||
asset_handle.Completed += result.continuationAction;
|
||||
break;
|
||||
case SceneOperationHandle scene_handle:
|
||||
scene_handle.Completed += result.continuationAction;
|
||||
break;
|
||||
case SubAssetsOperationHandle sub_asset_handle:
|
||||
sub_asset_handle.Completed += result.continuationAction;
|
||||
break;
|
||||
}
|
||||
|
||||
token = result.core.Version;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Continuation(OperationHandleBase _)
|
||||
{
|
||||
switch(handle)
|
||||
{
|
||||
case AssetOperationHandle asset_handle:
|
||||
asset_handle.Completed -= continuationAction;
|
||||
break;
|
||||
case SceneOperationHandle scene_handle:
|
||||
scene_handle.Completed -= continuationAction;
|
||||
break;
|
||||
case SubAssetsOperationHandle sub_asset_handle:
|
||||
sub_asset_handle.Completed -= continuationAction;
|
||||
break;
|
||||
}
|
||||
|
||||
if(completed)
|
||||
{
|
||||
TryReturn();
|
||||
}
|
||||
else
|
||||
{
|
||||
completed = true;
|
||||
if(handle.Status == EOperationStatus.Failed)
|
||||
{
|
||||
core.TrySetException(new Exception(handle.LastError));
|
||||
}
|
||||
else
|
||||
{
|
||||
core.TrySetResult(AsyncUnit.Default);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TryReturn()
|
||||
{
|
||||
TaskTracker.RemoveTracking(this);
|
||||
core.Reset();
|
||||
handle = default;
|
||||
progress = default;
|
||||
return pool.TryPush(this);
|
||||
}
|
||||
|
||||
public UniTaskStatus GetStatus(short token) => core.GetStatus(token);
|
||||
|
||||
public void OnCompleted(Action<object> continuation, object state, short token)
|
||||
{
|
||||
core.OnCompleted(continuation, state, token);
|
||||
}
|
||||
|
||||
public void GetResult(short token) { core.GetResult(token); }
|
||||
|
||||
public UniTaskStatus UnsafeGetStatus() => core.UnsafeGetStatus();
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
if(completed)
|
||||
{
|
||||
TryReturn();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(handle.IsValid)
|
||||
{
|
||||
progress?.Report(handle.Progress);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1c9a3a6de2246bf88547a6b59b99b9f
|
||||
timeCreated: 1650851321
|
||||
19
Assets/UniTask.YooAsset~/README.md
Normal file
19
Assets/UniTask.YooAsset~/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# UniTask 扩展
|
||||
|
||||
[仓库链接](https://github.com/Cysharp/UniTask)
|
||||
- 请去下载对应的源码,并删除此目录最后的波浪线
|
||||
- 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用
|
||||
|
||||
## 代码示例
|
||||
|
||||
```csharp
|
||||
var handle = YooAssets.LoadAssetAsync<GameObject>("Assets/Res/Prefabs/TestImg.prefab");
|
||||
|
||||
await handle.ToUniTask();
|
||||
|
||||
var obj = handle.AssetObject as GameObject;
|
||||
var go = Instantiate(obj, transform);
|
||||
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
go.transform.localScale = Vector3.one;
|
||||
```
|
||||
17
Assets/UniTask.YooAsset~/UniTask.YooAsset.asmdef
Normal file
17
Assets/UniTask.YooAsset~/UniTask.YooAsset.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "UniTask.YooAsset",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:e34a5702dd353724aa315fb8011f08c3",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/UniTask.YooAsset~/UniTask.YooAsset.asmdef.meta
Normal file
7
Assets/UniTask.YooAsset~/UniTask.YooAsset.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf4f1d4730c114c48ab680458e5a2455
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [1.0.6] - 2022-04-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复工具界面显示异常在Unity2021版本下。
|
||||
|
||||
### Changed
|
||||
|
||||
- 操作句柄支持错误信息查询。
|
||||
- 支持UniTask异步操作库。
|
||||
- 优化类型搜索方式,改为全域搜索类型。
|
||||
- AssetBundleGrouper窗口添加和移除Grouper支持操作回退。
|
||||
|
||||
## [1.0.5] - 2022-04-22
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -198,8 +198,9 @@ namespace YooAsset.Editor
|
||||
/// 获取加密类的类型列表
|
||||
/// </summary>
|
||||
private List<Type> GetEncryptionServicesClassTypes()
|
||||
{
|
||||
List<Type> classTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IEncryptionServices));
|
||||
{
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IEncryptionServices>();
|
||||
List<Type> classTypes = collection.ToList();
|
||||
return classTypes;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
@@ -250,6 +252,7 @@ namespace YooAsset.Editor
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = providerInfo.BundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar4" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
@@ -15,6 +15,6 @@
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -58,7 +58,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
@@ -250,10 +252,7 @@ namespace YooAsset.Editor
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(string bundleName)
|
||||
{
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var providerInfo in _debugReport.ProviderInfos)
|
||||
{
|
||||
@@ -266,7 +265,11 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
@@ -15,6 +15,6 @@
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar4" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string AssetTags = string.Empty;
|
||||
|
||||
[NonSerialized]
|
||||
public object UserData;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
@@ -110,7 +111,9 @@ namespace YooAsset.Editor
|
||||
typeof(PackGrouper),
|
||||
typeof(PackRawFile),
|
||||
};
|
||||
var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IPackRule));
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IPackRule>();
|
||||
var customTypes = collection.ToList();
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
@@ -134,7 +137,9 @@ namespace YooAsset.Editor
|
||||
typeof(CollectPrefab),
|
||||
typeof(CollectSprite)
|
||||
};
|
||||
var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IFilterRule));
|
||||
|
||||
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IFilterRule>();
|
||||
var customTypes = collection.ToList();
|
||||
types.AddRange(customTypes);
|
||||
for (int i = 0; i < types.Count; i++)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
private List<string> _packRuleList;
|
||||
private List<string> _filterRuleList;
|
||||
private ListView _grouperListView;
|
||||
private ListView _collectorListView;
|
||||
private ScrollView _collectorScrollView;
|
||||
private Toggle _autoCollectShaderToogle;
|
||||
private TextField _shaderBundleNameTxt;
|
||||
private TextField _grouperNameTxt;
|
||||
@@ -32,6 +32,9 @@ namespace YooAsset.Editor
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
Undo.undoRedoPerformed -= RefreshWindow;
|
||||
Undo.undoRedoPerformed += RefreshWindow;
|
||||
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
||||
@@ -61,7 +64,7 @@ namespace YooAsset.Editor
|
||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||
});
|
||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
||||
@@ -126,22 +129,15 @@ namespace YooAsset.Editor
|
||||
});
|
||||
|
||||
// 收集列表相关
|
||||
_collectorListView = root.Q<ListView>("CollectorListView");
|
||||
_collectorListView.makeItem = MakeCollectorListViewItem;
|
||||
_collectorListView.bindItem = BindCollectorListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_collectorListView.onSelectionChange += CollectorListView_onSelectionChange;
|
||||
#else
|
||||
_collectorListView.onSelectionChanged += CollectorListView_onSelectionChange;
|
||||
#endif
|
||||
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||
_collectorScrollView.viewDataKey = "scrollView";
|
||||
|
||||
// 收集添加删除按钮
|
||||
// 收集器创建按钮
|
||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||
{
|
||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddCollectorBtn_clicked;
|
||||
var removeBtn = collectorAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveCollectorBtn_clicked;
|
||||
}
|
||||
|
||||
// 刷新窗体
|
||||
@@ -194,6 +190,7 @@ namespace YooAsset.Editor
|
||||
_grouperListView.Clear();
|
||||
_grouperListView.ClearSelection();
|
||||
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
||||
_grouperListView.Rebuild();
|
||||
}
|
||||
private VisualElement MakeGrouperListViewItem()
|
||||
{
|
||||
@@ -227,6 +224,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void AddGrouperBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset AddGrouper");
|
||||
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper", string.Empty, string.Empty);
|
||||
FillGrouperViewData();
|
||||
}
|
||||
@@ -236,6 +234,8 @@ namespace YooAsset.Editor
|
||||
if (selectGrouper == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset RemoveGrouper");
|
||||
|
||||
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
||||
FillGrouperViewData();
|
||||
}
|
||||
@@ -251,13 +251,20 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
_grouperContainer.visible = true;
|
||||
_collectorListView.Clear();
|
||||
_collectorListView.ClearSelection();
|
||||
_collectorListView.itemsSource = selectGrouper.Collectors;
|
||||
|
||||
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
||||
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
||||
_grouperAssetTagsTxt.SetValueWithoutNotify(selectGrouper.AssetTags);
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectGrouper.Collectors.Count; i++)
|
||||
{
|
||||
var collector = selectGrouper.Collectors[i];
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
collector.UserData = element;
|
||||
BindCollectorListViewItem(element, i);
|
||||
_collectorScrollView.Add(element);
|
||||
}
|
||||
}
|
||||
private VisualElement MakeCollectorListViewItem()
|
||||
{
|
||||
@@ -271,11 +278,15 @@ namespace YooAsset.Editor
|
||||
elementBottom.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementBottom);
|
||||
|
||||
VisualElement elementFold = new VisualElement();
|
||||
elementFold.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementFold);
|
||||
|
||||
// Top VisualElement
|
||||
{
|
||||
var objectField = new ObjectField();
|
||||
objectField.name = "ObjectField1";
|
||||
objectField.label = "Collect Path";
|
||||
objectField.label = "Collecter";
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
objectField.style.flexGrow = 1f;
|
||||
@@ -283,6 +294,14 @@ namespace YooAsset.Editor
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 80;
|
||||
}
|
||||
{
|
||||
var button = new Button();
|
||||
button.name = "Button1";
|
||||
button.text = "[ - ]";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.style.flexGrow = 0f;
|
||||
elementTop.Add(button);
|
||||
}
|
||||
|
||||
// Bottom VisualElement
|
||||
{
|
||||
@@ -336,6 +355,8 @@ namespace YooAsset.Editor
|
||||
return;
|
||||
|
||||
var collector = selectGrouper.Collectors[index];
|
||||
collector.UserData = element;
|
||||
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
@@ -350,6 +371,13 @@ namespace YooAsset.Editor
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
});
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
removeBtn.clicked += ()=>
|
||||
{
|
||||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Pack Rule
|
||||
var popupField1 = element.Q<PopupField<string>>("PopupField1");
|
||||
popupField1.index = GetPackRuleIndex(collector.PackRuleName);
|
||||
@@ -386,9 +414,6 @@ namespace YooAsset.Editor
|
||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||
});
|
||||
}
|
||||
private void CollectorListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
@@ -398,16 +423,13 @@ namespace YooAsset.Editor
|
||||
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty, nameof(PackDirectory), nameof(CollectAll), false);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked()
|
||||
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||
{
|
||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||
if (selectGrouper == null)
|
||||
return;
|
||||
|
||||
var selectCollector = _collectorListView.selectedItem as AssetBundleCollector;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
|
||||
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="LeftContainer" 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:ListView focusable="true" name="GrouperListView" item-height="20" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="GrouperListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GrouperAddContainer" 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" />
|
||||
@@ -22,10 +22,9 @@
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Desc" name="GrouperDesc" />
|
||||
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
<ui:ListView focusable="true" name="CollectorListView" item-height="50" style="flex-grow: 1;" />
|
||||
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -77,7 +77,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
||||
}
|
||||
private List<ReportAssetInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
||||
@@ -201,6 +203,7 @@ namespace YooAsset.Editor
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = bundles;
|
||||
_dependListView.Rebuild();
|
||||
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
||||
}
|
||||
private VisualElement MakeDependListViewItem()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar3" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
@@ -13,6 +13,6 @@
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -78,7 +78,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
||||
}
|
||||
private List<ReportBundleInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
||||
@@ -204,6 +206,7 @@ namespace YooAsset.Editor
|
||||
_includeListView.Clear();
|
||||
_includeListView.ClearSelection();
|
||||
_includeListView.itemsSource = containsList;
|
||||
_includeListView.Rebuild();
|
||||
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
||||
}
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
@@ -15,7 +15,7 @@
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="GUID" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -60,9 +60,8 @@ namespace YooAsset.Editor
|
||||
public void FillViewData(BuildReport buildReport)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_listView.Clear();
|
||||
|
||||
_items.Clear();
|
||||
|
||||
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
||||
@@ -97,7 +96,10 @@ namespace YooAsset.Editor
|
||||
_items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));
|
||||
_items.Add(new ItemWrapper("原生资源包总大小", ConvertSize(buildReport.Summary.RawBundleTotalSize)));
|
||||
|
||||
_listView.Clear();
|
||||
_listView.ClearSelection();
|
||||
_listView.itemsSource = _items;
|
||||
_listView.Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -4,6 +4,6 @@
|
||||
<uie:ToolbarButton text="概览" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="参数" 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" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#if UNITY_2019_4
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
#if UNITY_2019
|
||||
public static partial class UnityEngine_UIElements_ListView_Extension
|
||||
{
|
||||
public static void ClearSelection(this UnityEngine.UIElements.ListView o)
|
||||
@@ -8,5 +9,15 @@ namespace YooAsset.Editor
|
||||
o.selectedIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if UNITY_2019 || UNITY_2020
|
||||
public static partial class UnityEngine_UIElements_ListView_Extension
|
||||
{
|
||||
public static void Rebuild(this UnityEngine.UIElements.ListView o)
|
||||
{
|
||||
o.Refresh();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_providers[i].CanDestroy())
|
||||
{
|
||||
_providers[i].Destory();
|
||||
_providers[i].Destroy();
|
||||
_providers.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace YooAsset
|
||||
{
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
provider.Destory();
|
||||
provider.Destroy();
|
||||
}
|
||||
_providers.Clear();
|
||||
|
||||
|
||||
@@ -32,6 +32,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsValid == false)
|
||||
return string.Empty;
|
||||
return _provider.LastError;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载进度
|
||||
/// </summary>
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
return;
|
||||
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
|
||||
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||
{
|
||||
_steps = ESteps.Download;
|
||||
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
|
||||
@@ -83,9 +83,9 @@ namespace YooAsset
|
||||
|
||||
if (_downloader.HasError())
|
||||
{
|
||||
_downloader.ReportError();
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = _downloader.GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -100,9 +100,10 @@ namespace YooAsset
|
||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||
if (System.IO.File.Exists(_fileLoadPath) == false)
|
||||
{
|
||||
YooLogger.Warning($"Not found assetBundle file : {_fileLoadPath}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found assetBundle file : {_fileLoadPath}";
|
||||
YooLogger.Error(LastError);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -151,9 +152,10 @@ namespace YooAsset
|
||||
// Check error
|
||||
if (CacheBundle == null)
|
||||
{
|
||||
YooLogger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load assetBundle : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public EStatus Status { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经销毁
|
||||
/// </summary>
|
||||
@@ -139,7 +144,7 @@ namespace YooAsset
|
||||
// 销毁所有Providers
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
provider.Destory();
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 从列表里移除Providers
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
return;
|
||||
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
|
||||
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||
{
|
||||
_steps = ESteps.LoadFile;
|
||||
_webURL = BundleFileInfo.GetStreamingLoadPath();
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset
|
||||
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
||||
#endif
|
||||
{
|
||||
Debug.LogWarning($"Failed to get asset bundle form web : {_webURL} Error : {_webRequest.error}");
|
||||
YooLogger.Warning($"Failed to get asset bundle form web : {_webURL} Error : {_webRequest.error}");
|
||||
_steps = ESteps.TryLoad;
|
||||
_tryTimer = 0;
|
||||
}
|
||||
@@ -85,9 +85,10 @@ namespace YooAsset
|
||||
CacheBundle = DownloadHandlerAssetBundle.GetContent(_webRequest);
|
||||
if (CacheBundle == null)
|
||||
{
|
||||
Debug.LogError($"Get asset bundle error : {_webRequest.error}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"AssetBundle file is invalid : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||
|
||||
|
||||
public DependAssetBundleGrouper(string assetPath)
|
||||
{
|
||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||
@@ -29,6 +30,36 @@ namespace YooAsset
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依赖资源包是否全部加载成功
|
||||
/// </summary>
|
||||
public bool IsSucceed()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
{
|
||||
if (loader.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某个加载失败的资源包错误信息
|
||||
/// </summary>
|
||||
public string GetLastError()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
{
|
||||
if (loader.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
return loader.LastError;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主线程等待异步操作完毕
|
||||
/// </summary>
|
||||
|
||||
@@ -45,15 +45,23 @@ namespace YooAsset
|
||||
if (OwnerBundle.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (OwnerBundle.CacheBundle == null)
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Fail;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
Status = EStatus.Fail;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
@@ -97,7 +105,10 @@ namespace YooAsset
|
||||
|
||||
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
||||
if (Status == EStatus.Fail)
|
||||
YooLogger.Warning($"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
|
||||
{
|
||||
LastError = $"Failed to load asset : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace YooAsset
|
||||
DependBundles = new DependAssetBundleGrouper(assetPath);
|
||||
DependBundles.Reference();
|
||||
}
|
||||
public override void Destory()
|
||||
public override void Destroy()
|
||||
{
|
||||
base.Destory();
|
||||
base.Destroy();
|
||||
|
||||
// 释放资源包
|
||||
if (OwnerBundle != null)
|
||||
|
||||
@@ -46,15 +46,23 @@ namespace YooAsset
|
||||
if (OwnerBundle.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (OwnerBundle.CacheBundle == null)
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Fail;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
Status = EStatus.Fail;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载场景
|
||||
@@ -69,8 +77,9 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Failed to load scene : {AssetName}");
|
||||
Status = EStatus.Fail;
|
||||
LastError = $"Failed to load scene : {AssetName}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
@@ -85,6 +94,11 @@ namespace YooAsset
|
||||
SceneManager.SetActiveScene(SceneObject);
|
||||
|
||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||
if(Status == EStatus.Fail)
|
||||
{
|
||||
LastError = $"The load scene is invalid : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,15 +45,23 @@ namespace YooAsset
|
||||
if (OwnerBundle.IsDone() == false)
|
||||
return;
|
||||
|
||||
if (OwnerBundle.CacheBundle == null)
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Fail;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
Status = EStatus.Fail;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
@@ -97,7 +105,10 @@ namespace YooAsset
|
||||
|
||||
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
||||
if (Status == EStatus.Fail)
|
||||
YooLogger.Warning($"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}");
|
||||
{
|
||||
LastError = $"Failed to load sub assets : {AssetName} from bundle : {OwnerBundle.BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace YooAsset
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Fail;
|
||||
LastError = $"Not found asset : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
@@ -41,7 +43,7 @@ namespace YooAsset
|
||||
{
|
||||
Status = EStatus.Loading;
|
||||
}
|
||||
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
return;
|
||||
@@ -59,7 +61,10 @@ namespace YooAsset
|
||||
{
|
||||
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
||||
if (Status == EStatus.Fail)
|
||||
YooLogger.Warning($"Failed to load asset object : {AssetPath}");
|
||||
{
|
||||
LastError = $"Failed to load asset object : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -51,8 +51,9 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Failed to load scene : {AssetName}");
|
||||
Status = EStatus.Fail;
|
||||
LastError = $"Failed to load scene : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
@@ -67,6 +68,11 @@ namespace YooAsset
|
||||
SceneManager.SetActiveScene(SceneObject);
|
||||
|
||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||
if (Status == EStatus.Fail)
|
||||
{
|
||||
LastError = $"The load scene is invalid : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace YooAsset
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Fail;
|
||||
LastError = $"Not found asset : {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
return;
|
||||
}
|
||||
@@ -73,7 +75,10 @@ namespace YooAsset
|
||||
{
|
||||
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
||||
if (Status == EStatus.Fail)
|
||||
YooLogger.Warning($"Failed to load sub assets : {AssetName}");
|
||||
{
|
||||
LastError = $"Failed to load sub assets : {nameof(AssetType)} in {AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public EStatus Status { protected set; get; } = EStatus.None;
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError { protected set; get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 引用计数
|
||||
/// </summary>
|
||||
@@ -105,7 +110,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 销毁资源对象
|
||||
/// </summary>
|
||||
public virtual void Destory()
|
||||
public virtual void Destroy()
|
||||
{
|
||||
IsDestroyed = true;
|
||||
}
|
||||
|
||||
@@ -98,19 +98,27 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报告错误信息
|
||||
/// 按照错误级别打印错误
|
||||
/// </summary>
|
||||
public void ReportError()
|
||||
{
|
||||
YooLogger.Error($"Failed to download : {_requestURL} Error : {_lastError}");
|
||||
YooLogger.Error(GetLastError());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近一条错误日志
|
||||
/// 按照警告级别打印错误
|
||||
/// </summary>
|
||||
public void ReportWarning()
|
||||
{
|
||||
YooLogger.Warning(GetLastError());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取最近发生的错误信息
|
||||
/// </summary>
|
||||
public string GetLastError()
|
||||
{
|
||||
return _lastError;
|
||||
return $"Failed to download : {_requestURL} Error : {_lastError}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,17 +95,21 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError();
|
||||
|
||||
string cacheFilePath = _bundleInfo.GetCacheLoadPath();
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
|
||||
// 失败后重新尝试
|
||||
if (_failedTryAgain > 0)
|
||||
{
|
||||
ReportWarning();
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError();
|
||||
_steps = ESteps.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
// 释放下载器
|
||||
|
||||
@@ -211,13 +211,18 @@ namespace YooAsset
|
||||
if (_threadDownloader.HasError())
|
||||
{
|
||||
_lastError = _threadDownloader.Error;
|
||||
ReportError();
|
||||
|
||||
// 失败后重新尝试
|
||||
if (_failedTryAgain > 0)
|
||||
{
|
||||
ReportWarning();
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError();
|
||||
_steps = ESteps.Failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -240,7 +245,7 @@ namespace YooAsset
|
||||
}
|
||||
public override void Abort()
|
||||
{
|
||||
if(IsDone() == false)
|
||||
if (IsDone() == false)
|
||||
{
|
||||
_steps = ESteps.Failed;
|
||||
_lastError = "user abort";
|
||||
|
||||
@@ -105,7 +105,6 @@ namespace YooAsset
|
||||
// 检测是否下载失败
|
||||
if (downloader.HasError())
|
||||
{
|
||||
downloader.ReportError();
|
||||
_removeList.Add(downloader);
|
||||
_loadFailedList.Add(bundleInfo);
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
||||
[assembly: InternalsVisibleTo("YooAsset.EditorExtend")]
|
||||
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
||||
@@ -84,7 +84,7 @@ namespace YooAsset
|
||||
{
|
||||
if (string.IsNullOrEmpty(location))
|
||||
{
|
||||
Debug.LogError("location param is null or empty!");
|
||||
YooLogger.Error("location param is null or empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,11 +93,11 @@ namespace YooAsset
|
||||
if (index != -1)
|
||||
{
|
||||
if (location.Length == index + 1)
|
||||
Debug.LogWarning($"Found blank character in location : \"{location}\"");
|
||||
YooLogger.Warning($"Found blank character in location : \"{location}\"");
|
||||
}
|
||||
|
||||
if (location.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
|
||||
Debug.LogWarning($"Found illegal character in location : \"{location}\"");
|
||||
YooLogger.Warning($"Found illegal character in location : \"{location}\"");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,147 +3,10 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 程序集工具类
|
||||
/// </summary>
|
||||
internal static class AssemblyUtility
|
||||
{
|
||||
public const string YooAssetAssemblyName = "YooAsset";
|
||||
public const string YooAssetAssemblyEditorName = "YooAsset.Editor";
|
||||
public const string UnityDefaultAssemblyName = "Assembly-CSharp";
|
||||
public const string UnityDefaultAssemblyEditorName = "Assembly-CSharp-Editor";
|
||||
|
||||
|
||||
private static readonly Dictionary<string, List<Type>> _cache = new Dictionary<string, List<Type>>();
|
||||
|
||||
static AssemblyUtility()
|
||||
{
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取程序集
|
||||
/// </summary>
|
||||
public static Assembly GetAssembly(string assemblyName)
|
||||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
if (assembly.GetName().Name == assemblyName)
|
||||
return assembly;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取程序集里的所有类型
|
||||
/// </summary>
|
||||
private static List<Type> GetTypes(string assemblyName)
|
||||
{
|
||||
if (_cache.ContainsKey(assemblyName))
|
||||
return _cache[assemblyName];
|
||||
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (Assembly assembly in assemblies)
|
||||
{
|
||||
if (assembly.GetName().Name == assemblyName)
|
||||
{
|
||||
List<Type> types = assembly.GetTypes().ToList();
|
||||
_cache.Add(assemblyName, types);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
// 注意:如果没有找到程序集返回空列表
|
||||
UnityEngine.Debug.LogWarning($"Not found assembly : {assemblyName}");
|
||||
return new List<Type>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取带继承关系的所有类的类型
|
||||
/// <param name="parentType">父类类型</param>
|
||||
/// </summary>
|
||||
public static List<Type> GetAssignableTypes(string assemblyName, System.Type parentType)
|
||||
{
|
||||
List<Type> result = new List<Type>();
|
||||
List<Type> cacheTypes = GetTypes(assemblyName);
|
||||
for (int i = 0; i < cacheTypes.Count; i++)
|
||||
{
|
||||
Type type = cacheTypes[i];
|
||||
|
||||
// 判断继承关系
|
||||
if (parentType.IsAssignableFrom(type))
|
||||
{
|
||||
if (type.Name == parentType.Name)
|
||||
continue;
|
||||
result.Add(type);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取带属性标签的所有类的类型
|
||||
/// <param name="attributeType">属性类型</param>
|
||||
/// </summary>
|
||||
public static List<Type> GetAttributeTypes(string assemblyName, System.Type attributeType)
|
||||
{
|
||||
List<Type> result = new List<Type>();
|
||||
List<Type> cacheTypes = GetTypes(assemblyName);
|
||||
for (int i = 0; i < cacheTypes.Count; i++)
|
||||
{
|
||||
System.Type type = cacheTypes[i];
|
||||
|
||||
// 判断属性标签
|
||||
if (Attribute.IsDefined(type, attributeType))
|
||||
{
|
||||
result.Add(type);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取带继承关系和属性标签的所有类的类型
|
||||
/// </summary>
|
||||
/// <param name="parentType">父类类型</param>
|
||||
/// <param name="attributeType">属性类型</param>
|
||||
public static List<Type> GetAssignableAttributeTypes(string assemblyName, System.Type parentType, System.Type attributeType, bool checkError = true)
|
||||
{
|
||||
List<Type> result = new List<Type>();
|
||||
List<Type> cacheTypes = GetTypes(assemblyName);
|
||||
for (int i = 0; i < cacheTypes.Count; i++)
|
||||
{
|
||||
Type type = cacheTypes[i];
|
||||
|
||||
// 判断属性标签
|
||||
if (Attribute.IsDefined(type, attributeType))
|
||||
{
|
||||
// 判断继承关系
|
||||
if (parentType.IsAssignableFrom(type))
|
||||
{
|
||||
if (type.Name == parentType.Name)
|
||||
continue;
|
||||
result.Add(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(checkError)
|
||||
throw new Exception($"class {type} must inherit from {parentType}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字符串工具类
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system",
|
||||
"author": {
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
他们帮忙协助解决了很多BUG以及提出了很多宝贵的意见!
|
||||
|
||||
- 黄色幻想
|
||||
|
||||
- 新乞丐王子
|
||||
|
||||
|
||||
- 黄色幻想 (793301844)
|
||||
- 新乞丐王子 (82470934)
|
||||
- Wales-丁 (709501148)
|
||||
- L (401419353)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user