com.alicizax.unity.tuyoogam.../RuntimeExtension/ExtensionFileSystem/WechatFileSystem/Operation/WXFSClearAllBundleFilesOperation.cs

58 lines
1.5 KiB
C#
Raw Normal View History

2025-01-09 11:31:04 +08:00
#if UNITY_WEBGL && WEIXINMINIGAME
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using YooAsset;
using WeChatWASM;
2025-02-05 13:06:28 +08:00
internal class WXFSClearAllBundleFilesOperation : FSClearCacheFilesOperation
2025-01-09 11:31:04 +08:00
{
private enum ESteps
{
None,
ClearAllCacheFiles,
2025-02-28 16:11:01 +08:00
WaitResult,
2025-01-09 11:31:04 +08:00
Done,
}
private readonly WechatFileSystem _fileSystem;
private ESteps _steps = ESteps.None;
internal WXFSClearAllBundleFilesOperation(WechatFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
2025-02-28 16:11:01 +08:00
internal override void InternalStart()
2025-01-09 11:31:04 +08:00
{
_steps = ESteps.ClearAllCacheFiles;
}
2025-02-28 16:11:01 +08:00
internal override void InternalUpdate()
2025-01-09 11:31:04 +08:00
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.ClearAllCacheFiles)
{
2025-02-28 16:11:01 +08:00
_steps = ESteps.WaitResult;
2025-01-09 11:31:04 +08:00
WX.CleanAllFileCache((bool isOk) =>
{
if (isOk)
2025-02-28 16:11:01 +08:00
{
2025-01-09 11:31:04 +08:00
YooLogger.Log("微信缓存清理成功!");
2025-02-28 16:11:01 +08:00
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
2025-01-09 11:31:04 +08:00
else
2025-02-28 16:11:01 +08:00
{
2025-01-09 11:31:04 +08:00
YooLogger.Log("微信缓存清理失败!");
2025-02-28 16:11:01 +08:00
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "微信缓存清理失败!";
}
2025-01-09 11:31:04 +08:00
});
}
}
}
#endif