AR继续骑和断线重连继续骑

This commit is contained in:
lishuo committed 2022-12-08 19:17:34 +08:00
1 parent ae58f4d461
commit 9e2e778e12
34 files changed
+3828 -497977

No files matched your search

+27
View File
@@ -1,10 +1,14 @@
using Assets.Scenes.Ride.Scripts;
using Assets.Scripts.Apis.Models;
using Cysharp.Threading.Tasks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using UnityEngine;
using UnityEngine.Networking;
/// <summary>
/// 异步线程更新ui工具类
@@ -174,4 +178,27 @@ public class Loom : MonoBehaviour
_current = null;
}
}
public static async void Download(MapRoute route)
{
var progress = Progress.Create<float>(x =>
DownLoadTaskList[route.FileName] = x
);
DownLoadTaskList.Add(route.FileName, 0);
var path = PFConstants.VideoFolder;
var localPath = PFConstants.ARFolder;
var arDataPath = route.ARConfig;
var videoRoute = route.VideoRoute;
var cancelToken = new CancellationTokenSource();
var res1 = await UnityWebRequest.Get(arDataPath).SendWebRequest().WithCancellation(cancelToken.Token);//下载AR数据
var res2 = await UnityWebRequest.Get(videoRoute).SendWebRequest().WithCancellation(cancelToken.Token);//下载video视频数据
var res3 = await UnityWebRequest.Get(route.Url).SendWebRequest().ToUniTask(progress);//下载视频
var dataPath = $"{localPath}/{route.Id}";
Helper.CreateDirectoryIfNotExsit(dataPath);
Helper.CreateDirectoryIfNotExsit(dataPath);
File.WriteAllBytes($"{dataPath}/{route.Id}.json", res1.downloadHandler.data);
File.WriteAllBytes($"{dataPath}/route-{route.Id}.json", res2.downloadHandler.data);
File.WriteAllBytes($"{path}/{route.FileName}", res3.downloadHandler.data);
}
}