mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-16 04:30:12 +00:00
Compare commits
16 Commits
2.0.2-prev
...
2.0.3-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
506612527d | ||
|
|
74f9f2b0e6 | ||
|
|
4119f02c60 | ||
|
|
bc9a4e07e2 | ||
|
|
9418544264 | ||
|
|
460ea091bd | ||
|
|
64681db027 | ||
|
|
992957e1e9 | ||
|
|
ce62dbc27f | ||
|
|
e2df967aa9 | ||
|
|
5b4a188c0b | ||
|
|
e8b5a58a90 | ||
|
|
c3d5c13a80 | ||
|
|
d30a8aefa4 | ||
|
|
194afe435a | ||
|
|
82ef993d83 |
@@ -2,6 +2,43 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.0.3-preview] - 2023-10-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#180) Fixed an issue with invalid encryption task in the build pipeline.
|
||||
- (#185) Fixed subscene unload error when the scene is not loaded.
|
||||
- (#190) Fixed webgl platform compile error.
|
||||
|
||||
### Improvements
|
||||
|
||||
- The asset load method add the priority parameter.
|
||||
- The async operation class add the priority field.
|
||||
|
||||
### Added
|
||||
|
||||
- The InitializeParameters calss add new parameter : AutoDestroyAssetProvider
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 自动销毁不再使用的资源提供者
|
||||
/// </summary>
|
||||
public bool AutoDestroyAssetProvider = false;
|
||||
```
|
||||
|
||||
- Resource package add TryUnloadUnusedAsset function.
|
||||
|
||||
```c#
|
||||
/// <summary>
|
||||
/// 尝试卸载指定资源的资源包(包括依赖资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
```
|
||||
|
||||
### Removed
|
||||
|
||||
- The InitializeParameters calss remove the parameter : LoadingMaxTimeSlice
|
||||
|
||||
## [2.0.2-preview] - 2023-10-17
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -165,10 +165,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
PackageBundle packageBundle = new PackageBundle();
|
||||
packageBundle.BundleName = BundleName;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.FileHash = PackageFileHash;
|
||||
packageBundle.FileCRC = PackageFileCRC;
|
||||
packageBundle.FileSize = PackageFileSize;
|
||||
packageBundle.UnityCRC = PackageUnityCRC;
|
||||
packageBundle.Encrypted = Encrypted;
|
||||
return packageBundle;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -26,6 +23,7 @@ namespace YooAsset.Editor
|
||||
new TaskGetBuildMap_BBP(),
|
||||
new TaskBuilding_BBP(),
|
||||
new TaskVerifyBuildResult_BBP(),
|
||||
new TaskEncryption_BBP(),
|
||||
new TaskUpdateBundleInfo_BBP(),
|
||||
new TaskCreateManifest_BBP(),
|
||||
new TaskCreateReport_BBP(),
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -26,6 +23,7 @@ namespace YooAsset.Editor
|
||||
new TaskGetBuildMap_SBP(),
|
||||
new TaskBuilding_SBP(),
|
||||
new TaskVerifyBuildResult_SBP(),
|
||||
new TaskEncryption_SBP(),
|
||||
new TaskUpdateBundleInfo_SBP(),
|
||||
new TaskCreateManifest_SBP(),
|
||||
new TaskCreateReport_SBP(),
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == ProviderBase.EStatus.Failed.ToString())
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
||||
DownloaderBase newDownloader = null;
|
||||
YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}");
|
||||
#if UNITY_WEBGL
|
||||
if (bundleInfo.Bundle.Buildpipeline == DefaultBuildPipeline.RawFileBuildPipelineName)
|
||||
if (bundleInfo.Bundle.Buildpipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
{
|
||||
FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath);
|
||||
System.Type requesterType = typeof(FileGeneralRequest);
|
||||
@@ -147,4 +147,4 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,10 +76,9 @@ namespace YooAsset
|
||||
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
|
||||
|
||||
/// <summary>
|
||||
/// 资源加载每帧处理的最大时间片段
|
||||
/// 注意:默认值为MaxValue
|
||||
/// 自动销毁不再使用的资源提供者
|
||||
/// </summary>
|
||||
public long LoadingMaxTimeSlice = long.MaxValue;
|
||||
public bool AutoDestroyAssetProvider = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传参数
|
||||
|
||||
@@ -5,16 +5,24 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class AsyncOperationBase : IEnumerator
|
||||
public abstract class AsyncOperationBase : IEnumerator, IComparable<AsyncOperationBase>
|
||||
{
|
||||
// 用户请求的回调
|
||||
private Action<AsyncOperationBase> _callback;
|
||||
|
||||
// 是否已经完成
|
||||
internal bool IsFinish = false;
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 优先级
|
||||
/// </summary>
|
||||
public uint Priority { set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
@@ -80,7 +88,7 @@ namespace YooAsset
|
||||
internal abstract void InternalOnUpdate();
|
||||
internal virtual void InternalOnAbort() { }
|
||||
|
||||
internal void SetPackageName(string packageName)
|
||||
internal void Init(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
@@ -91,8 +99,14 @@ namespace YooAsset
|
||||
}
|
||||
internal void SetFinish()
|
||||
{
|
||||
IsFinish = true;
|
||||
|
||||
// 进度百分百完成
|
||||
Progress = 1f;
|
||||
_callback?.Invoke(this); //注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||
|
||||
//注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||
_callback?.Invoke(this);
|
||||
|
||||
if (_taskCompletionSource != null)
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
@@ -115,6 +129,13 @@ namespace YooAsset
|
||||
_callback = null;
|
||||
}
|
||||
|
||||
#region 排序接口实现
|
||||
public int CompareTo(AsyncOperationBase other)
|
||||
{
|
||||
return other.Priority.CompareTo(this.Priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 异步编程相关
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
|
||||
@@ -45,29 +45,50 @@ namespace YooAsset
|
||||
{
|
||||
_frameTime = _watch.ElapsedMilliseconds;
|
||||
|
||||
// 添加新的异步操作
|
||||
// 添加新增的异步操作
|
||||
if (_newList.Count > 0)
|
||||
{
|
||||
bool sorting = false;
|
||||
foreach (var operation in _newList)
|
||||
{
|
||||
if (operation.Priority > 0)
|
||||
{
|
||||
sorting = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_operations.AddRange(_newList);
|
||||
_newList.Clear();
|
||||
|
||||
// 重新排序优先级
|
||||
if (sorting)
|
||||
_operations.Sort();
|
||||
}
|
||||
|
||||
// 更新所有的异步操作
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
// 更新进行中的异步操作
|
||||
for (int i = 0; i < _operations.Count; i++)
|
||||
{
|
||||
if (IsBusy)
|
||||
break;
|
||||
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
continue;
|
||||
|
||||
if (operation.IsDone == false)
|
||||
operation.InternalOnUpdate();
|
||||
|
||||
if (operation.IsDone)
|
||||
{
|
||||
// 注意:如果业务端发生异常,保证异步操作提前移除。
|
||||
_operations.RemoveAt(i);
|
||||
operation.SetFinish();
|
||||
}
|
||||
}
|
||||
|
||||
// 移除已经完成的异步操作
|
||||
for (int i = _operations.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var operation = _operations[i];
|
||||
if (operation.IsFinish)
|
||||
_operations.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +134,7 @@ namespace YooAsset
|
||||
public static void StartOperation(string packageName, AsyncOperationBase operation)
|
||||
{
|
||||
_newList.Add(operation);
|
||||
operation.SetPackageName(packageName);
|
||||
operation.Init(packageName);
|
||||
operation.SetStart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,15 +45,7 @@ namespace YooAsset
|
||||
if (IsValidWithWarning == false)
|
||||
return EOperationStatus.None;
|
||||
|
||||
var status = Provider.Status;
|
||||
if (status == ProviderBase.EStatus.None)
|
||||
return EOperationStatus.None;
|
||||
else if (status == ProviderBase.EStatus.Succeed)
|
||||
return EOperationStatus.Succeed;
|
||||
else if (status == ProviderBase.EStatus.Failed)
|
||||
return EOperationStatus.Failed;
|
||||
else
|
||||
return EOperationStatus.Processing;
|
||||
return Provider.Status;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +58,7 @@ namespace YooAsset
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return string.Empty;
|
||||
return Provider.LastError;
|
||||
return Provider.Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,19 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景名称
|
||||
/// </summary>
|
||||
public string SceneName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return string.Empty;
|
||||
return Provider.SceneName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景对象
|
||||
/// </summary>
|
||||
@@ -152,10 +165,8 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 卸载子场景
|
||||
Scene sceneObject = SceneObject;
|
||||
Provider.Impl.UnloadSubScene(Provider);
|
||||
{
|
||||
var operation = new UnloadSceneOperation(sceneObject);
|
||||
var operation = new UnloadSceneOperation(Provider);
|
||||
OperationSystem.StartOperation(packageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_createRequest != null)
|
||||
{
|
||||
if (_isWaitForAsyncComplete)
|
||||
if (_isWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity bundle.");
|
||||
|
||||
@@ -45,6 +45,8 @@ namespace YooAsset
|
||||
public bool IsDestroyed { private set; get; } = false;
|
||||
|
||||
private readonly List<ProviderBase> _providers = new List<ProviderBase>(100);
|
||||
private readonly List<ProviderBase> _removeList = new List<ProviderBase>(100);
|
||||
protected bool IsForceDestroyComplete { private set; get; } = false;
|
||||
internal AssetBundle CacheBundle { set; get; }
|
||||
internal string FileLoadPath { set; get; }
|
||||
internal float DownloadProgress { set; get; }
|
||||
@@ -59,15 +61,6 @@ namespace YooAsset
|
||||
Status = EStatus.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加附属的资源提供者
|
||||
/// </summary>
|
||||
public void AddProvider(ProviderBase provider)
|
||||
{
|
||||
if (_providers.Contains(provider) == false)
|
||||
_providers.Add(provider);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引用(引用计数递加)
|
||||
/// </summary>
|
||||
@@ -100,39 +93,45 @@ namespace YooAsset
|
||||
if (IsDone() == false)
|
||||
return false;
|
||||
|
||||
if (RefCount > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return RefCount <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在满足条件的前提下,销毁所有资源提供者
|
||||
/// 添加附属的资源提供者
|
||||
/// </summary>
|
||||
public void TryDestroyAllProviders()
|
||||
public void AddProvider(ProviderBase provider)
|
||||
{
|
||||
if (IsDone() == false)
|
||||
return;
|
||||
if (_providers.Contains(provider) == false)
|
||||
_providers.Add(provider);
|
||||
}
|
||||
|
||||
// 条件1:必须等待所有Provider可以销毁
|
||||
/// <summary>
|
||||
/// 尝试销毁资源提供者
|
||||
/// </summary>
|
||||
public void TryDestroyProviders()
|
||||
{
|
||||
// 获取移除列表
|
||||
_removeList.Clear();
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
if (provider.CanDestroy() == false)
|
||||
return;
|
||||
if (provider.CanDestroy())
|
||||
{
|
||||
_removeList.Add(provider);
|
||||
}
|
||||
}
|
||||
|
||||
// 条件2:除了自己没有其它引用
|
||||
if (RefCount > _providers.Count)
|
||||
return;
|
||||
|
||||
// 销毁所有Providers
|
||||
// 销毁资源提供者
|
||||
foreach (var provider in _removeList)
|
||||
{
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
provider.Destroy();
|
||||
}
|
||||
Impl.RemoveBundleProviders(_providers);
|
||||
_providers.Clear();
|
||||
_providers.Remove(provider);
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 移除资源提供者
|
||||
if (_removeList.Count > 0)
|
||||
{
|
||||
Impl.RemoveBundleProviders(_removeList);
|
||||
_removeList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +161,18 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制销毁资源提供者
|
||||
/// </summary>
|
||||
public void ForceDestroyComplete()
|
||||
{
|
||||
IsForceDestroyComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
// 说明:如果正在下载或解压也可以放心销毁。
|
||||
Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主线程等待异步操作完毕
|
||||
/// </summary>
|
||||
|
||||
@@ -8,68 +8,82 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public sealed class UnloadSceneOperation : AsyncOperationBase
|
||||
{
|
||||
private enum EFlag
|
||||
{
|
||||
Normal,
|
||||
Error,
|
||||
}
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
UnLoad,
|
||||
CheckError,
|
||||
PrepareDone,
|
||||
UnLoadScene,
|
||||
Checking,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EFlag _flag;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private Scene _scene;
|
||||
private readonly string _error;
|
||||
private readonly ProviderBase _provider;
|
||||
private AsyncOperation _asyncOp;
|
||||
|
||||
internal UnloadSceneOperation(string error)
|
||||
{
|
||||
_flag = EFlag.Error;
|
||||
Error = error;
|
||||
_error = error;
|
||||
}
|
||||
internal UnloadSceneOperation(Scene scene)
|
||||
internal UnloadSceneOperation(ProviderBase provider)
|
||||
{
|
||||
_flag = EFlag.Normal;
|
||||
_scene = scene;
|
||||
_error = null;
|
||||
_provider = provider;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
if (_flag == EFlag.Normal)
|
||||
{
|
||||
_steps = ESteps.UnLoad;
|
||||
}
|
||||
else if (_flag == EFlag.Error)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_flag.ToString());
|
||||
}
|
||||
_steps = ESteps.CheckError;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.UnLoad)
|
||||
if (_steps == ESteps.CheckError)
|
||||
{
|
||||
if (_scene.IsValid() && _scene.isLoaded)
|
||||
if (string.IsNullOrEmpty(_error) == false)
|
||||
{
|
||||
_asyncOp = SceneManager.UnloadSceneAsync(_scene);
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = "Scene is invalid or is not loaded.";
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _error;
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.PrepareDone;
|
||||
}
|
||||
|
||||
if(_steps == ESteps.PrepareDone)
|
||||
{
|
||||
if (_provider.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_provider.SceneObject.IsValid() == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Scene is invalid !";
|
||||
return;
|
||||
}
|
||||
|
||||
if (_provider.SceneObject.isLoaded == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Scene is not loaded !";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.UnLoadScene;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnLoadScene)
|
||||
{
|
||||
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
||||
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
||||
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.Checking)
|
||||
|
||||
@@ -7,24 +7,26 @@ namespace YooAsset
|
||||
internal sealed class BundledAllAssetsProvider : ProviderBase
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledAllAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
|
||||
public BundledAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAllAssets();
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledAssetProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AssetObject = OwnerBundle.CacheBundle.LoadAsset(MainAssetInfo.AssetPath);
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AssetObject == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,23 +3,25 @@ namespace YooAsset
|
||||
{
|
||||
internal class BundledRawFileProvider : ProviderBase
|
||||
{
|
||||
public BundledRawFileProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -31,21 +33,19 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 2. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = OwnerBundle.FileLoadPath;
|
||||
Status = EStatus.Succeed;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,32 +9,31 @@ namespace YooAsset
|
||||
internal sealed class BundledSceneProvider : ProviderBase
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly string _sceneName;
|
||||
private readonly bool _suspendLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOperation;
|
||||
|
||||
public BundledSceneProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
_sceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_priority = priority;
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (DependBundles.IsDone() == false)
|
||||
return;
|
||||
@@ -43,57 +42,57 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载场景
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
// 注意:如果场景不存在则返回NULL
|
||||
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.priority = _priority;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load scene : {_sceneName}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone)
|
||||
{
|
||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (SceneObject.IsValid())
|
||||
{
|
||||
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,23 +8,25 @@ namespace YooAsset
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
|
||||
public BundledSubAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public BundledSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -39,17 +41,15 @@ namespace YooAsset
|
||||
|
||||
if (DependBundles.IsSucceed() == false)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = DependBundles.GetLastError();
|
||||
InvokeCompletion();
|
||||
string error = DependBundles.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AllAssetObjects = OwnerBundle.CacheBundle.LoadAssetWithSubAssets(MainAssetInfo.AssetPath);
|
||||
@@ -79,15 +79,15 @@ namespace YooAsset
|
||||
else
|
||||
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
if (_cacheRequest != null)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
if (IsWaitForAsyncComplete || IsForceDestroyComplete)
|
||||
{
|
||||
// 强制挂起主线程(注意:该操作会很耗时)
|
||||
YooLogger.Warning("Suspend the main thread to load unity asset.");
|
||||
@@ -102,16 +102,20 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
else
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,19 @@ namespace YooAsset
|
||||
public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetCompleted(string error)
|
||||
{
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = error;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAllAssetsProvider : ProviderBase
|
||||
{
|
||||
public DatabaseAllAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
{
|
||||
@@ -82,22 +84,26 @@ namespace YooAsset
|
||||
}
|
||||
AllAssetObjects = result.ToArray();
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAssetProvider : ProviderBase
|
||||
{
|
||||
public DatabaseAssetProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,38 +51,41 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
|
||||
else
|
||||
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AssetObject == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,29 +3,32 @@ namespace YooAsset
|
||||
{
|
||||
internal class DatabaseRawFileProvider : ProviderBase
|
||||
{
|
||||
public DatabaseRawFileProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -33,7 +36,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -45,21 +48,19 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 2. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = MainAssetInfo.AssetPath;
|
||||
Status = EStatus.Succeed;
|
||||
InvokeCompletion();
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
@@ -7,28 +10,31 @@ namespace YooAsset
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private readonly bool _suspendLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOperation;
|
||||
|
||||
public DatabaseSceneProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
SceneMode = sceneMode;
|
||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||
_suspendLoad = suspendLoad;
|
||||
_priority = priority;
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -40,17 +46,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
|
||||
loadSceneParameters.loadSceneMode = SceneMode;
|
||||
@@ -58,32 +63,34 @@ namespace YooAsset
|
||||
if (_asyncOperation != null)
|
||||
{
|
||||
_asyncOperation.allowSceneActivation = !_suspendLoad;
|
||||
_asyncOperation.priority = _priority;
|
||||
_asyncOperation.priority = 100;
|
||||
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Progress = _asyncOperation.progress;
|
||||
if (_asyncOperation.isDone)
|
||||
{
|
||||
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (SceneObject.IsValid())
|
||||
{
|
||||
LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
string error = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,29 +6,32 @@ namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
||||
{
|
||||
public DatabaseSubAssetsProvider(ResourceManager impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
public DatabaseSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (IsDone)
|
||||
return;
|
||||
|
||||
if (Status == EStatus.None)
|
||||
if (_steps == ESteps.None)
|
||||
{
|
||||
// 检测资源文件是否存在
|
||||
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.CheckBundle;
|
||||
_steps = ESteps.CheckBundle;
|
||||
|
||||
// 注意:模拟异步加载效果提前返回
|
||||
if (IsWaitForAsyncComplete == false)
|
||||
@@ -36,7 +39,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 1. 检测资源包
|
||||
if (Status == EStatus.CheckBundle)
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -48,17 +51,16 @@ namespace YooAsset
|
||||
|
||||
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
Status = EStatus.Failed;
|
||||
LastError = OwnerBundle.LastError;
|
||||
InvokeCompletion();
|
||||
string error = OwnerBundle.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
Status = EStatus.Loading;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
// 2. 加载资源对象
|
||||
if (Status == EStatus.Loading)
|
||||
if (_steps == ESteps.Loading)
|
||||
{
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
{
|
||||
@@ -75,22 +77,26 @@ namespace YooAsset
|
||||
}
|
||||
AllAssetObjects = result.ToArray();
|
||||
}
|
||||
Status = EStatus.Checking;
|
||||
_steps = ESteps.Checking;
|
||||
}
|
||||
|
||||
// 3. 检测加载结果
|
||||
if (Status == EStatus.Checking)
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed;
|
||||
if (Status == EStatus.Failed)
|
||||
if (AllAssetObjects == null)
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
|
||||
else
|
||||
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(LastError);
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
InvokeCompletion();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class ProviderBase
|
||||
internal abstract class ProviderBase : AsyncOperationBase
|
||||
{
|
||||
public enum EStatus
|
||||
protected enum ESteps
|
||||
{
|
||||
None = 0,
|
||||
CheckBundle,
|
||||
Loading,
|
||||
Checking,
|
||||
Succeed,
|
||||
Failed,
|
||||
Done,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 所属资源系统
|
||||
/// </summary>
|
||||
public ResourceManager Impl { private set; get; }
|
||||
public ResourceManager ResourceMgr { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息
|
||||
@@ -47,27 +47,16 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public UnityEngine.SceneManagement.Scene SceneObject { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载的场景名称
|
||||
/// </summary>
|
||||
public string SceneName { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 原生文件路径
|
||||
/// </summary>
|
||||
public string RawFilePath { protected set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前的加载状态
|
||||
/// </summary>
|
||||
public EStatus Status { protected set; get; } = EStatus.None;
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError { protected set; get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 加载进度
|
||||
/// </summary>
|
||||
public float Progress { protected set; get; } = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// 引用计数
|
||||
/// </summary>
|
||||
@@ -78,55 +67,48 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool IsDestroyed { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 是否完毕(成功或失败)
|
||||
/// </summary>
|
||||
public bool IsDone
|
||||
{
|
||||
get
|
||||
{
|
||||
return Status == EStatus.Succeed || Status == EStatus.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ESteps _steps = ESteps.None;
|
||||
protected BundleLoaderBase OwnerBundle { private set; get; }
|
||||
protected DependAssetBundles DependBundles { private set; get; }
|
||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||
protected bool IsForceDestroyComplete { private set; get; } = false;
|
||||
private readonly List<HandleBase> _handles = new List<HandleBase>();
|
||||
|
||||
|
||||
public ProviderBase(ResourceManager impl, string providerGUID, AssetInfo assetInfo)
|
||||
public ProviderBase(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
{
|
||||
Impl = impl;
|
||||
ResourceMgr = manager;
|
||||
ProviderGUID = providerGUID;
|
||||
MainAssetInfo = assetInfo;
|
||||
|
||||
// 创建资源包加载器
|
||||
if (impl != null)
|
||||
if (manager != null)
|
||||
{
|
||||
OwnerBundle = impl.CreateOwnerAssetBundleLoader(assetInfo);
|
||||
OwnerBundle = manager.CreateOwnerAssetBundleLoader(assetInfo);
|
||||
OwnerBundle.Reference();
|
||||
OwnerBundle.AddProvider(this);
|
||||
|
||||
var dependList = impl.CreateDependAssetBundleLoaders(assetInfo);
|
||||
var dependList = manager.CreateDependAssetBundleLoaders(assetInfo);
|
||||
DependBundles = new DependAssetBundles(dependList);
|
||||
DependBundles.Reference();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮询更新方法
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
/// <summary>
|
||||
/// 销毁资源对象
|
||||
/// 销毁资源提供者
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
{
|
||||
IsDestroyed = true;
|
||||
|
||||
// 检测是否为正常销毁
|
||||
if (IsDone == false)
|
||||
{
|
||||
Error = "User abort !";
|
||||
Status = EOperationStatus.Failed;
|
||||
}
|
||||
|
||||
// 释放资源包加载器
|
||||
if (OwnerBundle != null)
|
||||
{
|
||||
@@ -145,14 +127,15 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool CanDestroy()
|
||||
{
|
||||
if (IsDone == false)
|
||||
// 注意:在进行资源加载过程时不可以销毁
|
||||
if (_steps == ESteps.Loading || _steps == ESteps.Checking)
|
||||
return false;
|
||||
|
||||
return RefCount <= 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建操作句柄
|
||||
/// 创建资源句柄
|
||||
/// </summary>
|
||||
public T CreateHandle<T>() where T : HandleBase
|
||||
{
|
||||
@@ -178,12 +161,12 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放操作句柄
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void ReleaseHandle(HandleBase handle)
|
||||
{
|
||||
if (RefCount <= 0)
|
||||
YooLogger.Warning("Asset provider reference count is already zero. There may be resource leaks !");
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
if (_handles.Remove(handle) == false)
|
||||
throw new System.Exception("Should never get here !");
|
||||
@@ -192,6 +175,18 @@ namespace YooAsset
|
||||
RefCount--;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄
|
||||
/// </summary>
|
||||
public void ReleaseAllHandles()
|
||||
{
|
||||
for (int i = _handles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var handle = _handles[i];
|
||||
handle.ReleaseInternal();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步执行完毕
|
||||
/// </summary>
|
||||
@@ -200,15 +195,27 @@ namespace YooAsset
|
||||
IsWaitForAsyncComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
Update();
|
||||
InternalOnUpdate();
|
||||
|
||||
// 验证结果
|
||||
if (IsDone == false)
|
||||
{
|
||||
YooLogger.Warning($"WaitForAsyncComplete failed to loading : {MainAssetInfo.AssetPath}");
|
||||
YooLogger.Warning($"{nameof(WaitForAsyncComplete)} failed to loading : {MainAssetInfo.AssetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制销毁资源提供者
|
||||
/// </summary>
|
||||
public void ForceDestroyComplete()
|
||||
{
|
||||
IsForceDestroyComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
// 说明:如果资源包未准备完毕也可以放心销毁。
|
||||
InternalOnUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理特殊异常
|
||||
/// </summary>
|
||||
@@ -217,37 +224,21 @@ namespace YooAsset
|
||||
if (OwnerBundle.IsDestroyed)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
YooLogger.Error(LastError);
|
||||
InvokeCompletion();
|
||||
string error = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(Error, EOperationStatus.Failed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作任务
|
||||
/// 结束流程
|
||||
/// </summary>
|
||||
public Task Task
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_taskCompletionSource == null)
|
||||
{
|
||||
_taskCompletionSource = new TaskCompletionSource<object>();
|
||||
if (IsDone)
|
||||
_taskCompletionSource.SetResult(null);
|
||||
}
|
||||
return _taskCompletionSource.Task;
|
||||
}
|
||||
}
|
||||
|
||||
#region 异步编程相关
|
||||
private TaskCompletionSource<object> _taskCompletionSource;
|
||||
protected void InvokeCompletion()
|
||||
protected void InvokeCompletion(string error, EOperationStatus status)
|
||||
{
|
||||
DebugEndRecording();
|
||||
|
||||
// 进度百分百完成
|
||||
Progress = 1f;
|
||||
_steps = ESteps.Done;
|
||||
Error = error;
|
||||
Status = status;
|
||||
|
||||
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
|
||||
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
|
||||
@@ -259,11 +250,7 @@ namespace YooAsset
|
||||
hande.InvokeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
if (_taskCompletionSource != null)
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试信息相关
|
||||
/// <summary>
|
||||
|
||||
@@ -9,31 +9,17 @@ namespace YooAsset
|
||||
{
|
||||
internal class ResourceManager
|
||||
{
|
||||
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
|
||||
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
|
||||
|
||||
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
|
||||
private readonly List<ProviderBase> _providerList = new List<ProviderBase>(5000);
|
||||
|
||||
// 全局场景句柄集合
|
||||
private readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100);
|
||||
private static long _sceneCreateCount = 0;
|
||||
|
||||
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
|
||||
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
|
||||
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
|
||||
|
||||
private bool _simulationOnEditor;
|
||||
private long _loadingMaxTimeSlice;
|
||||
private bool _autoDestroyAssetProvider;
|
||||
private IBundleQuery _bundleQuery;
|
||||
private bool _isUnloadSafe = true;
|
||||
|
||||
// 计时器相关
|
||||
private Stopwatch _watch;
|
||||
private long _frameTime;
|
||||
private bool IsBusy
|
||||
{
|
||||
get
|
||||
{
|
||||
return _watch.ElapsedMilliseconds - _frameTime >= _loadingMaxTimeSlice;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 所属包裹
|
||||
@@ -49,12 +35,11 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public void Initialize(bool simulationOnEditor, long loadingMaxTimeSlice, IBundleQuery bundleServices)
|
||||
public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, IBundleQuery bundleServices)
|
||||
{
|
||||
_simulationOnEditor = simulationOnEditor;
|
||||
_loadingMaxTimeSlice = loadingMaxTimeSlice;
|
||||
_autoDestroyAssetProvider = autoDestroyAssetProvider;
|
||||
_bundleQuery = bundleServices;
|
||||
_watch = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,50 +47,24 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
_frameTime = _watch.ElapsedMilliseconds;
|
||||
|
||||
// 更新加载器
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.Update();
|
||||
}
|
||||
|
||||
// 更新资源提供者
|
||||
// 注意:循环更新的时候,可能会扩展列表
|
||||
_isUnloadSafe = false;
|
||||
for (int i = 0; i < _providerList.Count; i++)
|
||||
{
|
||||
if (IsBusy)
|
||||
break;
|
||||
_providerList[i].Update();
|
||||
if (_autoDestroyAssetProvider)
|
||||
loader.TryDestroyProviders();
|
||||
}
|
||||
_isUnloadSafe = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
public void UnloadUnusedAssets()
|
||||
{
|
||||
if (_isUnloadSafe == false)
|
||||
{
|
||||
YooLogger.Warning("Can not unload unused assets when processing resource loading !");
|
||||
return;
|
||||
}
|
||||
|
||||
// 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。
|
||||
int loopCount = 10;
|
||||
for (int i = 0; i < loopCount; i++)
|
||||
{
|
||||
UnloadUnusedAssetsInternal();
|
||||
}
|
||||
}
|
||||
private void UnloadUnusedAssetsInternal()
|
||||
{
|
||||
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
BundleLoaderBase loader = _loaderList[i];
|
||||
loader.TryDestroyAllProviders();
|
||||
loader.TryDestroyProviders();
|
||||
}
|
||||
|
||||
for (int i = _loaderList.Count - 1; i >= 0; i--)
|
||||
@@ -121,26 +80,91 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试卸载指定资源的资源包(包括依赖资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to unload asset ! {assetInfo.Error}");
|
||||
return;
|
||||
}
|
||||
|
||||
// 卸载主资源包加载器
|
||||
string manBundleName = _bundleQuery.GetMainBundleName(assetInfo);
|
||||
var mainLoader = TryGetAssetBundleLoader(manBundleName);
|
||||
if (mainLoader != null)
|
||||
{
|
||||
mainLoader.TryDestroyProviders();
|
||||
if (mainLoader.CanDestroy())
|
||||
{
|
||||
string bundleName = mainLoader.MainBundleInfo.Bundle.BundleName;
|
||||
mainLoader.Destroy();
|
||||
_loaderList.Remove(mainLoader);
|
||||
_loaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
|
||||
// 卸载依赖资源包加载器
|
||||
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo);
|
||||
foreach (var dependBundleName in dependBundleNames)
|
||||
{
|
||||
var dependLoader = TryGetAssetBundleLoader(dependBundleName);
|
||||
if (dependLoader != null)
|
||||
{
|
||||
if (dependLoader.CanDestroy())
|
||||
{
|
||||
string bundleName = dependLoader.MainBundleInfo.Bundle.BundleName;
|
||||
dependLoader.Destroy();
|
||||
_loaderList.Remove(dependLoader);
|
||||
_loaderDic.Remove(bundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制回收所有资源
|
||||
/// 注意:加载器在销毁后关联的下载器还会继续下载!
|
||||
/// </summary>
|
||||
public void ForceUnloadAllAssets()
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
throw new Exception($"WebGL not support invoke {nameof(ForceUnloadAllAssets)}");
|
||||
#else
|
||||
foreach (var provider in _providerList)
|
||||
// 注意:因为场景无法异步转同步,需要等待所有场景加载完毕!
|
||||
foreach (var sceneHandlePair in _sceneHandles)
|
||||
{
|
||||
provider.WaitForAsyncComplete();
|
||||
var sceneHandle = sceneHandlePair.Value;
|
||||
if (sceneHandle.PackageName == PackageName)
|
||||
{
|
||||
if (sceneHandle.IsDone == false)
|
||||
throw new Exception($"{nameof(ForceUnloadAllAssets)} cannot be called when loading the scene !");
|
||||
}
|
||||
}
|
||||
|
||||
// 释放所有资源句柄
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
provider.ReleaseAllHandles();
|
||||
}
|
||||
|
||||
// 强制销毁资源提供者
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
provider.ForceDestroyComplete();
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 强制销毁资源加载器
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.WaitForAsyncComplete();
|
||||
loader.ForceDestroyComplete();
|
||||
loader.Destroy();
|
||||
}
|
||||
|
||||
_providerList.Clear();
|
||||
// 清空数据
|
||||
_providerDic.Clear();
|
||||
_loaderList.Clear();
|
||||
_loaderDic.Clear();
|
||||
@@ -152,9 +176,11 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载场景
|
||||
/// 加载场景对象
|
||||
/// 注意:返回的场景句柄是唯一的,每个场景句柄对应自己的场景提供者对象。
|
||||
/// 注意:业务逻辑层应该避免同时加载一个子场景。
|
||||
/// </summary>
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, int priority)
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -175,14 +201,15 @@ namespace YooAsset
|
||||
ProviderBase provider;
|
||||
{
|
||||
if (_simulationOnEditor)
|
||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||
else
|
||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad, priority);
|
||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
var handle = provider.CreateHandle<SceneHandle>();
|
||||
handle.PackageName = PackageName;
|
||||
_sceneHandles.Add(providerGUID, handle);
|
||||
@@ -192,7 +219,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载资源对象
|
||||
/// </summary>
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -211,16 +238,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledAssetProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<AssetHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载子资源对象
|
||||
/// </summary>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -239,16 +268,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<SubAssetsHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有资源对象
|
||||
/// </summary>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -267,16 +298,18 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<AllAssetsHandle>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载原生文件
|
||||
/// </summary>
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
@@ -295,21 +328,32 @@ namespace YooAsset
|
||||
else
|
||||
provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
|
||||
provider.InitSpawnDebugInfo();
|
||||
_providerList.Add(provider);
|
||||
_providerDic.Add(providerGUID, provider);
|
||||
OperationSystem.StartOperation(PackageName, provider);
|
||||
}
|
||||
|
||||
provider.Priority = priority;
|
||||
return provider.CreateHandle<RawFileHandle>();
|
||||
}
|
||||
|
||||
internal void UnloadSubScene(ProviderBase provider)
|
||||
internal void UnloadSubScene(string sceneName)
|
||||
{
|
||||
string providerGUID = provider.ProviderGUID;
|
||||
if (_sceneHandles.ContainsKey(providerGUID) == false)
|
||||
throw new Exception("Should never get here !");
|
||||
List<string> removeKeys = new List<string>();
|
||||
foreach (var valuePair in _sceneHandles)
|
||||
{
|
||||
var sceneHandle = valuePair.Value;
|
||||
if (sceneHandle.SceneName == sceneName)
|
||||
{
|
||||
// 释放子场景句柄
|
||||
sceneHandle.ReleaseInternal();
|
||||
removeKeys.Add(valuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
// 释放子场景句柄
|
||||
_sceneHandles[providerGUID].ReleaseInternal();
|
||||
_sceneHandles.Remove(providerGUID);
|
||||
foreach (string key in removeKeys)
|
||||
{
|
||||
_sceneHandles.Remove(key);
|
||||
}
|
||||
}
|
||||
private void UnloadAllScene()
|
||||
{
|
||||
@@ -357,14 +401,17 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal void RemoveBundleProviders(List<ProviderBase> providers)
|
||||
internal void RemoveBundleProviders(List<ProviderBase> removeList)
|
||||
{
|
||||
foreach (var provider in providers)
|
||||
foreach (var provider in removeList)
|
||||
{
|
||||
_providerList.Remove(provider);
|
||||
_providerDic.Remove(provider.ProviderGUID);
|
||||
}
|
||||
}
|
||||
internal bool HasAnyLoader()
|
||||
{
|
||||
return _loaderList.Count > 0;
|
||||
}
|
||||
|
||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
@@ -416,8 +463,8 @@ namespace YooAsset
|
||||
#region 调试信息
|
||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count);
|
||||
foreach (var provider in _providerList)
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerDic.Count);
|
||||
foreach (var provider in _providerDic.Values)
|
||||
{
|
||||
DebugProviderInfo providerInfo = new DebugProviderInfo();
|
||||
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;
|
||||
@@ -432,15 +479,6 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
internal List<BundleInfo> GetLoadedBundleInfos()
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(100);
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
result.Add(loader.MainBundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,16 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
BundleInfo[] GetDependBundleInfos(AssetInfo assetPath);
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源包名称
|
||||
/// </summary>
|
||||
string GetMainBundleName(AssetInfo assetInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 获取依赖的资源包名称集合
|
||||
/// </summary>
|
||||
string[] GetDependBundleNames(AssetInfo assetInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 清单是否有效
|
||||
/// </summary>
|
||||
|
||||
@@ -129,6 +129,29 @@ namespace YooAsset
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
||||
@@ -385,6 +385,29 @@ namespace YooAsset
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
||||
@@ -214,6 +214,29 @@ namespace YooAsset
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
||||
@@ -259,6 +259,29 @@ namespace YooAsset
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace YooAsset
|
||||
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
||||
_bundleQuery = editorSimulateModeImpl;
|
||||
_playModeImpl = editorSimulateModeImpl;
|
||||
_resourceMgr.Initialize(true, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||
_resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
|
||||
@@ -156,7 +156,7 @@ namespace YooAsset
|
||||
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
||||
_bundleQuery = offlinePlayModeImpl;
|
||||
_playModeImpl = offlinePlayModeImpl;
|
||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
|
||||
@@ -166,7 +166,7 @@ namespace YooAsset
|
||||
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
||||
_bundleQuery = hostPlayModeImpl;
|
||||
_playModeImpl = hostPlayModeImpl;
|
||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as HostPlayModeParameters;
|
||||
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
|
||||
@@ -179,7 +179,7 @@ namespace YooAsset
|
||||
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
||||
_bundleQuery = webPlayModeImpl;
|
||||
_playModeImpl = webPlayModeImpl;
|
||||
_resourceMgr.Initialize(false, parameters.LoadingMaxTimeSlice, _bundleQuery);
|
||||
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as WebPlayModeParameters;
|
||||
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
|
||||
@@ -266,13 +266,6 @@ namespace YooAsset
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 检测参数范围
|
||||
if (parameters.LoadingMaxTimeSlice < 10)
|
||||
{
|
||||
parameters.LoadingMaxTimeSlice = 10;
|
||||
YooLogger.Warning($"{nameof(parameters.LoadingMaxTimeSlice)} minimum value is 10 milliseconds.");
|
||||
}
|
||||
}
|
||||
private void InitializeOperation_Completed(AsyncOperationBase op)
|
||||
{
|
||||
@@ -300,7 +293,13 @@ namespace YooAsset
|
||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize(false);
|
||||
DebugCheckUpdateManifest();
|
||||
|
||||
// 注意:强烈建议在更新之前保持加载器为空!
|
||||
if (_resourceMgr.HasAnyLoader())
|
||||
{
|
||||
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
|
||||
}
|
||||
|
||||
return _playModeImpl.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
|
||||
}
|
||||
|
||||
@@ -346,6 +345,7 @@ namespace YooAsset
|
||||
return _playModeImpl.ActiveManifest.PackageVersion;
|
||||
}
|
||||
|
||||
#region 资源卸载
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
@@ -355,6 +355,25 @@ namespace YooAsset
|
||||
_resourceMgr.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(尝试卸载指定的资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(string location)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(尝试卸载指定的资源)
|
||||
/// </summary>
|
||||
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制回收所有资源
|
||||
/// </summary>
|
||||
@@ -363,6 +382,7 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
_resourceMgr.ForceUnloadAllAssets();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 沙盒相关
|
||||
/// <summary>
|
||||
@@ -521,7 +541,7 @@ namespace YooAsset
|
||||
public RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadRawFileInternal(assetInfo, true);
|
||||
return LoadRawFileInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -532,35 +552,37 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
return LoadRawFileInternal(assetInfo, true);
|
||||
return LoadRawFileInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadRawFileInternal(assetInfo, false);
|
||||
return LoadRawFileInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public RawFileHandle LoadRawFileAsync(string location)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
return LoadRawFileInternal(assetInfo, false);
|
||||
return LoadRawFileInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
|
||||
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckRawFileLoadMethod(nameof(LoadRawFileAsync));
|
||||
var handle = _resourceMgr.LoadRawFileAsync(assetInfo);
|
||||
var handle = _resourceMgr.LoadRawFileAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
return handle;
|
||||
@@ -574,8 +596,8 @@ namespace YooAsset
|
||||
/// <param name="location">场景的定位地址</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
@@ -589,8 +611,8 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">场景的资源信息</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
||||
@@ -606,7 +628,7 @@ namespace YooAsset
|
||||
public AssetHandle LoadAssetSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadAssetInternal(assetInfo, true);
|
||||
return LoadAssetInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -618,7 +640,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadAssetInternal(assetInfo, true);
|
||||
return LoadAssetInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -630,7 +652,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAssetInternal(assetInfo, true);
|
||||
return LoadAssetInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -642,7 +664,7 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAssetInternal(assetInfo, true);
|
||||
return LoadAssetInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -650,10 +672,11 @@ namespace YooAsset
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadAssetInternal(assetInfo, false);
|
||||
return LoadAssetInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -661,11 +684,12 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public AssetHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadAssetInternal(assetInfo, false);
|
||||
return LoadAssetInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -673,31 +697,33 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public AssetHandle LoadAssetAsync(string location, System.Type type)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAssetInternal(assetInfo, false);
|
||||
return LoadAssetInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public AssetHandle LoadAssetAsync(string location)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AssetHandle LoadAssetAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAssetInternal(assetInfo, false);
|
||||
return LoadAssetInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
|
||||
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
var handle = _resourceMgr.LoadAssetAsync(assetInfo);
|
||||
var handle = _resourceMgr.LoadAssetAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
return handle;
|
||||
@@ -712,7 +738,7 @@ namespace YooAsset
|
||||
public SubAssetsHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadSubAssetsInternal(assetInfo, true);
|
||||
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -724,7 +750,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadSubAssetsInternal(assetInfo, true);
|
||||
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -736,7 +762,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadSubAssetsInternal(assetInfo, true);
|
||||
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -748,7 +774,7 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadSubAssetsInternal(assetInfo, true);
|
||||
return LoadSubAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -756,10 +782,11 @@ namespace YooAsset
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadSubAssetsInternal(assetInfo, false);
|
||||
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -767,11 +794,12 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadSubAssetsInternal(assetInfo, false);
|
||||
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -779,31 +807,33 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadSubAssetsInternal(assetInfo, false);
|
||||
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(string location)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadSubAssetsInternal(assetInfo, false);
|
||||
return LoadSubAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
|
||||
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadMethod(nameof(LoadSubAssetsAsync));
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo);
|
||||
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
return handle;
|
||||
@@ -818,7 +848,7 @@ namespace YooAsset
|
||||
public AllAssetsHandle LoadAllAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadAllAssetsInternal(assetInfo, true);
|
||||
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -830,7 +860,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadAllAssetsInternal(assetInfo, true);
|
||||
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -842,7 +872,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAllAssetsInternal(assetInfo, true);
|
||||
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -854,7 +884,7 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAllAssetsInternal(assetInfo, true);
|
||||
return LoadAllAssetsInternal(assetInfo, true, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -862,10 +892,11 @@ namespace YooAsset
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return LoadAllAssetsInternal(assetInfo, false);
|
||||
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -873,11 +904,12 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
return LoadAllAssetsInternal(assetInfo, false);
|
||||
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -885,31 +917,33 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAllAssetsInternal(assetInfo, false);
|
||||
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(string location)
|
||||
/// <param name="priority">加载的优先级</param>
|
||||
public AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
Type type = typeof(UnityEngine.Object);
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, type);
|
||||
return LoadAllAssetsInternal(assetInfo, false);
|
||||
return LoadAllAssetsInternal(assetInfo, false, priority);
|
||||
}
|
||||
|
||||
|
||||
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadMethod(nameof(LoadAllAssetsAsync));
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo);
|
||||
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
return handle;
|
||||
@@ -1107,16 +1141,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void DebugCheckUpdateManifest()
|
||||
{
|
||||
var loadedBundleInfos = _resourceMgr.GetLoadedBundleInfos();
|
||||
if (loadedBundleInfos.Count > 0)
|
||||
{
|
||||
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private void DebugCheckRawFileLoadMethod(string method)
|
||||
{
|
||||
@@ -1141,6 +1165,11 @@ namespace YooAsset
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
if (typeof(UnityEngine.Behaviour).IsAssignableFrom(type))
|
||||
{
|
||||
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||
}
|
||||
|
||||
if (typeof(UnityEngine.Object).IsAssignableFrom(type) == false)
|
||||
{
|
||||
throw new Exception($"Load asset type is invalid : {type.FullName} !");
|
||||
|
||||
@@ -12,6 +12,14 @@ namespace YooAsset
|
||||
private static GameObject _driver = null;
|
||||
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// </summary>
|
||||
public static bool Initialized
|
||||
{
|
||||
get { return _isInitialize; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源系统
|
||||
/// </summary>
|
||||
@@ -90,7 +98,7 @@ namespace YooAsset
|
||||
public static ResourcePackage CreatePackage(string packageName)
|
||||
{
|
||||
CheckException(packageName);
|
||||
if (HasPackage(packageName))
|
||||
if (ContainsPackage(packageName))
|
||||
throw new Exception($"Package {packageName} already existed !");
|
||||
|
||||
YooLogger.Log($"Create resource package : {packageName}");
|
||||
@@ -142,7 +150,7 @@ namespace YooAsset
|
||||
/// 检测资源包是否存在
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static bool HasPackage(string packageName)
|
||||
public static bool ContainsPackage(string packageName)
|
||||
{
|
||||
CheckException(packageName);
|
||||
var package = GetPackageInternal(packageName);
|
||||
|
||||
@@ -138,20 +138,20 @@ namespace YooAsset
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo)
|
||||
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileAsync(assetInfo);
|
||||
return _defaultPackage.LoadRawFileAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static RawFileHandle LoadRawFileAsync(string location)
|
||||
public static RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileAsync(location);
|
||||
return _defaultPackage.LoadRawFileAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace YooAsset
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
||||
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(location, sceneMode, suspendLoad, priority);
|
||||
@@ -176,7 +176,7 @@ namespace YooAsset
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, int priority = 100)
|
||||
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
||||
@@ -231,10 +231,10 @@ namespace YooAsset
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(assetInfo);
|
||||
return _defaultPackage.LoadAssetAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -242,10 +242,10 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
public static AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync<TObject>(location);
|
||||
return _defaultPackage.LoadAssetAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,20 +253,20 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetHandle LoadAssetAsync(string location, System.Type type)
|
||||
public static AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(location, type);
|
||||
return _defaultPackage.LoadAssetAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetAsync(string location)
|
||||
public static AssetHandle LoadAssetAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(location);
|
||||
return _defaultPackage.LoadAssetAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -318,10 +318,10 @@ namespace YooAsset
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(assetInfo);
|
||||
return _defaultPackage.LoadSubAssetsAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -329,10 +329,10 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync<TObject>(location);
|
||||
return _defaultPackage.LoadSubAssetsAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -340,20 +340,20 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type)
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, type);
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location)
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(location);
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -405,10 +405,10 @@ namespace YooAsset
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo)
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(assetInfo);
|
||||
return _defaultPackage.LoadAllAssetsAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -416,10 +416,10 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync<TObject>(location);
|
||||
return _defaultPackage.LoadAllAssetsAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -427,20 +427,20 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type)
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(location, type);
|
||||
return _defaultPackage.LoadAllAssetsAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location)
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(location);
|
||||
return _defaultPackage.LoadAllAssetsAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -271,8 +271,8 @@ Canvas:
|
||||
m_GameObject: {fileID: 690216953}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_RenderMode: 1
|
||||
m_Camera: {fileID: 1631979429}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
@@ -296,6 +296,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 1645250797}
|
||||
- {fileID: 287634993}
|
||||
- {fileID: 1631979431}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -304,6 +305,80 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!1 &1631979428
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1631979431}
|
||||
- component: {fileID: 1631979429}
|
||||
m_Layer: 0
|
||||
m_Name: UICamera
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!20 &1631979429
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1631979428}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 3
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 10
|
||||
m_Depth: 1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 32
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1631979431
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1631979428}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -100}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 690216957}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1645250796
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -423,7 +498,7 @@ Camera:
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Bits: 23
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
|
||||
@@ -56,8 +56,11 @@ internal class SceneBattle : MonoBehaviour
|
||||
}
|
||||
|
||||
// 切换场景的时候释放资源
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
|
||||
@@ -25,7 +25,10 @@ public class SceneHome : MonoBehaviour
|
||||
}
|
||||
|
||||
// 切换场景的时候释放资源
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
if (YooAssets.Initialized)
|
||||
{
|
||||
var package = YooAssets.GetPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "2.0.2-preview",
|
||||
"version": "2.0.3-preview",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system.",
|
||||
"author": {
|
||||
|
||||
Reference in New Issue
Block a user