【m】111

This commit is contained in:
2025-09-29 18:24:13 +08:00
parent f9575180f3
commit 7f42b8b451
6 changed files with 240 additions and 31 deletions

View File

@@ -144,7 +144,7 @@ namespace Stary.Evo
/// <param name="url">获取Token值的服务URL地址很重要</param>
/// <param name="postData">传入请求的参数此处参数为JOSN格式</param>
/// <returns></returns>
public static async Task<ResultMessageEntity> PostFile(string url, string[] path)
public static async Task<ResultMessageEntity> PostFile(string url, string[] path,Action<float> uploadProgress = null)
{
if (!GetTokenState())
{
@@ -174,7 +174,18 @@ namespace Stary.Evo
webRequest.disposeDownloadHandlerOnDispose = true;
webRequest.disposeCertificateHandlerOnDispose = true;
webRequest.timeout = 60;
await webRequest.SendWebRequest();
// 发送请求但不等待完成
var operation = webRequest.SendWebRequest();
// 轮询获取上传进度
while (!operation.isDone)
{
// 调用进度回调函数
uploadProgress?.Invoke(webRequest.uploadProgress);
// 等待一帧,避免阻塞
await UniTask.Yield();
}
webRequest.uploadHandler?.Dispose();
// 更新错误检查方式
if (webRequest.result == UnityWebRequest.Result.ConnectionError ||