Optimize the scene unload logic.

优化场景卸载逻辑,在加载新的主场景的时候自动卸载已经加载的所有场景。
This commit is contained in:
hevinci
2022-04-21 21:11:11 +08:00
parent 20d2c517b2
commit f3ab8f63e7
7 changed files with 112 additions and 58 deletions
@@ -4,11 +4,13 @@ namespace YooAsset
{
public abstract class OperationHandleBase : IEnumerator
{
private readonly string _cachedAssetPath;
internal ProviderBase _provider { private set; get; }
internal OperationHandleBase(ProviderBase provider)
{
_provider = provider;
_cachedAssetPath = provider.AssetPath;
}
internal abstract void InvokeCallback();
@@ -63,7 +65,18 @@ namespace YooAsset
{
get
{
return _provider != null && _provider.IsDestroyed == false;
if (_provider != null && _provider.IsDestroyed == false)
{
return true;
}
else
{
if (_provider == null)
YooLogger.Warning($"Operation handle is released : {_cachedAssetPath}");
else if (_provider.IsDestroyed)
YooLogger.Warning($"Provider is destroyed : {_cachedAssetPath}");
return false;
}
}
}