优化场景卸载逻辑
This commit is contained in:
何冠峰
2024-12-27 11:53:55 +08:00
parent 069e29ac07
commit 8944ec0e02
7 changed files with 59 additions and 116 deletions
@@ -112,25 +112,6 @@ namespace YooAsset
return true;
}
/// <summary>
/// 是否为主场景
/// </summary>
public bool IsMainScene()
{
if (IsValidWithWarning == false)
return false;
if (Provider is SceneProvider)
{
var temp = Provider as SceneProvider;
return temp.SceneMode == LoadSceneMode.Single;
}
else
{
throw new System.NotImplementedException();
}
}
/// <summary>
/// 异步卸载子场景
/// </summary>
@@ -147,17 +128,6 @@ namespace YooAsset
return operation;
}
// 如果是主场景
if (IsMainScene())
{
string error = $"Cannot unload main scene. Use {nameof(YooAssets.LoadSceneAsync)} method to change the main scene !";
YooLogger.Error(error);
var operation = new UnloadSceneOperation(error);
OperationSystem.StartOperation(packageName, operation);
return operation;
}
// 卸载子场景
// 注意:如果场景正在加载过程,必须等待加载完成后才可以卸载该场景。
{
var operation = new UnloadSceneOperation(Provider);