Yooasset add destroy methods

增加销毁机制
pull/13/head
hevinci 2022-06-15 18:14:04 +08:00
parent 8deb239450
commit 0b1990f040
6 changed files with 48 additions and 7 deletions

View File

@ -63,6 +63,19 @@ namespace YooAsset
} }
} }
/// <summary>
/// 销毁
/// </summary>
public static void DestroyAll()
{
_loaders.Clear();
_providers.Clear();
_sceneHandles.Clear();
DecryptionServices = null;
BundleServices = null;
}
/// <summary> /// <summary>
/// 资源回收(卸载引用计数为零的资源) /// 资源回收(卸载引用计数为零的资源)
/// </summary> /// </summary>

View File

@ -51,6 +51,9 @@ namespace YooAsset
return; return;
} }
if (_handle.IsDone == false)
return;
if (_handle.AssetObject == null) if (_handle.AssetObject == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;

View File

@ -58,7 +58,9 @@ namespace YooAsset
downloader.Abort(); downloader.Abort();
} }
_downloaderDic.Clear(); _downloaderDic.Clear();
YooLogger.Log("DownloadSystem destroy all !"); _removeList.Clear();
_cachedHashList.Clear();
_breakpointResumeFileSize = int.MaxValue;
} }

View File

@ -45,6 +45,17 @@ namespace YooAsset
} }
} }
/// <summary>
/// 销毁异步操作系统
/// </summary>
public static void DestroyAll()
{
_operations.Clear();
_watch = null;
_maxTimeSlice = 0;
_frameTime = 0;
}
/// <summary> /// <summary>
/// 开始处理异步操作类 /// 开始处理异步操作类
/// </summary> /// </summary>

View File

@ -11,7 +11,7 @@ namespace YooAsset
void OnApplicationQuit() void OnApplicationQuit()
{ {
DownloadSystem.DestroyAll(); YooAssets.InternalDestroy();
} }
} }
} }

View File

@ -925,15 +925,27 @@ namespace YooAsset
#endregion #endregion
#region 内部方法 #region 内部方法
internal static void InternalDestroy()
{
_isInitialize = false;
_initializeError = string.Empty;
_initializeStatus = EOperationStatus.None;
_bundleServices = null;
_locationServices = null;
_editorSimulateModeImpl = null;
_offlinePlayModeImpl = null;
_hostPlayModeImpl = null;
OperationSystem.DestroyAll();
DownloadSystem.DestroyAll();
AssetSystem.DestroyAll();
YooLogger.Log("YooAssets destroy all !");
}
internal static void InternalUpdate() internal static void InternalUpdate()
{ {
// 更新异步操作系统
OperationSystem.Update(); OperationSystem.Update();
// 更新下载管理系统
DownloadSystem.Update(); DownloadSystem.Update();
// 更新资源系统
AssetSystem.Update(); AssetSystem.Update();
} }