1.4.5报错版本修改
All checks were successful
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 3s
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 3s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 19s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 5s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 32s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 4s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 16s
Plugin Library CI / publish (07.RKTools) (push) Successful in 3s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 3s

This commit is contained in:
2026-04-16 22:26:36 +08:00
parent 8a000420af
commit f8ca656870
3 changed files with 30 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ using Cysharp.Threading.Tasks;
#if WECHAT_MINIGAME
using WeChatWASM;
#else
using System.IO; // 仅在非微信平台使用
using ICSharpCode.SharpZipLib.Zip;
@@ -14,7 +15,7 @@ namespace Stary.Evo.Unzip
{
public static class CrossPlatformUnzip
{
public static async UniTask UnzipAsync(string zipPath, string extractPath,
public static async UniTask UnzipAsync(string zipPath, string extractPath,
Action<float> progressCallback = null, bool deleteAfterExtract = true)
{
#if WECHAT_MINIGAME && UNITY_WEBGL
@@ -32,7 +33,7 @@ namespace Stary.Evo.Unzip
#region 1. System.IO
#if WECHAT_MINIGAME
private static async UniTask UnzipWeChatNativeAsync(string zipPath, string extractPath,
private static async UniTask UnzipWeChatNativeAsync(string zipPath, string extractPath,
Action<float> progressCallback, bool deleteAfterExtract)
{
var tcs = new UniTaskCompletionSource();
@@ -40,24 +41,24 @@ namespace Stary.Evo.Unzip
// 检查 ZIP 存在(使用微信 API
bool fileExists = false;
fs.Access(new AccessOption()
fs.Access(new AccessParam()
{
path = zipPath,
success = (res) => fileExists = true,
fail = (err) => { }
});
await UniTask.Delay(50); // 等待异步结果
if (!fileExists)
throw new Exception($"ZIP 不存在: {zipPath}");
// 清理目标目录(递归删除)
try
{
fs.RmdirSync(extractPath, true);
try
{
fs.RmdirSync(extractPath, true);
}
catch
{
catch
{
// 目录不存在或已删除
}
@@ -69,7 +70,7 @@ namespace Stary.Evo.Unzip
var progressTask = SimulateProgressAsync(progressCallback, () => reportedProgress >= 1f);
// 微信原生解压性能最佳C++ 实现)
WX.Unzip(new UnzipOption()
WX.GetFileSystemManager().Unzip(new UnzipOption()
{
zipFilePath = zipPath,
targetPath = extractPath,
@@ -79,10 +80,7 @@ namespace Stary.Evo.Unzip
progressCallback?.Invoke(1f);
tcs.TrySetResult();
},
fail = (err) =>
{
tcs.TrySetException(new Exception($"微信解压失败: {err.errMsg}"));
}
fail = (err) => { tcs.TrySetException(new Exception($"微信解压失败: {err.errMsg}")); }
});
await tcs.Task;
@@ -98,7 +96,7 @@ namespace Stary.Evo.Unzip
private static async UniTask SimulateProgressAsync(Action<float> callback, Func<bool> isCompleted)
{
if (callback == null) return;
float progress = 0f;
while (!isCompleted())
{
@@ -108,16 +106,16 @@ namespace Stary.Evo.Unzip
}
}
private static void DeleteWeChatFileSafe(FileSystemManager fs, string path)
private static void DeleteWeChatFileSafe(WXFileSystemManager fs, string path)
{
try
{
fs.UnlinkSync(path);
try
{
fs.UnlinkSync(path);
Debug.Log($"[微信] 已删除 ZIP");
}
catch (Exception ex)
{
Debug.LogWarning($"[微信] 删除失败: {ex.Message}");
catch (Exception ex)
{
Debug.LogWarning($"[微信] 删除失败: {ex.Message}");
}
}
@@ -222,8 +220,8 @@ namespace Stary.Evo.Unzip
#endregion
#region 3. PC/ System.IO
private static async UniTask UnzipStandardAsync(string zipPath, string extractPath,
#if !UNITY_WEBGL && !WECHAT_MINIGAME
private static async UniTask UnzipStandardAsync(string zipPath, string extractPath,
Action<float> progressCallback, bool deleteAfterExtract)
{
await UniTask.SwitchToThreadPool();
@@ -234,7 +232,7 @@ namespace Stary.Evo.Unzip
throw new FileNotFoundException($"ZIP 不存在: {zipPath}");
string fullExtractPath = Path.GetFullPath(extractPath);
if (Directory.Exists(extractPath))
Directory.Delete(extractPath, true);
Directory.CreateDirectory(extractPath);
@@ -244,7 +242,8 @@ namespace Stary.Evo.Unzip
{
int total = 0;
foreach (ZipEntry entry in zipFile)
if (entry.IsFile) total++;
if (entry.IsFile)
total++;
int processed = 0;
foreach (ZipEntry entry in zipFile)
@@ -263,7 +262,7 @@ namespace Stary.Evo.Unzip
}
processed++;
await UniTask.SwitchToMainThread();
progressCallback?.Invoke((float)processed / total);
await UniTask.SwitchToThreadPool();
@@ -277,7 +276,7 @@ namespace Stary.Evo.Unzip
File.Delete(zipPath);
}
}
#endif
#endregion
#region 4.
@@ -301,7 +300,7 @@ namespace Stary.Evo.Unzip
{
#if WECHAT_MINIGAME
bool exists = false;
WX.GetFileSystemManager().Access(new AccessOption()
WX.GetFileSystemManager().Access(new AccessParam()
{
path = path,
success = (res) => exists = true,

View File

@@ -7,7 +7,9 @@ using Cysharp.Threading.Tasks;
using Stary.Evo.Unzip;
using UnityEngine;
using UnityEngine.Networking;
#if WEIXINMINIGAME
using WeChatWASM;
#endif
namespace Stary.Evo
{

View File

@@ -6,7 +6,6 @@
"com.audiocore.runtime",
"com.stary.evo.runtime",
"HybridCLR.Runtime",
"ImmersalSDK",
"Informationsave.runtime",
"DOTween.Modules",
"com.stary.buildoriginality.runtime",