mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 01:00:16 +00:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15dc047488 | ||
|
|
91b25400dc | ||
|
|
d316c5000a | ||
|
|
d8692c836f | ||
|
|
0a4a3d8f2e | ||
|
|
5484b604a7 | ||
|
|
66c3c4862a | ||
|
|
e9d31bbf94 | ||
|
|
55bcd502e2 | ||
|
|
9bf22f2c79 | ||
|
|
cbf142dbf8 | ||
|
|
a6e94acefb | ||
|
|
469d73d641 | ||
|
|
0d521c68bd | ||
|
|
cd62c1dd9a | ||
|
|
e6422445a6 | ||
|
|
7683746032 | ||
|
|
a25fd19bcc | ||
|
|
6675e8f171 | ||
|
|
c836dce54d | ||
|
|
f3ab8f63e7 | ||
|
|
20d2c517b2 | ||
|
|
d6a2b31d5c | ||
|
|
533f96361a | ||
|
|
09807901c0 | ||
|
|
57ae9aa18c | ||
|
|
08efcaf4c1 | ||
|
|
b221b8121a | ||
|
|
abb75fe858 | ||
|
|
4591d0b5f6 |
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,48 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.0.6] - 2022-04-26
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复工具界面显示异常在Unity2021版本下。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 操作句柄支持错误信息查询。
|
||||||
|
- 支持UniTask异步操作库。
|
||||||
|
- 优化类型搜索方式,改为全域搜索类型。
|
||||||
|
- AssetBundleGrouper窗口添加和移除Grouper支持操作回退。
|
||||||
|
|
||||||
|
## [1.0.5] - 2022-04-22
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了非主动收集的着色器没有打进统一的着色器资源包的问题。
|
||||||
|
- 修复了单个收集的资源对象没有设置依赖资源列表的问题。
|
||||||
|
- 修复Task异步加载一直等待的问题。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 资源打包的过滤文件列表增加cginc格式。
|
||||||
|
- 增加编辑器扩展的支持,第三方实现YooAsset插件。
|
||||||
|
- 优化原生文件加载逻辑,支持离线运行模式和编辑器运行模式。
|
||||||
|
- 优化场景卸载逻辑,在加载新的主场景的时候自动卸载已经加载的所有场景。
|
||||||
|
- 支持演练构建模式,在不生成资源包的情况下快速构建查看结果。
|
||||||
|
- 新增调试信息,出生场景和出生时间。
|
||||||
|
|
||||||
|
## [1.0.4] - 2022-04-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复资源清单附加版本之后引发的一个流程错误。
|
||||||
|
- 修复原生文件拷贝目录不存导致的加载失败。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 在编辑器下检测资源路径是否合法并警告。
|
||||||
|
- 完善原生文件异步加载接口。
|
||||||
|
|
||||||
## [1.0.3] - 2022-04-14
|
## [1.0.3] - 2022-04-14
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ namespace YooAsset.Editor
|
|||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
|
if (Parameters.DryRunBuild)
|
||||||
|
{
|
||||||
|
opt |= BuildAssetBundleOptions.DryRunBuild;
|
||||||
|
return opt;
|
||||||
|
}
|
||||||
|
|
||||||
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
if (Parameters.CompressOption == ECompressOption.Uncompressed)
|
||||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||||
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
else if (Parameters.CompressOption == ECompressOption.LZ4)
|
||||||
@@ -107,7 +113,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
new TaskPrepare(), //前期准备工作
|
new TaskPrepare(), //前期准备工作
|
||||||
new TaskGetBuildMap(), //获取构建列表
|
new TaskGetBuildMap(), //获取构建列表
|
||||||
new TaskBuilding(), //开始执行构建
|
new TaskBuilding(), //开始执行构建
|
||||||
|
new TaskVerifyBuildResult(), //验证构建结果
|
||||||
new TaskEncryption(), //加密资源文件
|
new TaskEncryption(), //加密资源文件
|
||||||
new TaskCreatePatchManifest(), //创建清单文件
|
new TaskCreatePatchManifest(), //创建清单文件
|
||||||
new TaskCreateReport(), //创建报告文件
|
new TaskCreateReport(), //创建报告文件
|
||||||
|
|||||||
@@ -198,8 +198,9 @@ namespace YooAsset.Editor
|
|||||||
/// 获取加密类的类型列表
|
/// 获取加密类的类型列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<Type> GetEncryptionServicesClassTypes()
|
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;
|
return classTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsCollectAsset { private set; get; }
|
public bool IsCollectAsset { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为着色器资源
|
||||||
|
/// </summary>
|
||||||
|
public bool IsShaderAsset { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 被依赖次数
|
/// 被依赖次数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,6 +59,12 @@ namespace YooAsset.Editor
|
|||||||
IsRawAsset = isRawAsset;
|
IsRawAsset = isRawAsset;
|
||||||
NotWriteToAssetList = notWriteToAssetList;
|
NotWriteToAssetList = notWriteToAssetList;
|
||||||
IsCollectAsset = true;
|
IsCollectAsset = true;
|
||||||
|
|
||||||
|
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
|
IsShaderAsset = true;
|
||||||
|
else
|
||||||
|
IsShaderAsset = false;
|
||||||
}
|
}
|
||||||
public BuildAssetInfo(string assetPath)
|
public BuildAssetInfo(string assetPath)
|
||||||
{
|
{
|
||||||
@@ -61,6 +72,12 @@ namespace YooAsset.Editor
|
|||||||
IsRawAsset = false;
|
IsRawAsset = false;
|
||||||
NotWriteToAssetList = true;
|
NotWriteToAssetList = true;
|
||||||
IsCollectAsset = false;
|
IsCollectAsset = false;
|
||||||
|
|
||||||
|
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
|
IsShaderAsset = true;
|
||||||
|
else
|
||||||
|
IsShaderAsset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,7 +99,7 @@ namespace YooAsset.Editor
|
|||||||
if (string.IsNullOrEmpty(BundleName) == false)
|
if (string.IsNullOrEmpty(BundleName) == false)
|
||||||
throw new System.Exception("Should never get here !");
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -99,7 +116,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加资源分类标签
|
/// 添加资源分类标签
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddAssetTag(string tag)
|
public void AddAssetTag(string tag)
|
||||||
{
|
{
|
||||||
if (AssetTags.Contains(tag) == false)
|
if (AssetTags.Contains(tag) == false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
if (buildAssetDic.ContainsKey(collectAssetInfo.AssetPath) == false)
|
||||||
{
|
{
|
||||||
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset, collectAssetInfo.NotWriteToAssetList);
|
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.AssetPath, collectAssetInfo.IsRawAsset, collectAssetInfo.NotWriteToAssetList);
|
||||||
buildAssetInfo.SetBundleName(collectAssetInfo.BundleName);
|
buildAssetInfo.SetBundleName(collectAssetInfo.BundleName);
|
||||||
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
|
||||||
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
buildAssetDic.Add(collectAssetInfo.AssetPath, buildAssetInfo);
|
||||||
@@ -78,6 +78,13 @@ namespace YooAsset.Editor
|
|||||||
var buildAssetInfo = pair.Value;
|
var buildAssetInfo = pair.Value;
|
||||||
if (buildAssetInfo.IsCollectAsset)
|
if (buildAssetInfo.IsCollectAsset)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.IsShaderAsset)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (buildAssetInfo.DependCount == 0)
|
if (buildAssetInfo.DependCount == 0)
|
||||||
removeList.Add(buildAssetInfo);
|
removeList.Add(buildAssetInfo);
|
||||||
}
|
}
|
||||||
@@ -93,9 +100,17 @@ namespace YooAsset.Editor
|
|||||||
var buildAssetInfo = pair.Value;
|
var buildAssetInfo = pair.Value;
|
||||||
if (buildAssetInfo.BundleNameIsValid() == false)
|
if (buildAssetInfo.BundleNameIsValid() == false)
|
||||||
{
|
{
|
||||||
string bundleName = defaultPackRule.GetBundleName(new PackRuleData(buildAssetInfo.AssetPath));
|
string shaderBundleName = AssetBundleCollector.CollectShaderBundleName(buildAssetInfo.AssetPath);
|
||||||
bundleName = AssetBundleCollector.RevisedBundleName(bundleName, false);
|
if (string.IsNullOrEmpty(shaderBundleName) == false)
|
||||||
buildAssetInfo.SetBundleName(bundleName);
|
{
|
||||||
|
buildAssetInfo.SetBundleName(shaderBundleName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string bundleName = defaultPackRule.GetBundleName(new PackRuleData(buildAssetInfo.AssetPath));
|
||||||
|
bundleName = AssetBundleCollector.CorrectBundleName(bundleName, false);
|
||||||
|
buildAssetInfo.SetBundleName(bundleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ namespace YooAsset.Editor
|
|||||||
public IEncryptionServices EncryptionServices;
|
public IEncryptionServices EncryptionServices;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 演练构建模式
|
||||||
|
/// </summary>
|
||||||
|
public bool DryRunBuild;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 强制重新构建整个项目,如果为FALSE则是增量打包
|
/// 强制重新构建整个项目,如果为FALSE则是增量打包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace YooAsset.Editor
|
|||||||
public string EncryptionServicesClassName;
|
public string EncryptionServicesClassName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
public bool DryRunBuild;
|
||||||
public bool ForceRebuild;
|
public bool ForceRebuild;
|
||||||
public string BuildinTags;
|
public string BuildinTags;
|
||||||
public ECompressOption CompressOption;
|
public ECompressOption CompressOption;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Build task {task.GetType().Name} failed : {e}");
|
Debug.LogError($"Build task {task.GetType().Name} failed !");
|
||||||
|
Debug.LogError($"Detail error : {e}");
|
||||||
succeed = false;
|
succeed = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,164 +31,29 @@ namespace YooAsset.Editor
|
|||||||
context.SetContextObject(unityManifestContext);
|
context.SetContextObject(unityManifestContext);
|
||||||
|
|
||||||
// 拷贝原生文件
|
// 拷贝原生文件
|
||||||
|
if (buildParametersContext.Parameters.DryRunBuild == false)
|
||||||
|
{
|
||||||
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 拷贝原生文件
|
||||||
|
/// </summary>
|
||||||
|
private void CopyRawBundle(BuildMapContext buildMapContext, AssetBundleBuilder.BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
if (bundleInfo.IsRawFile)
|
if (bundleInfo.IsRawFile)
|
||||||
{
|
{
|
||||||
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
string dest = $"{buildParametersContext.PipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||||
foreach(var buildAsset in bundleInfo.BuildinAssets)
|
foreach (var buildAsset in bundleInfo.BuildinAssets)
|
||||||
{
|
{
|
||||||
if(buildAsset.IsRawAsset)
|
if (buildAsset.IsRawAsset)
|
||||||
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
EditorTools.CopyFile(buildAsset.AssetPath, dest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证构建结果
|
|
||||||
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
|
||||||
{
|
|
||||||
VerifyingBuildingResult(context, unityManifest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 验证构建结果
|
|
||||||
/// </summary>
|
|
||||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
|
||||||
{
|
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
|
||||||
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
|
||||||
List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length);
|
|
||||||
foreach(var bundleInfo in buildMapContext.BundleInfos)
|
|
||||||
{
|
|
||||||
if (bundleInfo.IsRawFile == false)
|
|
||||||
expectBundles.Add(bundleInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 验证数量
|
|
||||||
if (buildedBundles.Length != expectBundles.Count)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"构建过程中可能存在无效的资源,导致和预期构建的Bundle数量不一致!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 正向验证Bundle
|
|
||||||
foreach (var bundleName in buildedBundles)
|
|
||||||
{
|
|
||||||
if (buildMapContext.IsContainsBundle(bundleName) == false)
|
|
||||||
{
|
|
||||||
throw new Exception($"Should never get here !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 反向验证Bundle
|
|
||||||
bool isPass = true;
|
|
||||||
foreach (var expectBundle in expectBundles)
|
|
||||||
{
|
|
||||||
bool isMatch = false;
|
|
||||||
foreach (var buildedBundle in buildedBundles)
|
|
||||||
{
|
|
||||||
if (buildedBundle == expectBundle.BundleName)
|
|
||||||
{
|
|
||||||
isMatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isMatch == false)
|
|
||||||
{
|
|
||||||
isPass = false;
|
|
||||||
Debug.LogWarning($"没有找到预期构建的Bundle文件 : {expectBundle.BundleName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(isPass == false)
|
|
||||||
{
|
|
||||||
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 验证Asset
|
|
||||||
int progressValue = 0;
|
|
||||||
foreach (var buildedBundle in buildedBundles)
|
|
||||||
{
|
|
||||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{buildedBundle}";
|
|
||||||
string[] allBuildinAssetPaths = GetAssetBundleAllAssets(filePath);
|
|
||||||
string[] expectBuildinAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
|
||||||
if (expectBuildinAssetPaths.Length != allBuildinAssetPaths.Length)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
|
||||||
isPass = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var buildinAssetPath in allBuildinAssetPaths)
|
|
||||||
{
|
|
||||||
var guid = AssetDatabase.AssetPathToGUID(buildinAssetPath);
|
|
||||||
if (string.IsNullOrEmpty(guid))
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"无效的资源路径,请检查路径是否带有特殊符号或中文:{buildinAssetPath}");
|
|
||||||
isPass = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMatch = false;
|
|
||||||
foreach (var exceptBuildAssetPath in expectBuildinAssetPaths)
|
|
||||||
{
|
|
||||||
var guidExcept = AssetDatabase.AssetPathToGUID(exceptBuildAssetPath);
|
|
||||||
if (guid == guidExcept)
|
|
||||||
{
|
|
||||||
isMatch = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isMatch == false)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"在构建的Bundle文件里发现了没有匹配的资源对象:{buildinAssetPath}");
|
|
||||||
isPass = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorTools.DisplayProgressBar("验证构建结果", ++progressValue, buildedBundles.Length);
|
|
||||||
}
|
|
||||||
EditorTools.ClearProgressBar();
|
|
||||||
if (isPass == false)
|
|
||||||
{
|
|
||||||
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 卸载所有加载的Bundle
|
|
||||||
Debug.Log("构建结果验证成功!");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 解析.manifest文件并获取资源列表
|
|
||||||
/// </summary>
|
|
||||||
private string[] GetAssetBundleAllAssets(string filePath)
|
|
||||||
{
|
|
||||||
string manifestFilePath = $"{filePath}.manifest";
|
|
||||||
List<string> assetLines = new List<string>();
|
|
||||||
using (StreamReader reader = File.OpenText(manifestFilePath))
|
|
||||||
{
|
|
||||||
string content;
|
|
||||||
bool findTarget = false;
|
|
||||||
while (null != (content = reader.ReadLine()))
|
|
||||||
{
|
|
||||||
if (content.StartsWith("Dependencies:"))
|
|
||||||
break;
|
|
||||||
if (findTarget == false && content.StartsWith("Assets:"))
|
|
||||||
findTarget = true;
|
|
||||||
if (findTarget)
|
|
||||||
{
|
|
||||||
if (content.StartsWith("- "))
|
|
||||||
{
|
|
||||||
string assetPath = content.TrimStart("- ".ToCharArray());
|
|
||||||
assetLines.Add(assetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return assetLines.ToArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
// 注意:我们只有在强制重建的时候才会拷贝
|
// 注意:我们只有在强制重建的时候才会拷贝
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
if (buildParameters.Parameters.ForceRebuild)
|
if (buildParameters.Parameters.DryRunBuild == false && buildParameters.Parameters.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||||
|
|||||||
@@ -62,14 +62,14 @@ namespace YooAsset.Editor
|
|||||||
// 内置标记列表
|
// 内置标记列表
|
||||||
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
||||||
|
|
||||||
|
bool dryRunBuild = buildParameters.Parameters.DryRunBuild;
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
var bundleName = bundleInfo.BundleName;
|
var bundleName = bundleInfo.BundleName;
|
||||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
||||||
string hash = HashUtility.FileMD5(filePath);
|
string hash = GetFileHash(filePath, dryRunBuild);
|
||||||
string crc32 = HashUtility.FileCRC32(filePath);
|
string crc32 = GetFileCRC(filePath, dryRunBuild);
|
||||||
long size = FileUtility.GetFileSize(filePath);
|
long size = GetFileSize(filePath, dryRunBuild);
|
||||||
int version = buildParameters.Parameters.BuildVersion;
|
|
||||||
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
||||||
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
bool isEncrypted = encryptionContext.IsEncryptFile(bundleName);
|
||||||
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
bool isBuildin = IsBuildinBundle(tags, buildinTags);
|
||||||
@@ -101,6 +101,27 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
private string GetFileHash(string filePath, bool dryRunBuild)
|
||||||
|
{
|
||||||
|
if (dryRunBuild)
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
else
|
||||||
|
return HashUtility.FileMD5(filePath);
|
||||||
|
}
|
||||||
|
private string GetFileCRC(string filePath, bool dryRunBuild)
|
||||||
|
{
|
||||||
|
if (dryRunBuild)
|
||||||
|
return "00000000"; //8位
|
||||||
|
else
|
||||||
|
return HashUtility.FileCRC32(filePath);
|
||||||
|
}
|
||||||
|
private long GetFileSize(string filePath, bool dryRunBuild)
|
||||||
|
{
|
||||||
|
if (dryRunBuild)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return FileUtility.GetFileSize(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源列表
|
/// 获取资源列表
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
CopyPatchFiles(buildParameters);
|
if (buildParameters.Parameters.DryRunBuild == false)
|
||||||
|
{
|
||||||
|
CopyPatchFiles(buildParameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
buildReport.Summary.ShadersBundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
buildReport.Summary.EncryptionServicesClassName = buildParameters.Parameters.EncryptionServices == null ?
|
||||||
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
"null" : buildParameters.Parameters.EncryptionServices.GetType().FullName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
buildReport.Summary.DryRunBuild = buildParameters.Parameters.DryRunBuild;
|
||||||
buildReport.Summary.ForceRebuild = buildParameters.Parameters.ForceRebuild;
|
buildReport.Summary.ForceRebuild = buildParameters.Parameters.ForceRebuild;
|
||||||
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
buildReport.Summary.BuildinTags = buildParameters.Parameters.BuildinTags;
|
||||||
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
buildReport.Summary.CompressOption = buildParameters.Parameters.CompressOption;
|
||||||
|
|||||||
@@ -26,9 +26,18 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
EncryptionContext encryptionContext = new EncryptionContext();
|
if (buildParameters.Parameters.DryRunBuild)
|
||||||
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
{
|
||||||
context.SetContextObject(encryptionContext);
|
EncryptionContext encryptionContext = new EncryptionContext();
|
||||||
|
encryptionContext.EncryptList = new List<string>();
|
||||||
|
context.SetContextObject(encryptionContext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EncryptionContext encryptionContext = new EncryptionContext();
|
||||||
|
encryptionContext.EncryptList = EncryptFiles(buildParameters, buildMapContext);
|
||||||
|
context.SetContextObject(encryptionContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.IO;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskVerifyBuildResult : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
|
var unityManifestContext = context.GetContextObject<TaskBuilding.UnityManifestContext>();
|
||||||
|
|
||||||
|
// 验证构建结果
|
||||||
|
if (buildParametersContext.Parameters.VerifyBuildingResult)
|
||||||
|
{
|
||||||
|
VerifyingBuildingResult(context, unityManifestContext.UnityManifest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证构建结果
|
||||||
|
/// </summary>
|
||||||
|
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
string[] buildedBundles = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
|
// 1. 过滤掉原生Bundle
|
||||||
|
List<BuildBundleInfo> expectBundles = new List<BuildBundleInfo>(buildedBundles.Length);
|
||||||
|
foreach(var bundleInfo in buildMapContext.BundleInfos)
|
||||||
|
{
|
||||||
|
if (bundleInfo.IsRawFile == false)
|
||||||
|
expectBundles.Add(bundleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 验证数量
|
||||||
|
if (buildedBundles.Length != expectBundles.Count)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"构建过程中可能存在无效的资源,导致和预期构建的Bundle数量不一致!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 正向验证Bundle
|
||||||
|
foreach (var bundleName in buildedBundles)
|
||||||
|
{
|
||||||
|
if (buildMapContext.IsContainsBundle(bundleName) == false)
|
||||||
|
{
|
||||||
|
throw new Exception($"Should never get here !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 反向验证Bundle
|
||||||
|
bool isPass = true;
|
||||||
|
foreach (var expectBundle in expectBundles)
|
||||||
|
{
|
||||||
|
bool isMatch = false;
|
||||||
|
foreach (var buildedBundle in buildedBundles)
|
||||||
|
{
|
||||||
|
if (buildedBundle == expectBundle.BundleName)
|
||||||
|
{
|
||||||
|
isMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMatch == false)
|
||||||
|
{
|
||||||
|
isPass = false;
|
||||||
|
Debug.LogWarning($"没有找到预期构建的Bundle文件 : {expectBundle.BundleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isPass == false)
|
||||||
|
{
|
||||||
|
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 验证Asset
|
||||||
|
if(buildParameters.Parameters.DryRunBuild == false)
|
||||||
|
{
|
||||||
|
int progressValue = 0;
|
||||||
|
foreach (var buildedBundle in buildedBundles)
|
||||||
|
{
|
||||||
|
string filePath = $"{buildParameters.PipelineOutputDirectory}/{buildedBundle}";
|
||||||
|
string[] allBuildinAssetPaths = GetAssetBundleAllAssets(filePath);
|
||||||
|
string[] expectBuildinAssetPaths = buildMapContext.GetBuildinAssetPaths(buildedBundle);
|
||||||
|
if (expectBuildinAssetPaths.Length != allBuildinAssetPaths.Length)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"构建的Bundle文件内的资源对象数量和预期不匹配 : {buildedBundle}");
|
||||||
|
isPass = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var buildinAssetPath in allBuildinAssetPaths)
|
||||||
|
{
|
||||||
|
var guid = AssetDatabase.AssetPathToGUID(buildinAssetPath);
|
||||||
|
if (string.IsNullOrEmpty(guid))
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"无效的资源路径,请检查路径是否带有特殊符号或中文:{buildinAssetPath}");
|
||||||
|
isPass = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isMatch = false;
|
||||||
|
foreach (var exceptBuildAssetPath in expectBuildinAssetPaths)
|
||||||
|
{
|
||||||
|
var guidExcept = AssetDatabase.AssetPathToGUID(exceptBuildAssetPath);
|
||||||
|
if (guid == guidExcept)
|
||||||
|
{
|
||||||
|
isMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isMatch == false)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"在构建的Bundle文件里发现了没有匹配的资源对象:{buildinAssetPath}");
|
||||||
|
isPass = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorTools.DisplayProgressBar("验证构建结果", ++progressValue, buildedBundles.Length);
|
||||||
|
}
|
||||||
|
EditorTools.ClearProgressBar();
|
||||||
|
if (isPass == false)
|
||||||
|
{
|
||||||
|
throw new Exception("构建结果验证没有通过,请参考警告日志!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 卸载所有加载的Bundle
|
||||||
|
Debug.Log("构建结果验证成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析.manifest文件并获取资源列表
|
||||||
|
/// </summary>
|
||||||
|
private string[] GetAssetBundleAllAssets(string filePath)
|
||||||
|
{
|
||||||
|
string manifestFilePath = $"{filePath}.manifest";
|
||||||
|
List<string> assetLines = new List<string>();
|
||||||
|
using (StreamReader reader = File.OpenText(manifestFilePath))
|
||||||
|
{
|
||||||
|
string content;
|
||||||
|
bool findTarget = false;
|
||||||
|
while (null != (content = reader.ReadLine()))
|
||||||
|
{
|
||||||
|
if (content.StartsWith("Dependencies:"))
|
||||||
|
break;
|
||||||
|
if (findTarget == false && content.StartsWith("Assets:"))
|
||||||
|
findTarget = true;
|
||||||
|
if (findTarget)
|
||||||
|
{
|
||||||
|
if (content.StartsWith("- "))
|
||||||
|
{
|
||||||
|
string assetPath = content.TrimStart("- ".ToCharArray());
|
||||||
|
assetLines.Add(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return assetLines.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b883ac0c3c25e8143847a9326e2961cf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -58,7 +58,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
_debugReport = debugReport;
|
||||||
_assetListView.Clear();
|
_assetListView.Clear();
|
||||||
|
_assetListView.ClearSelection();
|
||||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||||
|
_assetListView.Rebuild();
|
||||||
}
|
}
|
||||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
@@ -114,7 +116,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 100;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +126,26 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 150;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label4";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 100;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label5";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 120;
|
label.style.width = 120;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
@@ -139,9 +161,17 @@ namespace YooAsset.Editor
|
|||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = providerInfo.AssetPath;
|
label1.text = providerInfo.AssetPath;
|
||||||
|
|
||||||
// Ref Count
|
// Spawn Scene
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = providerInfo.RefCount.ToString();
|
label2.text = providerInfo.SpawnScene;
|
||||||
|
|
||||||
|
// Spawn Time
|
||||||
|
var label3 = element.Q<Label>("Label3");
|
||||||
|
label3.text = providerInfo.SpawnTime;
|
||||||
|
|
||||||
|
// Ref Count
|
||||||
|
var label4 = element.Q<Label>("Label4");
|
||||||
|
label4.text = providerInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
@@ -149,9 +179,9 @@ namespace YooAsset.Editor
|
|||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = label1.style.color;
|
textColor = label1.style.color;
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label3.text = providerInfo.Status.ToString();
|
label5.text = providerInfo.Status.ToString();
|
||||||
label3.style.color = textColor;
|
label5.style.color = textColor;
|
||||||
}
|
}
|
||||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
{
|
{
|
||||||
@@ -222,6 +252,7 @@ namespace YooAsset.Editor
|
|||||||
_dependListView.Clear();
|
_dependListView.Clear();
|
||||||
_dependListView.ClearSelection();
|
_dependListView.ClearSelection();
|
||||||
_dependListView.itemsSource = providerInfo.BundleInfos;
|
_dependListView.itemsSource = providerInfo.BundleInfos;
|
||||||
|
_dependListView.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar3" style="width: 120px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
|
<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>
|
</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>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
@@ -13,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="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:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</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>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -58,21 +58,23 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
_debugReport = debugReport;
|
||||||
_bundleListView.Clear();
|
_bundleListView.Clear();
|
||||||
|
_bundleListView.ClearSelection();
|
||||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||||
|
_bundleListView.Rebuild();
|
||||||
}
|
}
|
||||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||||
{
|
{
|
||||||
Dictionary<string, DebugBundleInfo> result = new Dictionary<string, DebugBundleInfo>(debugReport.ProviderInfos.Count);
|
Dictionary<string, DebugBundleInfo> result = new Dictionary<string, DebugBundleInfo>(debugReport.ProviderInfos.Count);
|
||||||
foreach (var providerInfo in debugReport.ProviderInfos)
|
foreach (var providerInfo in debugReport.ProviderInfos)
|
||||||
{
|
{
|
||||||
foreach(var bundleInfo in providerInfo.BundleInfos)
|
foreach (var bundleInfo in providerInfo.BundleInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(result.ContainsKey(bundleInfo.BundleName) == false)
|
if (result.ContainsKey(bundleInfo.BundleName) == false)
|
||||||
result.Add(bundleInfo.BundleName, bundleInfo);
|
result.Add(bundleInfo.BundleName, bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ namespace YooAsset.Editor
|
|||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 顶部列表相关
|
// 顶部列表相关
|
||||||
private VisualElement MakeAssetListViewItem()
|
private VisualElement MakeAssetListViewItem()
|
||||||
{
|
{
|
||||||
@@ -188,7 +190,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 100;
|
label.style.width = 150;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,10 +200,30 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 150;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label4";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 100;
|
label.style.width = 100;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Label5";
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
label.style.marginLeft = 3f;
|
||||||
|
//label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 120;
|
||||||
|
element.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||||
@@ -213,32 +235,41 @@ namespace YooAsset.Editor
|
|||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = providerInfo.AssetPath;
|
label1.text = providerInfo.AssetPath;
|
||||||
|
|
||||||
// Ref Count
|
// Spawn Scene
|
||||||
var label2 = element.Q<Label>("Label2");
|
var label2 = element.Q<Label>("Label2");
|
||||||
label2.text = providerInfo.RefCount.ToString();
|
label2.text = providerInfo.SpawnScene;
|
||||||
|
|
||||||
|
// Spawn Time
|
||||||
|
var label3 = element.Q<Label>("Label3");
|
||||||
|
label3.text = providerInfo.SpawnTime;
|
||||||
|
|
||||||
|
// Ref Count
|
||||||
|
var label4 = element.Q<Label>("Label4");
|
||||||
|
label4.text = providerInfo.RefCount.ToString();
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label3.text = providerInfo.Status.ToString();
|
label5.text = providerInfo.Status.ToString();
|
||||||
}
|
}
|
||||||
private void FillUsingListView(string bundleName)
|
private void FillUsingListView(string bundleName)
|
||||||
{
|
{
|
||||||
_usingListView.Clear();
|
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||||
_usingListView.ClearSelection();
|
foreach (var providerInfo in _debugReport.ProviderInfos)
|
||||||
|
|
||||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
|
||||||
foreach(var providerInfo in _debugReport.ProviderInfos)
|
|
||||||
{
|
{
|
||||||
foreach(var bundleInfo in providerInfo.BundleInfos)
|
foreach (var bundleInfo in providerInfo.BundleInfos)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == bundleName)
|
if (bundleInfo.BundleName == bundleName)
|
||||||
{
|
{
|
||||||
source.Add(providerInfo);
|
source.Add(providerInfo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_usingListView.Clear();
|
||||||
|
_usingListView.ClearSelection();
|
||||||
_usingListView.itemsSource = source;
|
_usingListView.itemsSource = source;
|
||||||
|
_usingListView.Rebuild();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,16 @@
|
|||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
<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:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</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>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Using Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Using Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="BottomBar2" style="width: 150px; -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:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="BottomBar3" style="width: 150px; -unity-text-align: middle-left;" />
|
||||||
|
<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>
|
</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>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetTags = string.Empty;
|
public string AssetTags = string.Empty;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
public object UserData;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测配置错误
|
/// 检测配置错误
|
||||||
@@ -94,6 +97,7 @@ namespace YooAsset.Editor
|
|||||||
string bundleName = GetBundleName(grouper, assetPath, isRawAsset);
|
string bundleName = GetBundleName(grouper, assetPath, isRawAsset);
|
||||||
List<string> assetTags = GetAssetTags(grouper);
|
List<string> assetTags = GetAssetTags(grouper);
|
||||||
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
var collectAssetInfo = new CollectAssetInfo(bundleName, assetPath, assetTags, isRawAsset, NotWriteToAssetList);
|
||||||
|
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||||
result.Add(assetPath, collectAssetInfo);
|
result.Add(assetPath, collectAssetInfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -120,7 +124,7 @@ namespace YooAsset.Editor
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
string ext = System.IO.Path.GetExtension(assetPath);
|
string ext = System.IO.Path.GetExtension(assetPath);
|
||||||
if (ext == "" || ext == ".dll" || ext == ".cs" || ext == ".js" || ext == ".boo" || ext == ".meta")
|
if (ext == "" || ext == ".dll" || ext == ".cs" || ext == ".js" || ext == ".boo" || ext == ".meta" || ext == ".cginc")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -141,22 +145,15 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private string GetBundleName(AssetBundleGrouper grouper, string assetPath, bool isRawAsset)
|
private string GetBundleName(AssetBundleGrouper grouper, string assetPath, bool isRawAsset)
|
||||||
{
|
{
|
||||||
// 如果收集全路径着色器
|
string shaderBundleName = CollectShaderBundleName(assetPath);
|
||||||
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
if (string.IsNullOrEmpty(shaderBundleName) == false)
|
||||||
{
|
return shaderBundleName;
|
||||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
if (assetType == typeof(UnityEngine.Shader))
|
|
||||||
{
|
|
||||||
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
|
||||||
return RevisedBundleName(bundleName, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 根据规则设置获取资源包名称
|
// 根据规则设置获取资源包名称
|
||||||
{
|
{
|
||||||
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
IPackRule packRuleInstance = AssetBundleGrouperSettingData.GetPackRuleInstance(PackRuleName);
|
||||||
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
string bundleName = packRuleInstance.GetBundleName(new PackRuleData(assetPath, CollectPath, grouper.GrouperName));
|
||||||
return RevisedBundleName(bundleName, isRawAsset);
|
return CorrectBundleName(bundleName, isRawAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
private List<string> GetAssetTags(AssetBundleGrouper grouper)
|
||||||
@@ -182,11 +179,28 @@ namespace YooAsset.Editor
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 收集着色器的资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public static string CollectShaderBundleName(string assetPath)
|
||||||
|
{
|
||||||
|
// 如果自动收集所有的着色器
|
||||||
|
if (AssetBundleGrouperSettingData.Setting.AutoCollectShaders)
|
||||||
|
{
|
||||||
|
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||||
|
if (assetType == typeof(UnityEngine.Shader))
|
||||||
|
{
|
||||||
|
string bundleName = AssetBundleGrouperSettingData.Setting.ShadersBundleName;
|
||||||
|
return CorrectBundleName(bundleName, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 修正资源包名
|
/// 修正资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string RevisedBundleName(string bundleName, bool isRawBundle)
|
public static string CorrectBundleName(string bundleName, bool isRawBundle)
|
||||||
{
|
{
|
||||||
if (isRawBundle)
|
if (isRawBundle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
@@ -110,7 +111,9 @@ namespace YooAsset.Editor
|
|||||||
typeof(PackGrouper),
|
typeof(PackGrouper),
|
||||||
typeof(PackRawFile),
|
typeof(PackRawFile),
|
||||||
};
|
};
|
||||||
var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IPackRule));
|
|
||||||
|
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IPackRule>();
|
||||||
|
var customTypes = collection.ToList();
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
@@ -134,7 +137,9 @@ namespace YooAsset.Editor
|
|||||||
typeof(CollectPrefab),
|
typeof(CollectPrefab),
|
||||||
typeof(CollectSprite)
|
typeof(CollectSprite)
|
||||||
};
|
};
|
||||||
var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IFilterRule));
|
|
||||||
|
TypeCache.TypeCollection collection = TypeCache.GetTypesDerivedFrom<IFilterRule>();
|
||||||
|
var customTypes = collection.ToList();
|
||||||
types.AddRange(customTypes);
|
types.AddRange(customTypes);
|
||||||
for (int i = 0; i < types.Count; i++)
|
for (int i = 0; i < types.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
|||||||
private List<string> _packRuleList;
|
private List<string> _packRuleList;
|
||||||
private List<string> _filterRuleList;
|
private List<string> _filterRuleList;
|
||||||
private ListView _grouperListView;
|
private ListView _grouperListView;
|
||||||
private ListView _collectorListView;
|
private ScrollView _collectorScrollView;
|
||||||
private Toggle _autoCollectShaderToogle;
|
private Toggle _autoCollectShaderToogle;
|
||||||
private TextField _shaderBundleNameTxt;
|
private TextField _shaderBundleNameTxt;
|
||||||
private TextField _grouperNameTxt;
|
private TextField _grouperNameTxt;
|
||||||
@@ -32,6 +32,9 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
public void CreateGUI()
|
public void CreateGUI()
|
||||||
{
|
{
|
||||||
|
Undo.undoRedoPerformed -= RefreshWindow;
|
||||||
|
Undo.undoRedoPerformed += RefreshWindow;
|
||||||
|
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleGrouperSettingData.GetPackRuleNames();
|
||||||
@@ -61,7 +64,7 @@ namespace YooAsset.Editor
|
|||||||
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
_autoCollectShaderToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
AssetBundleGrouperSettingData.ModifyShader(evt.newValue, _shaderBundleNameTxt.value);
|
||||||
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
_shaderBundleNameTxt.SetEnabled(evt.newValue);
|
||||||
});
|
});
|
||||||
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
_shaderBundleNameTxt = root.Q<TextField>("ShaderBundleName");
|
||||||
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
_shaderBundleNameTxt.RegisterValueChangedCallback(evt =>
|
||||||
@@ -126,22 +129,15 @@ namespace YooAsset.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 收集列表相关
|
// 收集列表相关
|
||||||
_collectorListView = root.Q<ListView>("CollectorListView");
|
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||||
_collectorListView.makeItem = MakeCollectorListViewItem;
|
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||||
_collectorListView.bindItem = BindCollectorListViewItem;
|
_collectorScrollView.viewDataKey = "scrollView";
|
||||||
#if UNITY_2020_1_OR_NEWER
|
|
||||||
_collectorListView.onSelectionChange += CollectorListView_onSelectionChange;
|
|
||||||
#else
|
|
||||||
_collectorListView.onSelectionChanged += CollectorListView_onSelectionChange;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 收集添加删除按钮
|
// 收集器创建按钮
|
||||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||||
{
|
{
|
||||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||||
addBtn.clicked += AddCollectorBtn_clicked;
|
addBtn.clicked += AddCollectorBtn_clicked;
|
||||||
var removeBtn = collectorAddContainer.Q<Button>("RemoveBtn");
|
|
||||||
removeBtn.clicked += RemoveCollectorBtn_clicked;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新窗体
|
// 刷新窗体
|
||||||
@@ -194,6 +190,7 @@ namespace YooAsset.Editor
|
|||||||
_grouperListView.Clear();
|
_grouperListView.Clear();
|
||||||
_grouperListView.ClearSelection();
|
_grouperListView.ClearSelection();
|
||||||
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
_grouperListView.itemsSource = AssetBundleGrouperSettingData.Setting.Groupers;
|
||||||
|
_grouperListView.Rebuild();
|
||||||
}
|
}
|
||||||
private VisualElement MakeGrouperListViewItem()
|
private VisualElement MakeGrouperListViewItem()
|
||||||
{
|
{
|
||||||
@@ -227,6 +224,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void AddGrouperBtn_clicked()
|
private void AddGrouperBtn_clicked()
|
||||||
{
|
{
|
||||||
|
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset AddGrouper");
|
||||||
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper", string.Empty, string.Empty);
|
AssetBundleGrouperSettingData.CreateGrouper("Default Grouper", string.Empty, string.Empty);
|
||||||
FillGrouperViewData();
|
FillGrouperViewData();
|
||||||
}
|
}
|
||||||
@@ -236,6 +234,8 @@ namespace YooAsset.Editor
|
|||||||
if (selectGrouper == null)
|
if (selectGrouper == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Undo.RecordObject(AssetBundleGrouperSettingData.Setting, "YooAsset RemoveGrouper");
|
||||||
|
|
||||||
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
AssetBundleGrouperSettingData.RemoveGrouper(selectGrouper);
|
||||||
FillGrouperViewData();
|
FillGrouperViewData();
|
||||||
}
|
}
|
||||||
@@ -251,13 +251,20 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
_grouperContainer.visible = true;
|
_grouperContainer.visible = true;
|
||||||
_collectorListView.Clear();
|
|
||||||
_collectorListView.ClearSelection();
|
|
||||||
_collectorListView.itemsSource = selectGrouper.Collectors;
|
|
||||||
|
|
||||||
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
_grouperNameTxt.SetValueWithoutNotify(selectGrouper.GrouperName);
|
||||||
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
_grouperDescTxt.SetValueWithoutNotify(selectGrouper.GrouperDesc);
|
||||||
_grouperAssetTagsTxt.SetValueWithoutNotify(selectGrouper.AssetTags);
|
_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()
|
private VisualElement MakeCollectorListViewItem()
|
||||||
{
|
{
|
||||||
@@ -271,11 +278,15 @@ namespace YooAsset.Editor
|
|||||||
elementBottom.style.flexDirection = FlexDirection.Row;
|
elementBottom.style.flexDirection = FlexDirection.Row;
|
||||||
element.Add(elementBottom);
|
element.Add(elementBottom);
|
||||||
|
|
||||||
|
VisualElement elementFold = new VisualElement();
|
||||||
|
elementFold.style.flexDirection = FlexDirection.Row;
|
||||||
|
element.Add(elementFold);
|
||||||
|
|
||||||
// Top VisualElement
|
// Top VisualElement
|
||||||
{
|
{
|
||||||
var objectField = new ObjectField();
|
var objectField = new ObjectField();
|
||||||
objectField.name = "ObjectField1";
|
objectField.name = "ObjectField1";
|
||||||
objectField.label = "Collect Path";
|
objectField.label = "Collecter";
|
||||||
objectField.objectType = typeof(UnityEngine.Object);
|
objectField.objectType = typeof(UnityEngine.Object);
|
||||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
objectField.style.flexGrow = 1f;
|
objectField.style.flexGrow = 1f;
|
||||||
@@ -283,6 +294,14 @@ namespace YooAsset.Editor
|
|||||||
var label = objectField.Q<Label>();
|
var label = objectField.Q<Label>();
|
||||||
label.style.minWidth = 80;
|
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
|
// Bottom VisualElement
|
||||||
{
|
{
|
||||||
@@ -336,6 +355,8 @@ namespace YooAsset.Editor
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var collector = selectGrouper.Collectors[index];
|
var collector = selectGrouper.Collectors[index];
|
||||||
|
collector.UserData = element;
|
||||||
|
|
||||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||||
if (collectObject != null)
|
if (collectObject != null)
|
||||||
collectObject.name = collector.CollectPath;
|
collectObject.name = collector.CollectPath;
|
||||||
@@ -350,6 +371,13 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove Button
|
||||||
|
var removeBtn = element.Q<Button>("Button1");
|
||||||
|
removeBtn.clicked += ()=>
|
||||||
|
{
|
||||||
|
RemoveCollectorBtn_clicked(collector);
|
||||||
|
};
|
||||||
|
|
||||||
// Pack Rule
|
// Pack Rule
|
||||||
var popupField1 = element.Q<PopupField<string>>("PopupField1");
|
var popupField1 = element.Q<PopupField<string>>("PopupField1");
|
||||||
popupField1.index = GetPackRuleIndex(collector.PackRuleName);
|
popupField1.index = GetPackRuleIndex(collector.PackRuleName);
|
||||||
@@ -386,9 +414,6 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
AssetBundleGrouperSettingData.ModifyCollector(selectGrouper, collector);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void CollectorListView_onSelectionChange(IEnumerable<object> objs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
private void AddCollectorBtn_clicked()
|
private void AddCollectorBtn_clicked()
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||||
@@ -398,16 +423,13 @@ namespace YooAsset.Editor
|
|||||||
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty, nameof(PackDirectory), nameof(CollectAll), false);
|
AssetBundleGrouperSettingData.CreateCollector(selectGrouper, string.Empty, nameof(PackDirectory), nameof(CollectAll), false);
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
}
|
}
|
||||||
private void RemoveCollectorBtn_clicked()
|
private void RemoveCollectorBtn_clicked(AssetBundleCollector selectCollector)
|
||||||
{
|
{
|
||||||
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
var selectGrouper = _grouperListView.selectedItem as AssetBundleGrouper;
|
||||||
if (selectGrouper == null)
|
if (selectGrouper == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var selectCollector = _collectorListView.selectedItem as AssetBundleCollector;
|
|
||||||
if (selectCollector == null)
|
if (selectCollector == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
AssetBundleGrouperSettingData.RemoveCollector(selectGrouper, selectCollector);
|
||||||
FillCollectorViewData();
|
FillCollectorViewData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<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: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: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="RemoveBtn" />
|
||||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
<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 Desc" name="GrouperDesc" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
<ui:TextField picking-mode="Ignore" label="Grouper Asset Tags" name="GrouperAssetTags" />
|
||||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
<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: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>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
_assetListView.Clear();
|
_assetListView.Clear();
|
||||||
|
_assetListView.ClearSelection();
|
||||||
_assetListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
_assetListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
||||||
|
_assetListView.Rebuild();
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
||||||
}
|
}
|
||||||
private List<ReportAssetInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
private List<ReportAssetInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
||||||
@@ -201,6 +203,7 @@ namespace YooAsset.Editor
|
|||||||
_dependListView.Clear();
|
_dependListView.Clear();
|
||||||
_dependListView.ClearSelection();
|
_dependListView.ClearSelection();
|
||||||
_dependListView.itemsSource = bundles;
|
_dependListView.itemsSource = bundles;
|
||||||
|
_dependListView.Rebuild();
|
||||||
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
||||||
}
|
}
|
||||||
private VisualElement MakeDependListViewItem()
|
private VisualElement MakeDependListViewItem()
|
||||||
@@ -234,7 +237,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 250;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,14 @@
|
|||||||
<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="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:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar3" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</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>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<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="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: 250px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</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>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
_bundleListView.Clear();
|
_bundleListView.Clear();
|
||||||
|
_bundleListView.ClearSelection();
|
||||||
_bundleListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
_bundleListView.itemsSource = FilterViewItems(buildReport, searchKeyWord);
|
||||||
|
_bundleListView.Rebuild();
|
||||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
||||||
}
|
}
|
||||||
private List<ReportBundleInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
private List<ReportBundleInfo> FilterViewItems(BuildReport buildReport, string searchKeyWord)
|
||||||
@@ -145,7 +147,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 250;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +206,7 @@ namespace YooAsset.Editor
|
|||||||
_includeListView.Clear();
|
_includeListView.Clear();
|
||||||
_includeListView.ClearSelection();
|
_includeListView.ClearSelection();
|
||||||
_includeListView.itemsSource = containsList;
|
_includeListView.itemsSource = containsList;
|
||||||
|
_includeListView.Rebuild();
|
||||||
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
||||||
}
|
}
|
||||||
private VisualElement MakeIncludeListViewItem()
|
private VisualElement MakeIncludeListViewItem()
|
||||||
@@ -237,7 +240,7 @@ namespace YooAsset.Editor
|
|||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
label.style.marginLeft = 3f;
|
label.style.marginLeft = 3f;
|
||||||
//label.style.flexGrow = 1f;
|
//label.style.flexGrow = 1f;
|
||||||
label.style.width = 250;
|
label.style.width = 280;
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,18 @@
|
|||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<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="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
<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:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</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>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Include Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Include Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left;" />
|
<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: 250px; -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>
|
</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:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -60,9 +60,8 @@ namespace YooAsset.Editor
|
|||||||
public void FillViewData(BuildReport buildReport)
|
public void FillViewData(BuildReport buildReport)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
_listView.Clear();
|
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion));
|
||||||
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildTime));
|
||||||
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
_items.Add(new ItemWrapper("构建耗时", $"{buildReport.Summary.BuildSeconds}秒"));
|
||||||
@@ -76,6 +75,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
_items.Add(new ItemWrapper("构建参数", string.Empty));
|
||||||
|
_items.Add(new ItemWrapper("DryRunBuild", $"{buildReport.Summary.DryRunBuild}"));
|
||||||
_items.Add(new ItemWrapper("ForceRebuild", $"{buildReport.Summary.ForceRebuild}"));
|
_items.Add(new ItemWrapper("ForceRebuild", $"{buildReport.Summary.ForceRebuild}"));
|
||||||
_items.Add(new ItemWrapper("BuildinTags", $"{buildReport.Summary.BuildinTags}"));
|
_items.Add(new ItemWrapper("BuildinTags", $"{buildReport.Summary.BuildinTags}"));
|
||||||
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
|
||||||
@@ -96,7 +96,10 @@ namespace YooAsset.Editor
|
|||||||
_items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));
|
_items.Add(new ItemWrapper("原生资源包总数", $"{buildReport.Summary.RawBundleTotalCount}"));
|
||||||
_items.Add(new ItemWrapper("原生资源包总大小", ConvertSize(buildReport.Summary.RawBundleTotalSize)));
|
_items.Add(new ItemWrapper("原生资源包总大小", ConvertSize(buildReport.Summary.RawBundleTotalSize)));
|
||||||
|
|
||||||
|
_listView.Clear();
|
||||||
|
_listView.ClearSelection();
|
||||||
_listView.itemsSource = _items;
|
_listView.itemsSource = _items;
|
||||||
|
_listView.Rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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="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:ToolbarButton text="参数" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</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:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#if UNITY_2019_4
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
#if UNITY_2019
|
||||||
public static partial class UnityEngine_UIElements_ListView_Extension
|
public static partial class UnityEngine_UIElements_ListView_Extension
|
||||||
{
|
{
|
||||||
public static void ClearSelection(this UnityEngine.UIElements.ListView o)
|
public static void ClearSelection(this UnityEngine.UIElements.ListView o)
|
||||||
@@ -8,5 +9,15 @@ namespace YooAsset.Editor
|
|||||||
o.selectedIndex = -1;
|
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
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
@@ -10,7 +11,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000);
|
private static readonly List<AssetBundleLoaderBase> _loaders = new List<AssetBundleLoaderBase>(1000);
|
||||||
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
||||||
|
private static readonly Dictionary<string, SceneOperationHandle> _sceneHandles = new Dictionary<string, SceneOperationHandle>(100);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在编辑器下模拟运行
|
/// 在编辑器下模拟运行
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -81,7 +83,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_providers[i].CanDestroy())
|
if (_providers[i].CanDestroy())
|
||||||
{
|
{
|
||||||
_providers[i].Destory();
|
_providers[i].Destroy();
|
||||||
_providers.RemoveAt(i);
|
_providers.RemoveAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +114,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
provider.Destory();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
_providers.Clear();
|
_providers.Clear();
|
||||||
|
|
||||||
@@ -127,23 +129,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载原生文件
|
|
||||||
/// </summary>
|
|
||||||
public static RawFileOperation LoadRawFileAsync(string assetPath, string savePath)
|
|
||||||
{
|
|
||||||
string bundleName = BundleServices.GetBundleName(assetPath);
|
|
||||||
BundleInfo bundleInfo = BundleServices.GetBundleInfo(bundleName);
|
|
||||||
RawFileOperation operation = new RawFileOperation(bundleInfo, savePath);
|
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载场景
|
/// 异步加载场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
||||||
{
|
{
|
||||||
|
// 注意:场景句柄永远保持唯一
|
||||||
|
if (_sceneHandles.ContainsKey(scenePath))
|
||||||
|
return _sceneHandles[scenePath];
|
||||||
|
|
||||||
|
// 如果加载的是主场景,则卸载所有缓存的场景
|
||||||
|
if (sceneMode == LoadSceneMode.Single)
|
||||||
|
{
|
||||||
|
UnloadAllScene();
|
||||||
|
}
|
||||||
|
|
||||||
ProviderBase provider = TryGetProvider(scenePath);
|
ProviderBase provider = TryGetProvider(scenePath);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
{
|
{
|
||||||
@@ -151,9 +151,13 @@ namespace YooAsset
|
|||||||
provider = new DatabaseSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
|
provider = new DatabaseSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
|
||||||
else
|
else
|
||||||
provider = new BundledSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
|
provider = new BundledSceneProvider(scenePath, sceneMode, activateOnLoad, priority);
|
||||||
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providers.Add(provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle() as SceneOperationHandle;
|
|
||||||
|
var handle = provider.CreateHandle() as SceneOperationHandle;
|
||||||
|
_sceneHandles.Add(scenePath, handle);
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -168,6 +172,7 @@ namespace YooAsset
|
|||||||
provider = new DatabaseAssetProvider(assetPath, assetType);
|
provider = new DatabaseAssetProvider(assetPath, assetType);
|
||||||
else
|
else
|
||||||
provider = new BundledAssetProvider(assetPath, assetType);
|
provider = new BundledAssetProvider(assetPath, assetType);
|
||||||
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providers.Add(provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle() as AssetOperationHandle;
|
return provider.CreateHandle() as AssetOperationHandle;
|
||||||
@@ -185,12 +190,55 @@ namespace YooAsset
|
|||||||
provider = new DatabaseSubAssetsProvider(assetPath, assetType);
|
provider = new DatabaseSubAssetsProvider(assetPath, assetType);
|
||||||
else
|
else
|
||||||
provider = new BundledSubAssetsProvider(assetPath, assetType);
|
provider = new BundledSubAssetsProvider(assetPath, assetType);
|
||||||
|
provider.InitSpawnDebugInfo();
|
||||||
_providers.Add(provider);
|
_providers.Add(provider);
|
||||||
}
|
}
|
||||||
return provider.CreateHandle() as SubAssetsOperationHandle;
|
return provider.CreateHandle() as SubAssetsOperationHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static void UnloadSubScene(ProviderBase provider)
|
||||||
|
{
|
||||||
|
string scenePath = provider.AssetPath;
|
||||||
|
if (_sceneHandles.ContainsKey(scenePath) == false)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
|
// 释放子场景句柄
|
||||||
|
_sceneHandles[scenePath].ReleaseInternal();
|
||||||
|
_sceneHandles.Remove(scenePath);
|
||||||
|
|
||||||
|
// 卸载未被使用的资源(包括场景)
|
||||||
|
AssetSystem.UnloadUnusedAssets();
|
||||||
|
|
||||||
|
// 检验子场景是否销毁
|
||||||
|
if (provider.IsDestroyed == false)
|
||||||
|
{
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal static void UnloadAllScene()
|
||||||
|
{
|
||||||
|
// 释放所有场景句柄
|
||||||
|
foreach (var valuePair in _sceneHandles)
|
||||||
|
{
|
||||||
|
valuePair.Value.ReleaseInternal();
|
||||||
|
}
|
||||||
|
_sceneHandles.Clear();
|
||||||
|
|
||||||
|
// 卸载未被使用的资源(包括场景)
|
||||||
|
AssetSystem.UnloadUnusedAssets();
|
||||||
|
|
||||||
|
// 检验所有场景是否销毁
|
||||||
|
foreach (var provider in _providers)
|
||||||
|
{
|
||||||
|
if (provider.IsSceneProvider())
|
||||||
|
{
|
||||||
|
if (provider.IsDestroyed == false)
|
||||||
|
throw new Exception("Should never get here !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static AssetBundleLoaderBase CreateOwnerAssetBundleLoader(string assetPath)
|
internal static AssetBundleLoaderBase CreateOwnerAssetBundleLoader(string assetPath)
|
||||||
{
|
{
|
||||||
string bundleName = BundleServices.GetBundleName(assetPath);
|
string bundleName = BundleServices.GetBundleName(assetPath);
|
||||||
@@ -266,6 +314,7 @@ namespace YooAsset
|
|||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region 调试专属方法
|
#region 调试专属方法
|
||||||
internal static void GetDebugReport(DebugReport report)
|
internal static void GetDebugReport(DebugReport report)
|
||||||
{
|
{
|
||||||
@@ -277,6 +326,8 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||||
providerInfo.AssetPath = provider.AssetPath;
|
providerInfo.AssetPath = provider.AssetPath;
|
||||||
|
providerInfo.SpawnScene = provider.SpawnScene;
|
||||||
|
providerInfo.SpawnTime = provider.SpawnTime;
|
||||||
providerInfo.RefCount = provider.RefCount;
|
providerInfo.RefCount = provider.RefCount;
|
||||||
providerInfo.Status = provider.Status;
|
providerInfo.Status = provider.Status;
|
||||||
providerInfo.BundleInfos.Clear();
|
providerInfo.BundleInfos.Clear();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class AssetOperationHandle : OperationHandleBase
|
public sealed class AssetOperationHandle : OperationHandleBase
|
||||||
{
|
{
|
||||||
private System.Action<AssetOperationHandle> _callback;
|
private System.Action<AssetOperationHandle> _callback;
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,13 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public abstract class OperationHandleBase : IEnumerator
|
public abstract class OperationHandleBase : IEnumerator
|
||||||
{
|
{
|
||||||
|
private readonly string _cachedAssetPath;
|
||||||
internal ProviderBase _provider { private set; get; }
|
internal ProviderBase _provider { private set; get; }
|
||||||
|
|
||||||
internal OperationHandleBase(ProviderBase provider)
|
internal OperationHandleBase(ProviderBase provider)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
|
_cachedAssetPath = provider.AssetPath;
|
||||||
}
|
}
|
||||||
internal abstract void InvokeCallback();
|
internal abstract void InvokeCallback();
|
||||||
|
|
||||||
@@ -30,6 +32,19 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最近的错误信息
|
||||||
|
/// </summary>
|
||||||
|
public string LastError
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsValid == false)
|
||||||
|
return string.Empty;
|
||||||
|
return _provider.LastError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载进度
|
/// 加载进度
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -63,7 +78,18 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _provider != null && _provider.IsDestroyed == false;
|
if (_provider != null && _provider.IsDestroyed == false)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_provider == null)
|
||||||
|
YooLogger.Warning($"Operation handle is released : {_cachedAssetPath}");
|
||||||
|
else if (_provider.IsDestroyed)
|
||||||
|
YooLogger.Warning($"Provider is destroyed : {_cachedAssetPath}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +108,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步操作任务
|
/// 异步操作任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public System.Threading.Tasks.Task<object> Task
|
public System.Threading.Tasks.Task Task
|
||||||
{
|
{
|
||||||
get { return _provider.Task; }
|
get { return _provider.Task; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,10 +69,35 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步卸载场景
|
/// 是否为主场景
|
||||||
|
/// </summary>
|
||||||
|
public bool IsMainScene()
|
||||||
|
{
|
||||||
|
if (IsValid == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_provider is DatabaseSceneProvider)
|
||||||
|
{
|
||||||
|
var temp = _provider as DatabaseSceneProvider;
|
||||||
|
return temp.SceneMode == LoadSceneMode.Single;
|
||||||
|
}
|
||||||
|
else if (_provider is BundledSceneProvider)
|
||||||
|
{
|
||||||
|
var temp = _provider as BundledSceneProvider;
|
||||||
|
return temp.SceneMode == LoadSceneMode.Single;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步卸载子场景
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UnloadSceneOperation UnloadAsync()
|
public UnloadSceneOperation UnloadAsync()
|
||||||
{
|
{
|
||||||
|
// 如果句柄无效
|
||||||
if (IsValid == false)
|
if (IsValid == false)
|
||||||
{
|
{
|
||||||
string error = $"{nameof(SceneOperationHandle)} is invalid.";
|
string error = $"{nameof(SceneOperationHandle)} is invalid.";
|
||||||
@@ -81,54 +106,23 @@ namespace YooAsset
|
|||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProviderBase provider = _provider;
|
// 如果是主场景
|
||||||
|
if (IsMainScene())
|
||||||
// 释放场景句柄
|
|
||||||
ReleaseInternal();
|
|
||||||
|
|
||||||
// 卸载未被使用的资源(包括场景)
|
|
||||||
AssetSystem.UnloadUnusedAssets();
|
|
||||||
|
|
||||||
// 返回场景卸载异步操作类
|
|
||||||
if (provider.IsDestroyed == false)
|
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Scene can not unload. The provider not destroyed : {provider.AssetPath}");
|
string error = $"Cannot unload main scene. Use {nameof(YooAssets.LoadSceneAsync)} method to change the main scene !";
|
||||||
var operation = new UnloadSceneOperation();
|
YooLogger.Error(error);
|
||||||
|
var operation = new UnloadSceneOperation(error);
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (IsAdditiveScene(provider))
|
|
||||||
{
|
|
||||||
var operation = new UnloadSceneOperation(provider.SceneObject);
|
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var operation = new UnloadSceneOperation();
|
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsAdditiveScene(ProviderBase provider)
|
// 卸载子场景
|
||||||
{
|
Scene sceneObject = SceneObject;
|
||||||
if (provider is DatabaseSceneProvider)
|
AssetSystem.UnloadSubScene(_provider);
|
||||||
{
|
{
|
||||||
var temp = provider as DatabaseSceneProvider;
|
var operation = new UnloadSceneOperation(sceneObject);
|
||||||
return temp.SceneMode == LoadSceneMode.Additive;
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
}
|
return operation;
|
||||||
else if (provider is BundledSceneProvider)
|
|
||||||
{
|
|
||||||
var temp = provider as BundledSceneProvider;
|
|
||||||
return temp.SceneMode == LoadSceneMode.Additive;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class SubAssetsOperationHandle : OperationHandleBase
|
public sealed class SubAssetsOperationHandle : OperationHandleBase
|
||||||
{
|
{
|
||||||
private System.Action<SubAssetsOperationHandle> _callback;
|
private System.Action<SubAssetsOperationHandle> _callback;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private string _fileLoadPath;
|
||||||
private bool _isWaitForAsyncComplete = false;
|
private bool _isWaitForAsyncComplete = false;
|
||||||
private bool _isShowWaitForAsyncError = false;
|
private bool _isShowWaitForAsyncError = false;
|
||||||
private DownloaderBase _downloader;
|
private DownloaderBase _downloader;
|
||||||
@@ -38,18 +39,32 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测加载地址是否为空
|
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||||
if (string.IsNullOrEmpty(BundleFileInfo.LocalPath))
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
return;
|
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
|
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
if (string.IsNullOrEmpty(BundleFileInfo.RemoteMainURL))
|
{
|
||||||
_steps = ESteps.LoadFile;
|
|
||||||
else
|
|
||||||
_steps = ESteps.Download;
|
_steps = ESteps.Download;
|
||||||
|
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
|
||||||
|
}
|
||||||
|
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadFile;
|
||||||
|
_fileLoadPath = BundleFileInfo.GetStreamingLoadPath();
|
||||||
|
}
|
||||||
|
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadFile;
|
||||||
|
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 从服务器下载
|
// 1. 从服务器下载
|
||||||
@@ -68,9 +83,9 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_downloader.HasError())
|
if (_downloader.HasError())
|
||||||
{
|
{
|
||||||
_downloader.ReportError();
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
|
LastError = _downloader.GetLastError();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -83,11 +98,12 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||||
if (System.IO.File.Exists(BundleFileInfo.LocalPath) == false)
|
if (System.IO.File.Exists(_fileLoadPath) == false)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Not found assetBundle file : {BundleFileInfo.LocalPath}");
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"Not found assetBundle file : {_fileLoadPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -96,20 +112,20 @@ namespace YooAsset
|
|||||||
if (BundleFileInfo.IsEncrypted)
|
if (BundleFileInfo.IsEncrypted)
|
||||||
{
|
{
|
||||||
if (AssetSystem.DecryptionServices == null)
|
if (AssetSystem.DecryptionServices == null)
|
||||||
throw new Exception($"{nameof(AssetBundleFileLoader)} need IDecryptServices : {BundleFileInfo.BundleName}");
|
throw new Exception($"{nameof(AssetBundleFileLoader)} need {nameof(IDecryptionServices)} : {BundleFileInfo.BundleName}");
|
||||||
|
|
||||||
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
|
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath, 0, offset);
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath, 0, offset);
|
||||||
else
|
else
|
||||||
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath, 0, offset);
|
_cacheRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath, 0, offset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
CacheBundle = AssetBundle.LoadFromFile(BundleFileInfo.LocalPath);
|
CacheBundle = AssetBundle.LoadFromFile(_fileLoadPath);
|
||||||
else
|
else
|
||||||
_cacheRequest = AssetBundle.LoadFromFileAsync(BundleFileInfo.LocalPath);
|
_cacheRequest = AssetBundle.LoadFromFileAsync(_fileLoadPath);
|
||||||
}
|
}
|
||||||
_steps = ESteps.CheckFile;
|
_steps = ESteps.CheckFile;
|
||||||
}
|
}
|
||||||
@@ -136,9 +152,10 @@ namespace YooAsset
|
|||||||
// Check error
|
// Check error
|
||||||
if (CacheBundle == null)
|
if (CacheBundle == null)
|
||||||
{
|
{
|
||||||
YooLogger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}");
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"Failed to load assetBundle : {BundleFileInfo.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EStatus Status { protected set; get; }
|
public EStatus Status { protected set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最近的错误信息
|
||||||
|
/// </summary>
|
||||||
|
public string LastError { protected set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否已经销毁
|
/// 是否已经销毁
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -139,7 +144,7 @@ namespace YooAsset
|
|||||||
// 销毁所有Providers
|
// 销毁所有Providers
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
provider.Destory();
|
provider.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从列表里移除Providers
|
// 从列表里移除Providers
|
||||||
|
|||||||
@@ -37,19 +37,22 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
// 检测加载地址是否为空
|
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||||
if (string.IsNullOrEmpty(BundleFileInfo.LocalPath))
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
return;
|
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
|
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadFile;
|
||||||
|
_webURL = BundleFileInfo.GetStreamingLoadPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(BundleFileInfo.RemoteMainURL))
|
|
||||||
_webURL = BundleFileInfo.LocalPath;
|
|
||||||
else
|
else
|
||||||
_webURL = BundleFileInfo.RemoteMainURL;
|
{
|
||||||
_steps = ESteps.LoadFile;
|
throw new System.NotImplementedException(BundleFileInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 从服务器或缓存中获取AssetBundle文件
|
// 1. 从服务器或缓存中获取AssetBundle文件
|
||||||
@@ -73,7 +76,7 @@ namespace YooAsset
|
|||||||
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
||||||
#endif
|
#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;
|
_steps = ESteps.TryLoad;
|
||||||
_tryTimer = 0;
|
_tryTimer = 0;
|
||||||
}
|
}
|
||||||
@@ -82,9 +85,10 @@ namespace YooAsset
|
|||||||
CacheBundle = DownloadHandlerAssetBundle.GetContent(_webRequest);
|
CacheBundle = DownloadHandlerAssetBundle.GetContent(_webRequest);
|
||||||
if (CacheBundle == null)
|
if (CacheBundle == null)
|
||||||
{
|
{
|
||||||
Debug.LogError($"Get asset bundle error : {_webRequest.error}");
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
|
LastError = $"AssetBundle file is invalid : {BundleFileInfo.BundleName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||||
|
|
||||||
|
|
||||||
public DependAssetBundleGrouper(string assetPath)
|
public DependAssetBundleGrouper(string assetPath)
|
||||||
{
|
{
|
||||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||||
@@ -29,6 +30,36 @@ namespace YooAsset
|
|||||||
return true;
|
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>
|
||||||
/// 主线程等待异步操作完毕
|
/// 主线程等待异步操作完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -48,12 +48,15 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"{nameof(AssetOperationHandle)} is invalid.";
|
Error = $"{nameof(AssetOperationHandle)} is invalid.";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_handle.AssetObject == null)
|
if (_handle.AssetObject == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"{nameof(AssetOperationHandle.AssetObject)} is null.";
|
Error = $"{nameof(AssetOperationHandle.AssetObject)} is null.";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_setPositionRotation)
|
if(_setPositionRotation)
|
||||||
|
|||||||
@@ -2,39 +2,70 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class RawFileOperation : AsyncOperationBase
|
/// <summary>
|
||||||
|
/// 原生文件操作
|
||||||
|
/// </summary>
|
||||||
|
public abstract class RawFileOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
protected readonly BundleInfo _bundleInfo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件的拷贝路径
|
||||||
|
/// </summary>
|
||||||
|
public string CopyPath { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
internal RawFileOperation(BundleInfo bundleInfo, string copyPath)
|
||||||
|
{
|
||||||
|
_bundleInfo = bundleInfo;
|
||||||
|
CopyPath = copyPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件的缓存路径
|
||||||
|
/// </summary>
|
||||||
|
public abstract string GetCachePath();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取原生文件的二进制数据
|
||||||
|
/// </summary>
|
||||||
|
public byte[] GetFileData()
|
||||||
|
{
|
||||||
|
string filePath = GetCachePath();
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
return null;
|
||||||
|
return File.ReadAllBytes(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取原生文件的文本数据
|
||||||
|
/// </summary>
|
||||||
|
public string GetFileText()
|
||||||
|
{
|
||||||
|
string filePath = GetCachePath();
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
return string.Empty;
|
||||||
|
return File.ReadAllText(filePath, System.Text.Encoding.UTF8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下模拟运行的原生文件操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class EditorPlayModeRawFileOperation : RawFileOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Prepare,
|
Prepare,
|
||||||
DownloadFromWeb,
|
CheckAndCopyFile,
|
||||||
CheckDownloadFromWeb,
|
|
||||||
CheckFile,
|
|
||||||
DownloadFromApk,
|
|
||||||
CheckDownloadFromApk,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly BundleInfo _bundleInfo;
|
|
||||||
private readonly string _savePath;
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private DownloaderBase _downloader;
|
|
||||||
private UnityWebFileRequester _fileRequester;
|
|
||||||
|
|
||||||
/// <summary>
|
internal EditorPlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
||||||
/// 原生文件的存储路径
|
|
||||||
/// </summary>
|
|
||||||
public string SavePath
|
|
||||||
{
|
{
|
||||||
get { return _savePath; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
internal RawFileOperation(BundleInfo bundleInfo, string savePath)
|
|
||||||
{
|
|
||||||
_bundleInfo = bundleInfo;
|
|
||||||
_savePath = savePath;
|
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -48,19 +79,250 @@ namespace YooAsset
|
|||||||
// 1. 准备工作
|
// 1. 准备工作
|
||||||
if (_steps == ESteps.Prepare)
|
if (_steps == ESteps.Prepare)
|
||||||
{
|
{
|
||||||
// 检测加载地址是否为空
|
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||||
if (string.IsNullOrEmpty(_bundleInfo.LocalPath))
|
{
|
||||||
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
|
return; // 模拟实现异步操作
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(_bundleInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 检测并拷贝原生文件
|
||||||
|
if (_steps == ESteps.CheckAndCopyFile)
|
||||||
|
{
|
||||||
|
// 如果不需要保存文件
|
||||||
|
if (string.IsNullOrEmpty(CopyPath))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Succeed;
|
||||||
Error = "Local path is null or empty.";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_bundleInfo.RemoteMainURL))
|
// 如果原生文件已经存在,则将其删除
|
||||||
_steps = ESteps.CheckFile;
|
if (File.Exists(CopyPath))
|
||||||
|
{
|
||||||
|
File.Delete(CopyPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileUtility.CreateFileDirectory(CopyPath);
|
||||||
|
File.Copy(GetCachePath(), CopyPath, true);
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = e.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件的缓存路径
|
||||||
|
/// </summary>
|
||||||
|
public override string GetCachePath()
|
||||||
|
{
|
||||||
|
if (_bundleInfo == null)
|
||||||
|
return string.Empty;
|
||||||
|
return _bundleInfo.BundleName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 离线模式的原生文件操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class OfflinePlayModeRawFileOperation : RawFileOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Prepare,
|
||||||
|
DownloadFromApk,
|
||||||
|
CheckDownloadFromApk,
|
||||||
|
CheckAndCopyFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private UnityWebFileRequester _fileRequester;
|
||||||
|
|
||||||
|
public OfflinePlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.Prepare;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 1. 准备工作
|
||||||
|
if (_steps == ESteps.Prepare)
|
||||||
|
{
|
||||||
|
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Bundle info is invalid : {_bundleInfo.BundleName}";
|
||||||
|
}
|
||||||
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
|
{
|
||||||
|
_steps = ESteps.DownloadFromApk;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(_bundleInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 从APK拷贝文件
|
||||||
|
if (_steps == ESteps.DownloadFromApk)
|
||||||
|
{
|
||||||
|
string downloadURL = PathHelper.ConvertToWWWPath(_bundleInfo.GetStreamingLoadPath());
|
||||||
|
_fileRequester = new UnityWebFileRequester();
|
||||||
|
_fileRequester.SendRequest(downloadURL, GetCachePath());
|
||||||
|
_steps = ESteps.CheckDownloadFromApk;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 检测APK拷贝文件结果
|
||||||
|
if (_steps == ESteps.CheckDownloadFromApk)
|
||||||
|
{
|
||||||
|
if (_fileRequester.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_fileRequester.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _fileRequester.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
|
}
|
||||||
|
_fileRequester.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 检测并拷贝原生文件
|
||||||
|
if (_steps == ESteps.CheckAndCopyFile)
|
||||||
|
{
|
||||||
|
// 如果不需要保存文件
|
||||||
|
if (string.IsNullOrEmpty(CopyPath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果原生文件已经存在,则验证其完整性
|
||||||
|
if (File.Exists(CopyPath))
|
||||||
|
{
|
||||||
|
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(CopyPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileUtility.CreateFileDirectory(CopyPath);
|
||||||
|
File.Copy(GetCachePath(), CopyPath, true);
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = e.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原生文件的缓存路径
|
||||||
|
/// </summary>
|
||||||
|
public override string GetCachePath()
|
||||||
|
{
|
||||||
|
if (_bundleInfo == null)
|
||||||
|
return string.Empty;
|
||||||
|
return _bundleInfo.GetCacheLoadPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网络模式的原生文件操作
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class HostPlayModeRawFileOperation : RawFileOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Prepare,
|
||||||
|
DownloadFromWeb,
|
||||||
|
CheckDownloadFromWeb,
|
||||||
|
DownloadFromApk,
|
||||||
|
CheckDownloadFromApk,
|
||||||
|
CheckAndCopyFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private DownloaderBase _downloader;
|
||||||
|
private UnityWebFileRequester _fileRequester;
|
||||||
|
|
||||||
|
internal HostPlayModeRawFileOperation(BundleInfo bundleInfo, string copyPath) : base(bundleInfo, copyPath)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
_steps = ESteps.Prepare;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 1. 准备工作
|
||||||
|
if (_steps == ESteps.Prepare)
|
||||||
|
{
|
||||||
|
if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.None)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Bundle info is invalid : {_bundleInfo.BundleName}";
|
||||||
|
}
|
||||||
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
|
{
|
||||||
_steps = ESteps.DownloadFromWeb;
|
_steps = ESteps.DownloadFromWeb;
|
||||||
|
}
|
||||||
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||||
|
{
|
||||||
|
_steps = ESteps.DownloadFromApk;
|
||||||
|
}
|
||||||
|
else if (_bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromCache)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(_bundleInfo.LoadMode.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 从服务器下载
|
// 2. 从服务器下载
|
||||||
@@ -85,65 +347,20 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:当文件更新之后,需要删除旧文件
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
if (File.Exists(_savePath))
|
|
||||||
File.Delete(_savePath);
|
|
||||||
_steps = ESteps.CheckFile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 检测文件
|
// 4. 从APK拷贝文件
|
||||||
if (_steps == ESteps.CheckFile)
|
|
||||||
{
|
|
||||||
// 注意:如果原生文件已经存在,则验证其完整性
|
|
||||||
if (File.Exists(_savePath))
|
|
||||||
{
|
|
||||||
bool result = DownloadSystem.CheckContentIntegrity(_savePath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
File.Delete(_savePath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_bundleInfo.IsBuildinJarFile())
|
|
||||||
{
|
|
||||||
_steps = ESteps.DownloadFromApk;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
File.Copy(_bundleInfo.LocalPath, _savePath, true);
|
|
||||||
}
|
|
||||||
catch (System.Exception e)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = e.ToString();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. 从APK拷贝文件
|
|
||||||
if (_steps == ESteps.DownloadFromApk)
|
if (_steps == ESteps.DownloadFromApk)
|
||||||
{
|
{
|
||||||
string downloadURL = PathHelper.ConvertToWWWPath(_bundleInfo.LocalPath);
|
string downloadURL = PathHelper.ConvertToWWWPath(_bundleInfo.GetStreamingLoadPath());
|
||||||
_fileRequester = new UnityWebFileRequester();
|
_fileRequester = new UnityWebFileRequester();
|
||||||
_fileRequester.SendRequest(downloadURL, _savePath);
|
_fileRequester.SendRequest(downloadURL, GetCachePath());
|
||||||
_steps = ESteps.CheckDownloadFromApk;
|
_steps = ESteps.CheckDownloadFromApk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. 检测APK拷贝文件结果
|
// 5. 检测APK拷贝文件结果
|
||||||
if (_steps == ESteps.CheckDownloadFromApk)
|
if (_steps == ESteps.CheckDownloadFromApk)
|
||||||
{
|
{
|
||||||
if (_fileRequester.IsDone() == false)
|
if (_fileRequester.IsDone() == false)
|
||||||
@@ -157,32 +374,62 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
_steps = ESteps.CheckAndCopyFile;
|
||||||
|
}
|
||||||
|
_fileRequester.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 检测并拷贝原生文件
|
||||||
|
if (_steps == ESteps.CheckAndCopyFile)
|
||||||
|
{
|
||||||
|
// 如果不需要保存文件
|
||||||
|
if (string.IsNullOrEmpty(CopyPath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果原生文件已经存在,则验证其完整性
|
||||||
|
if (File.Exists(CopyPath))
|
||||||
|
{
|
||||||
|
bool result = DownloadSystem.CheckContentIntegrity(CopyPath, _bundleInfo.SizeBytes, _bundleInfo.CRC);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(CopyPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileUtility.CreateFileDirectory(CopyPath);
|
||||||
|
File.Copy(GetCachePath(), CopyPath, true);
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
_fileRequester.Dispose();
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = e.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取原生文件的二进制数据
|
/// 原生文件的缓存路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public byte[] GetFileData()
|
public override string GetCachePath()
|
||||||
{
|
{
|
||||||
if (File.Exists(_savePath) == false)
|
if (_bundleInfo == null)
|
||||||
return null;
|
|
||||||
return File.ReadAllBytes(_savePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取原生文件的文本数据
|
|
||||||
/// </summary>
|
|
||||||
public string GetFileText()
|
|
||||||
{
|
|
||||||
if (File.Exists(_savePath) == false)
|
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
return File.ReadAllText(_savePath, System.Text.Encoding.UTF8);
|
return _bundleInfo.GetCacheLoadPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,6 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
Normal,
|
Normal,
|
||||||
Error,
|
Error,
|
||||||
Skip,
|
|
||||||
}
|
}
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -40,10 +39,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal UnloadSceneOperation()
|
|
||||||
{
|
|
||||||
_flag = EFlag.Skip;
|
|
||||||
}
|
|
||||||
internal UnloadSceneOperation(string error)
|
internal UnloadSceneOperation(string error)
|
||||||
{
|
{
|
||||||
_flag = EFlag.Error;
|
_flag = EFlag.Error;
|
||||||
@@ -60,11 +55,6 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.UnLoad;
|
_steps = ESteps.UnLoad;
|
||||||
}
|
}
|
||||||
else if (_flag == EFlag.Skip)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
else if (_flag == EFlag.Error)
|
else if (_flag == EFlag.Error)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|||||||
@@ -45,15 +45,23 @@ namespace YooAsset
|
|||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OwnerBundle.CacheBundle == null)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Loading;
|
Status = EStatus.Fail;
|
||||||
|
LastError = OwnerBundle.LastError;
|
||||||
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = EStatus.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
@@ -97,7 +105,10 @@ namespace YooAsset
|
|||||||
|
|
||||||
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
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();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ namespace YooAsset
|
|||||||
DependBundles = new DependAssetBundleGrouper(assetPath);
|
DependBundles = new DependAssetBundleGrouper(assetPath);
|
||||||
DependBundles.Reference();
|
DependBundles.Reference();
|
||||||
}
|
}
|
||||||
public override void Destory()
|
public override void Destroy()
|
||||||
{
|
{
|
||||||
base.Destory();
|
base.Destroy();
|
||||||
|
|
||||||
// 释放资源包
|
// 释放资源包
|
||||||
if (OwnerBundle != null)
|
if (OwnerBundle != null)
|
||||||
|
|||||||
@@ -46,15 +46,23 @@ namespace YooAsset
|
|||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OwnerBundle.CacheBundle == null)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Loading;
|
Status = EStatus.Fail;
|
||||||
|
LastError = OwnerBundle.LastError;
|
||||||
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = EStatus.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载场景
|
// 2. 加载场景
|
||||||
@@ -69,8 +77,9 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Failed to load scene : {AssetName}");
|
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = $"Failed to load scene : {AssetName}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,6 +94,11 @@ namespace YooAsset
|
|||||||
SceneManager.SetActiveScene(SceneObject);
|
SceneManager.SetActiveScene(SceneObject);
|
||||||
|
|
||||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||||
|
if(Status == EStatus.Fail)
|
||||||
|
{
|
||||||
|
LastError = $"The load scene is invalid : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,15 +45,23 @@ namespace YooAsset
|
|||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (OwnerBundle.CacheBundle == null)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (OwnerBundle.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
Status = EStatus.Loading;
|
Status = EStatus.Fail;
|
||||||
|
LastError = OwnerBundle.LastError;
|
||||||
|
InvokeCompletion();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = EStatus.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 加载资源对象
|
// 2. 加载资源对象
|
||||||
@@ -97,7 +105,10 @@ namespace YooAsset
|
|||||||
|
|
||||||
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
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();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = $"Not found asset : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,7 +43,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
Status = EStatus.Loading;
|
Status = EStatus.Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:模拟异步加载效果提前返回
|
// 注意:模拟异步加载效果提前返回
|
||||||
if (IsWaitForAsyncComplete == false)
|
if (IsWaitForAsyncComplete == false)
|
||||||
return;
|
return;
|
||||||
@@ -59,7 +61,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
Status = AssetObject == null ? EStatus.Fail : EStatus.Success;
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
YooLogger.Warning($"Failed to load asset object : {AssetPath}");
|
{
|
||||||
|
LastError = $"Failed to load asset object : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Failed to load scene : {AssetName}");
|
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = $"Failed to load scene : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -67,6 +68,11 @@ namespace YooAsset
|
|||||||
SceneManager.SetActiveScene(SceneObject);
|
SceneManager.SetActiveScene(SceneObject);
|
||||||
|
|
||||||
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
Status = SceneObject.IsValid() ? EStatus.Success : EStatus.Fail;
|
||||||
|
if (Status == EStatus.Fail)
|
||||||
|
{
|
||||||
|
LastError = $"The load scene is invalid : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
{
|
{
|
||||||
Status = EStatus.Fail;
|
Status = EStatus.Fail;
|
||||||
|
LastError = $"Not found asset : {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -73,7 +75,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
Status = AllAssetObjects == null ? EStatus.Fail : EStatus.Success;
|
||||||
if (Status == EStatus.Fail)
|
if (Status == EStatus.Fail)
|
||||||
YooLogger.Warning($"Failed to load sub assets : {AssetName}");
|
{
|
||||||
|
LastError = $"Failed to load sub assets : {nameof(AssetType)} in {AssetPath}";
|
||||||
|
YooLogger.Error(LastError);
|
||||||
|
}
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -51,6 +53,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EStatus Status { protected set; get; } = EStatus.None;
|
public EStatus Status { protected set; get; } = EStatus.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最近的错误信息
|
||||||
|
/// </summary>
|
||||||
|
public string LastError { protected set; get; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -103,7 +110,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 销毁资源对象
|
/// 销毁资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Destory()
|
public virtual void Destroy()
|
||||||
{
|
{
|
||||||
IsDestroyed = true;
|
IsDestroyed = true;
|
||||||
}
|
}
|
||||||
@@ -197,31 +204,22 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步操作任务
|
/// 异步操作任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public System.Threading.Tasks.Task<object> Task
|
public Task Task
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var handle = WaitHandle;
|
if (_taskCompletionSource == null)
|
||||||
return System.Threading.Tasks.Task.Factory.StartNew(o =>
|
|
||||||
{
|
{
|
||||||
handle.WaitOne();
|
_taskCompletionSource = new TaskCompletionSource<object>();
|
||||||
return AssetObject as object;
|
if (IsDone)
|
||||||
}, this);
|
_taskCompletionSource.SetResult(null);
|
||||||
|
}
|
||||||
|
return _taskCompletionSource.Task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 异步编程相关
|
#region 异步编程相关
|
||||||
private System.Threading.EventWaitHandle _waitHandle;
|
private TaskCompletionSource<object> _taskCompletionSource;
|
||||||
private System.Threading.WaitHandle WaitHandle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_waitHandle == null)
|
|
||||||
_waitHandle = new System.Threading.EventWaitHandle(false, System.Threading.EventResetMode.ManualReset);
|
|
||||||
_waitHandle.Reset();
|
|
||||||
return _waitHandle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protected void InvokeCompletion()
|
protected void InvokeCompletion()
|
||||||
{
|
{
|
||||||
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
||||||
@@ -233,7 +231,35 @@ namespace YooAsset
|
|||||||
hande.InvokeCallback();
|
hande.InvokeCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_waitHandle?.Set();
|
|
||||||
|
if (_taskCompletionSource != null)
|
||||||
|
_taskCompletionSource.TrySetResult(null);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 调试信息相关
|
||||||
|
/// <summary>
|
||||||
|
/// 出生的场景
|
||||||
|
/// </summary>
|
||||||
|
public string SpawnScene = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 出生的时间
|
||||||
|
/// </summary>
|
||||||
|
public string SpawnTime = string.Empty;
|
||||||
|
|
||||||
|
[Conditional("DEBUG")]
|
||||||
|
public void InitSpawnDebugInfo()
|
||||||
|
{
|
||||||
|
SpawnScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; ;
|
||||||
|
SpawnTime = SpawnTimeToString(UnityEngine.Time.realtimeSinceStartup);
|
||||||
|
}
|
||||||
|
private string SpawnTimeToString(float spawnTime)
|
||||||
|
{
|
||||||
|
float h = UnityEngine.Mathf.FloorToInt(spawnTime / 3600f);
|
||||||
|
float m = UnityEngine.Mathf.FloorToInt(spawnTime / 60f - h * 60f);
|
||||||
|
float s = UnityEngine.Mathf.FloorToInt(spawnTime - m * 60f - h * 3600f);
|
||||||
|
return h.ToString("00") + ":" + m.ToString("00") + ":" + s.ToString("00");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string AssetPath { set; get; }
|
public string AssetPath { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源出生的场景
|
||||||
|
/// </summary>
|
||||||
|
public string SpawnScene { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源出生的时间
|
||||||
|
/// </summary>
|
||||||
|
public string SpawnTime { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ namespace YooAsset
|
|||||||
// 创建新的下载器
|
// 创建新的下载器
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
YooLogger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
||||||
FileUtility.CreateFileDirectory(bundleInfo.LocalPath);
|
FileUtility.CreateFileDirectory(bundleInfo.GetCacheLoadPath());
|
||||||
DownloaderBase newDownloader;
|
DownloaderBase newDownloader;
|
||||||
if (bundleInfo.SizeBytes >= _breakpointResumeFileSize)
|
if (bundleInfo.SizeBytes >= _breakpointResumeFileSize)
|
||||||
newDownloader = new HttpDownloader(bundleInfo);
|
newDownloader = new HttpDownloader(bundleInfo);
|
||||||
@@ -146,7 +146,7 @@ namespace YooAsset
|
|||||||
// 验证文件完整性
|
// 验证文件完整性
|
||||||
public static bool CheckContentIntegrity(BundleInfo bundleInfo)
|
public static bool CheckContentIntegrity(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
return CheckContentIntegrity(bundleInfo.LocalPath, bundleInfo.SizeBytes, bundleInfo.CRC);
|
return CheckContentIntegrity(bundleInfo.GetCacheLoadPath(), bundleInfo.SizeBytes, bundleInfo.CRC);
|
||||||
}
|
}
|
||||||
public static bool CheckContentIntegrity(PatchBundle patchBundle)
|
public static bool CheckContentIntegrity(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,9 +50,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public void SendRequest(int failedTryAgain, int timeout)
|
public void SendRequest(int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_bundleInfo.LocalPath))
|
|
||||||
throw new System.ArgumentNullException();
|
|
||||||
|
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
_failedTryAgain = failedTryAgain;
|
_failedTryAgain = failedTryAgain;
|
||||||
@@ -62,7 +59,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public abstract void Update();
|
public abstract void Update();
|
||||||
public abstract void Abort();
|
public abstract void Abort();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取网络请求地址
|
/// 获取网络请求地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -101,19 +98,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 报告错误信息
|
/// 按照错误级别打印错误
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReportError()
|
public void ReportError()
|
||||||
{
|
{
|
||||||
YooLogger.Error($"Failed to download : {_requestURL} Error : {_lastError}");
|
YooLogger.Error(GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取最近一条错误日志
|
/// 按照警告级别打印错误
|
||||||
|
/// </summary>
|
||||||
|
public void ReportWarning()
|
||||||
|
{
|
||||||
|
YooLogger.Warning(GetLastError());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取最近发生的错误信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetLastError()
|
public string GetLastError()
|
||||||
{
|
{
|
||||||
return _lastError;
|
return $"Failed to download : {_requestURL} Error : {_lastError}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
_webRequest = new UnityWebRequest(_requestURL, UnityWebRequest.kHttpVerbGET);
|
||||||
DownloadHandlerFile handler = new DownloadHandlerFile(_bundleInfo.LocalPath);
|
DownloadHandlerFile handler = new DownloadHandlerFile(_bundleInfo.GetCacheLoadPath());
|
||||||
handler.removeFileOnAbort = true;
|
handler.removeFileOnAbort = true;
|
||||||
_webRequest.downloadHandler = handler;
|
_webRequest.downloadHandler = handler;
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
@@ -95,16 +95,21 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ReportError();
|
string cacheFilePath = _bundleInfo.GetCacheLoadPath();
|
||||||
|
if (File.Exists(cacheFilePath))
|
||||||
if (File.Exists(_bundleInfo.LocalPath))
|
File.Delete(cacheFilePath);
|
||||||
File.Delete(_bundleInfo.LocalPath);
|
|
||||||
|
|
||||||
// 失败后重新尝试
|
// 失败后重新尝试
|
||||||
if (_failedTryAgain > 0)
|
if (_failedTryAgain > 0)
|
||||||
|
{
|
||||||
|
ReportWarning();
|
||||||
_steps = ESteps.TryAgain;
|
_steps = ESteps.TryAgain;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ReportError();
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Failed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 释放下载器
|
// 释放下载器
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
_requestURL = GetRequestURL();
|
_requestURL = GetRequestURL();
|
||||||
_threadDownloader = new ThreadDownloader();
|
_threadDownloader = new ThreadDownloader();
|
||||||
_threadDownloader.Run(_requestURL, _bundleInfo.LocalPath, _bundleInfo.Hash, _bundleInfo.CRC, _bundleInfo.SizeBytes, _timeout);
|
_threadDownloader.Run(_requestURL, _bundleInfo.GetCacheLoadPath(), _bundleInfo.Hash, _bundleInfo.CRC, _bundleInfo.SizeBytes, _timeout);
|
||||||
_steps = ESteps.CheckDownload;
|
_steps = ESteps.CheckDownload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,13 +211,18 @@ namespace YooAsset
|
|||||||
if (_threadDownloader.HasError())
|
if (_threadDownloader.HasError())
|
||||||
{
|
{
|
||||||
_lastError = _threadDownloader.Error;
|
_lastError = _threadDownloader.Error;
|
||||||
ReportError();
|
|
||||||
|
|
||||||
// 失败后重新尝试
|
// 失败后重新尝试
|
||||||
if (_failedTryAgain > 0)
|
if (_failedTryAgain > 0)
|
||||||
|
{
|
||||||
|
ReportWarning();
|
||||||
_steps = ESteps.TryAgain;
|
_steps = ESteps.TryAgain;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ReportError();
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Failed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -240,7 +245,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public override void Abort()
|
public override void Abort()
|
||||||
{
|
{
|
||||||
if(IsDone() == false)
|
if (IsDone() == false)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Failed;
|
_steps = ESteps.Failed;
|
||||||
_lastError = "user abort";
|
_lastError = "user abort";
|
||||||
|
|||||||
@@ -3,18 +3,25 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public class BundleInfo
|
public class BundleInfo
|
||||||
{
|
{
|
||||||
|
internal enum ELoadMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadFromStreaming,
|
||||||
|
LoadFromCache,
|
||||||
|
LoadFromRemote,
|
||||||
|
}
|
||||||
|
|
||||||
private readonly PatchBundle _patchBundle;
|
private readonly PatchBundle _patchBundle;
|
||||||
|
internal readonly ELoadMode LoadMode;
|
||||||
|
|
||||||
|
private string _streamingPath;
|
||||||
|
private string _cachePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称
|
/// 资源包名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { private set; get; }
|
public string BundleName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 本地存储的路径
|
|
||||||
/// </summary>
|
|
||||||
public string LocalPath { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 远端下载地址
|
/// 远端下载地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -96,30 +103,57 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取流文件夹的加载路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetStreamingLoadPath()
|
||||||
|
{
|
||||||
|
if (_patchBundle == null)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_streamingPath))
|
||||||
|
_streamingPath = PathHelper.MakeStreamingLoadPath(_patchBundle.Hash);
|
||||||
|
return _streamingPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取缓存文件夹的加载路径
|
||||||
|
/// </summary>
|
||||||
|
public string GetCacheLoadPath()
|
||||||
|
{
|
||||||
|
if (_patchBundle == null)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_cachePath))
|
||||||
|
_cachePath = SandboxHelper.MakeSandboxCacheFilePath(_patchBundle.Hash);
|
||||||
|
return _cachePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private BundleInfo()
|
private BundleInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal BundleInfo(PatchBundle patchBundle, string localPath, string mainURL, string fallbackURL)
|
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string mainURL, string fallbackURL)
|
||||||
{
|
{
|
||||||
_patchBundle = patchBundle;
|
_patchBundle = patchBundle;
|
||||||
|
LoadMode = loadMode;
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
LocalPath = localPath;
|
|
||||||
RemoteMainURL = mainURL;
|
RemoteMainURL = mainURL;
|
||||||
RemoteFallbackURL = fallbackURL;
|
RemoteFallbackURL = fallbackURL;
|
||||||
}
|
}
|
||||||
internal BundleInfo(PatchBundle patchBundle, string localPath)
|
internal BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||||
{
|
{
|
||||||
_patchBundle = patchBundle;
|
_patchBundle = patchBundle;
|
||||||
|
LoadMode = loadMode;
|
||||||
BundleName = patchBundle.BundleName;
|
BundleName = patchBundle.BundleName;
|
||||||
LocalPath = localPath;
|
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
}
|
}
|
||||||
internal BundleInfo(string bundleName, string localPath)
|
internal BundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
_patchBundle = null;
|
_patchBundle = null;
|
||||||
|
LoadMode = ELoadMode.None;
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
LocalPath = localPath;
|
|
||||||
RemoteMainURL = string.Empty;
|
RemoteMainURL = string.Empty;
|
||||||
RemoteFallbackURL = string.Empty;
|
RemoteFallbackURL = string.Empty;
|
||||||
}
|
}
|
||||||
@@ -127,9 +161,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为JAR包内文件
|
/// 是否为JAR包内文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsBuildinJarFile()
|
public static bool IsBuildinJarFile(string streamingPath)
|
||||||
{
|
{
|
||||||
return LocalPath.StartsWith("jar:");
|
return streamingPath.StartsWith("jar:");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,6 @@ namespace YooAsset
|
|||||||
// 检测是否下载失败
|
// 检测是否下载失败
|
||||||
if (downloader.HasError())
|
if (downloader.HasError())
|
||||||
{
|
{
|
||||||
downloader.ReportError();
|
|
||||||
_removeList.Add(downloader);
|
_removeList.Add(downloader);
|
||||||
_loadFailedList.Add(bundleInfo);
|
_loadFailedList.Add(bundleInfo);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -15,7 +14,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的初始化操作
|
/// 编辑器下模拟运行的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class EditorModeInitializationOperation : InitializationOperation
|
internal sealed class EditorPlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -29,7 +28,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的初始化操作
|
/// 离线模式的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class OfflinePlayModeInitializationOperation : InitializationOperation
|
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -81,7 +80,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式的初始化操作
|
/// 网络模式的初始化操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class HostPlayModeInitializationOperation : InitializationOperation
|
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的更新清单操作
|
/// 编辑器下模拟运行的更新清单操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class EditorModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class EditorPlayModeUpdateManifestOperation : UpdateManifestOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的更新清单操作
|
/// 离线模式的更新清单操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class OfflinePlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class OfflinePlayModeUpdateManifestOperation : UpdateManifestOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -44,7 +44,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式的更新清单操作
|
/// 网络模式的更新清单操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class HostPlayModeUpdateManifestOperation : UpdateManifestOperation
|
internal sealed class HostPlayModeUpdateManifestOperation : UpdateManifestOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -113,6 +113,7 @@ namespace YooAsset
|
|||||||
if (cachedManifestHash == webManifestHash)
|
if (cachedManifestHash == webManifestHash)
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
||||||
|
LoadSandboxPatchManifest(_updateResourceVersion);
|
||||||
_steps = ESteps.InitPrepareCache;
|
_steps = ESteps.InitPrepareCache;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -140,7 +141,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
// Check error
|
// Check error
|
||||||
if (_downloaderManifest.HasError())
|
if (_downloaderManifest.HasError())
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _downloaderManifest.GetError();
|
Error = _downloaderManifest.GetError();
|
||||||
@@ -211,6 +212,17 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载沙盒内的补丁清单
|
||||||
|
/// </summary>
|
||||||
|
private void LoadSandboxPatchManifest(int updateResourceVersion)
|
||||||
|
{
|
||||||
|
YooLogger.Log("Load sandbox patch manifest file.");
|
||||||
|
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
|
string jsonData = File.ReadAllText(filePath);
|
||||||
|
_impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取沙盒内补丁清单文件的哈希值
|
/// 获取沙盒内补丁清单文件的哈希值
|
||||||
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
|
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -19,7 +17,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行的更新静态版本操作
|
/// 编辑器下模拟运行的更新静态版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class EditorModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class EditorPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -33,7 +31,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线模式的更新静态版本操作
|
/// 离线模式的更新静态版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
@@ -47,7 +45,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网络模式的更新静态版本操作
|
/// 网络模式的更新静态版本操作
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
internal sealed class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync()
|
public InitializationOperation InitializeAsync()
|
||||||
{
|
{
|
||||||
var operation = new EditorModeInitializationOperation();
|
var operation = new EditorPlayModeInitializationOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ namespace YooAsset
|
|||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Editor play mode can not get bundle info.");
|
YooLogger.Warning($"Editor play mode can not get bundle info.");
|
||||||
BundleInfo bundleInfo = new BundleInfo(bundleName, bundleName);
|
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
string IBundleServices.GetBundleName(string assetPath)
|
string IBundleServices.GetBundleName(string assetPath)
|
||||||
|
|||||||
@@ -196,10 +196,9 @@ namespace YooAsset
|
|||||||
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
// 注意:资源版本号只用于确定下载路径
|
// 注意:资源版本号只用于确定下载路径
|
||||||
string sandboxPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
|
||||||
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Hash);
|
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Hash);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,36 +206,34 @@ namespace YooAsset
|
|||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
return new BundleInfo(string.Empty, string.Empty);
|
return new BundleInfo(string.Empty);
|
||||||
|
|
||||||
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (LocalPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
{
|
{
|
||||||
|
// 查询沙盒资源
|
||||||
|
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||||
|
{
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
||||||
|
return bundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// 查询APP资源
|
// 查询APP资源
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle appPatchBundle))
|
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle appPatchBundle))
|
||||||
{
|
{
|
||||||
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
if (appPatchBundle.IsBuildin && appPatchBundle.Hash == patchBundle.Hash)
|
||||||
{
|
{
|
||||||
string appLoadPath = PathHelper.MakeStreamingLoadPath(appPatchBundle.Hash);
|
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, appLoadPath);
|
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询沙盒资源
|
|
||||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
|
||||||
{
|
|
||||||
string sandboxLoadPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxLoadPath);
|
|
||||||
return bundleInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从服务端下载
|
// 从服务端下载
|
||||||
return ConvertToDownloadInfo(patchBundle);
|
return ConvertToDownloadInfo(patchBundle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
|
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,18 +42,17 @@ namespace YooAsset
|
|||||||
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(bundleName))
|
if (string.IsNullOrEmpty(bundleName))
|
||||||
return new BundleInfo(string.Empty, string.Empty);
|
return new BundleInfo(string.Empty);
|
||||||
|
|
||||||
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
if (AppPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle patchBundle))
|
||||||
{
|
{
|
||||||
string localPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, localPath);
|
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
|
||||||
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
|
BundleInfo bundleInfo = new BundleInfo(bundleName);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
[assembly: InternalsVisibleTo("YooAsset.Editor")]
|
||||||
|
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -13,6 +14,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
public string ConvertLocationToAssetPath(YooAssets.EPlayMode playMode, string location)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
CheckLocation(location);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
if (playMode == YooAssets.EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
string filePath = CombineAssetPath(_resourceRoot, location);
|
string filePath = CombineAssetPath(_resourceRoot, location);
|
||||||
@@ -73,5 +78,28 @@ namespace YooAsset
|
|||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private void CheckLocation(string location)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(location))
|
||||||
|
{
|
||||||
|
YooLogger.Error("location param is null or empty!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 检查路径末尾是否有空格
|
||||||
|
int index = location.LastIndexOf(" ");
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
if (location.Length == index + 1)
|
||||||
|
YooLogger.Warning($"Found blank character in location : \"{location}\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
|
||||||
|
YooLogger.Warning($"Found illegal character in location : \"{location}\"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,6 +150,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static List<BundleInfo> GetUnpackListByTags(PatchManifest appPatchManifest, string[] tags)
|
public static List<BundleInfo> GetUnpackListByTags(PatchManifest appPatchManifest, string[] tags)
|
||||||
{
|
{
|
||||||
|
// 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
|
||||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||||
foreach (var patchBundle in appPatchManifest.BundleList)
|
foreach (var patchBundle in appPatchManifest.BundleList)
|
||||||
{
|
{
|
||||||
@@ -162,19 +163,11 @@ namespace YooAsset
|
|||||||
if (patchBundle.IsBuildin == false)
|
if (patchBundle.IsBuildin == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// 如果是纯内置资源
|
// 查询DLC资源
|
||||||
if (patchBundle.IsPureBuildin())
|
if (patchBundle.HasTag(tags))
|
||||||
{
|
{
|
||||||
downloadList.Add(patchBundle);
|
downloadList.Add(patchBundle);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// 查询DLC资源
|
|
||||||
if (patchBundle.HasTag(tags))
|
|
||||||
{
|
|
||||||
downloadList.Add(patchBundle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ConvertToUnpackList(downloadList);
|
return ConvertToUnpackList(downloadList);
|
||||||
@@ -191,9 +184,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
private static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
private static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||||
{
|
{
|
||||||
string sandboxPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
// 注意:我们把流加载路径指定为远端下载地址
|
||||||
string streamingLoadPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, streamingLoadPath, streamingLoadPath);
|
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,147 +3,10 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace YooAsset
|
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>
|
||||||
/// 字符串工具类
|
/// 字符串工具类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -219,12 +219,11 @@ namespace YooAsset
|
|||||||
/// 向网络端请求静态资源版本号
|
/// 向网络端请求静态资源版本号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
/// <returns></returns>
|
|
||||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorModeUpdateStaticVersionOperation();
|
var operation = new EditorPlayModeUpdateStaticVersionOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -255,7 +254,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_playMode == EPlayMode.EditorPlayMode)
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
{
|
{
|
||||||
var operation = new EditorModeUpdateManifestOperation();
|
var operation = new EditorPlayModeUpdateManifestOperation();
|
||||||
OperationSystem.ProcessOperaiton(operation);
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -364,10 +363,40 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载原生文件
|
/// 异步加载原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static RawFileOperation LoadRawFileAsync(string location, string savePath)
|
/// <param name="location">资源的定位地址</param>
|
||||||
|
/// <param name="copyPath">拷贝路径</param>
|
||||||
|
public static RawFileOperation LoadRawFileAsync(string location, string copyPath = null)
|
||||||
{
|
{
|
||||||
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
string assetPath = _locationServices.ConvertLocationToAssetPath(_playMode, location);
|
||||||
return AssetSystem.LoadRawFileAsync(assetPath, savePath);
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
|
{
|
||||||
|
BundleInfo bundleInfo = new BundleInfo(assetPath);
|
||||||
|
RawFileOperation operation = new EditorPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
|
{
|
||||||
|
IBundleServices bundleServices = _offlinePlayModeImpl;
|
||||||
|
string bundleName = bundleServices.GetBundleName(assetPath);
|
||||||
|
BundleInfo bundleInfo = bundleServices.GetBundleInfo(bundleName);
|
||||||
|
RawFileOperation operation = new OfflinePlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
{
|
||||||
|
IBundleServices bundleServices = _hostPlayModeImpl;
|
||||||
|
string bundleName = bundleServices.GetBundleName(assetPath);
|
||||||
|
BundleInfo bundleInfo = bundleServices.GetBundleInfo(bundleName);
|
||||||
|
RawFileOperation operation = new HostPlayModeRawFileOperation(bundleInfo, copyPath);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -375,7 +404,7 @@ namespace YooAsset
|
|||||||
/// 同步加载资源对象
|
/// 同步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : class
|
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : class
|
||||||
{
|
{
|
||||||
return LoadAssetInternal(location, typeof(TObject), true);
|
return LoadAssetInternal(location, typeof(TObject), true);
|
||||||
@@ -384,7 +413,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载资源对象
|
/// 同步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">资源类型</param>
|
/// <param name="type">资源类型</param>
|
||||||
public static AssetOperationHandle LoadAssetSync(string location, System.Type type)
|
public static AssetOperationHandle LoadAssetSync(string location, System.Type type)
|
||||||
{
|
{
|
||||||
@@ -395,7 +424,7 @@ namespace YooAsset
|
|||||||
/// 同步加载子资源对象
|
/// 同步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location)
|
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location)
|
||||||
{
|
{
|
||||||
return LoadSubAssetsInternal(location, typeof(TObject), true);
|
return LoadSubAssetsInternal(location, typeof(TObject), true);
|
||||||
@@ -404,7 +433,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载子资源对象
|
/// 同步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, System.Type type)
|
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, System.Type type)
|
||||||
{
|
{
|
||||||
@@ -416,7 +445,7 @@ namespace YooAsset
|
|||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
||||||
{
|
{
|
||||||
return LoadAssetInternal(location, typeof(TObject), false);
|
return LoadAssetInternal(location, typeof(TObject), false);
|
||||||
@@ -425,7 +454,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载资源对象
|
/// 异步加载资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">资源类型</param>
|
/// <param name="type">资源类型</param>
|
||||||
public static AssetOperationHandle LoadAssetAsync(string location, System.Type type)
|
public static AssetOperationHandle LoadAssetAsync(string location, System.Type type)
|
||||||
{
|
{
|
||||||
@@ -436,7 +465,7 @@ namespace YooAsset
|
|||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location)
|
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location)
|
||||||
{
|
{
|
||||||
return LoadSubAssetsInternal(location, typeof(TObject), false);
|
return LoadSubAssetsInternal(location, typeof(TObject), false);
|
||||||
@@ -445,7 +474,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步加载子资源对象
|
/// 异步加载子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">资源对象相对路径</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
/// <param name="type">子对象类型</param>
|
/// <param name="type">子对象类型</param>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, System.Type type)
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, System.Type type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.0.3",
|
"version": "1.0.6",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system",
|
"description": "unity3d resources management system",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
他们帮忙协助解决了很多BUG以及提出了很多宝贵的意见!
|
他们帮忙协助解决了很多BUG以及提出了很多宝贵的意见!
|
||||||
|
|
||||||
- 黄色幻想
|
- 黄色幻想 (793301844)
|
||||||
|
- 新乞丐王子 (82470934)
|
||||||
- 新乞丐王子
|
- Wales-丁 (709501148)
|
||||||
|
- L (401419353)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user