Update YooAssetDriver

在游戏对象销毁的时候释放YooAssets
pull/40/head
hevinci 2022-09-21 11:36:28 +08:00
parent 95924868f7
commit a89127df1d
2 changed files with 22 additions and 14 deletions

View File

@ -9,6 +9,11 @@ namespace YooAsset
YooAssets.InternalUpdate(); YooAssets.InternalUpdate();
} }
void OnDestroy()
{
YooAssets.InternalDestroy();
}
void OnApplicationQuit() void OnApplicationQuit()
{ {
YooAssets.InternalDestroy(); YooAssets.InternalDestroy();

View File

@ -1072,21 +1072,24 @@ namespace YooAsset
#region 内部方法 #region 内部方法
internal static void InternalDestroy() internal static void InternalDestroy()
{ {
_isInitialize = false; if (_isInitialize)
_initializeError = string.Empty; {
_initializeStatus = EOperationStatus.None; _isInitialize = false;
_initializeError = string.Empty;
_initializeStatus = EOperationStatus.None;
_bundleServices = null; _bundleServices = null;
_locationServices = null; _locationServices = null;
_editorSimulateModeImpl = null; _editorSimulateModeImpl = null;
_offlinePlayModeImpl = null; _offlinePlayModeImpl = null;
_hostPlayModeImpl = null; _hostPlayModeImpl = null;
OperationSystem.DestroyAll(); OperationSystem.DestroyAll();
DownloadSystem.DestroyAll(); DownloadSystem.DestroyAll();
CacheSystem.DestroyAll(); CacheSystem.DestroyAll();
AssetSystem.DestroyAll(); AssetSystem.DestroyAll();
YooLogger.Log("YooAssets destroy all !"); YooLogger.Log("YooAssets destroy all !");
}
} }
internal static void InternalUpdate() internal static void InternalUpdate()
{ {
@ -1136,7 +1139,7 @@ namespace YooAsset
private static void DebugCheckUpdateManifest() private static void DebugCheckUpdateManifest()
{ {
var loadedBundleInfos = AssetSystem.GetLoadedBundleInfos(); var loadedBundleInfos = AssetSystem.GetLoadedBundleInfos();
if(loadedBundleInfos.Count > 0) if (loadedBundleInfos.Count > 0)
{ {
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !"); YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
} }