ar骑行bug fix

This commit is contained in:
lishuo committed 2023-02-07 18:35:16 +08:00
1 parent 2c9440f656
commit 08b92e7e9b
37 files changed
+3233 -3358

No files matched your search

@@ -1,6 +1,7 @@
using Assets.Scenes.Ride.Scripts;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Cysharp.Threading.Tasks;
using PolyAndCode.UI;
using System;
using System.Collections.Generic;
@@ -31,8 +32,9 @@ class GameRoomDownLoad : MonoBehaviour
public GameObject downLoadTask;
private GameRoomListController manager;
private int RoomId { get; set; }
private string FileName { get; set; }
public int RoomId { get; set; }
public string FileName { get; set; }
public string RouteName { get; set; }
private string FileUrl { get; set; }
private void Start()
{
@@ -69,23 +71,27 @@ class GameRoomDownLoad : MonoBehaviour
private void Update()
{
if (!string.IsNullOrEmpty(FileName) && Loom.DownLoadTaskList.ContainsKey(FileName))
{
processing(Loom.DownLoadTaskList[FileName]);
}
//if (!string.IsNullOrEmpty(FileName) && Loom.DownloadStack.ContainsKey(FileName))
//{
// processing(Loom.DownloadStack[FileName]);
//}
}
public void Init(int Id,string fileName,string url, GameRoomListController gameRoomListController)
public void Init(int Id, string fileName, string url, GameRoomListController gameRoomListController, string routeName)
{
RoomId = Id;
FileName = fileName;
RouteName = routeName;
FileUrl = url;
manager = gameRoomListController;
}
public void ComeIntoStep2(string fileName)
public void ComeIntoStep2(string fileName, string routeName)
{
FileName = fileName;
RouteName = routeName;
step2.SetActive(true);
step2.transform.Find("RouteName").GetComponent<Text>().text = routeName;
step3.transform.Find("RouteName").GetComponent<Text>().text = routeName;
step3.SetActive(false);
}
@@ -103,60 +109,34 @@ class GameRoomDownLoad : MonoBehaviour
private void processing(float p)
{
downloadSlider.value = p;
if (Loom.DownLoadTaskList.ContainsKey(FileName))
if (!Loom.DownloadStack.ContainsKey(FileName) )
{
Loom.DownLoadTaskList[FileName] = p;
Loom.DownloadStack.Add(FileName, new Assets.Core.DownloadInfo(FileName, RouteName, p));
}
else
Loom.DownloadStack[FileName].Process = p;
if (p >= 1)
{
Loom.DownLoadTaskList.Add(FileName, p);
Loom.DownloadStack.Remove(FileName);
}
}
private void DownloadClick(BaseEventData baseEventData)
private async void DownloadClick(BaseEventData baseEventData)
{
var fileName = FileName;
var path = PFConstants.VideoFolder;
var filepath = path + "/" + fileName;
var url = FileUrl;
step2.SetActive(true);
step2.transform.Find("RouteName").GetComponent<Text>().text = RouteName;
//新增
var content = downLoadList.transform.Find("Viewport/Content");
var newtask = Instantiate(downLoadTask, content);
var currentTask = newtask.GetComponent<GameRoomDownloadTask>();
currentTask.Init(RoomId, fileName,gameObject);
Loom.Current.StartCoroutine(Utils.DownloadFileWithProcess(fileName, url
, path,(p, req) =>
{
currentTask.UpdateProcess(p);
processing(p);
}
, (p) =>
{
if (string.IsNullOrEmpty(p))
var filepath = PFConstants.VideoFolder + "/" + FileName;
await Loom.DownloadToFileAsync(FileUrl, filepath, Progress.Create<float>(x => {
processing(x);
if (x >= 1)
{
var process = 100f;
if (Loom.DownLoadTaskList.ContainsKey(FileName))
{
Loom.DownLoadTaskList[FileName] = process;
}
else
{
Loom.DownLoadTaskList.Add(FileName, process);
}
currentTask.UpdateProcess(process);
downloadSlider.value = process;
downloadSlider.value = 100;
step3.SetActive(true);
step3.transform.Find("RouteName").GetComponent<Text>().text = RouteName;
}
else
{
Utils.showToast(gameObject, p);
}
}
));
}));
}
}
@@ -18,32 +18,41 @@ class GameRoomDownloadTask : MonoBehaviour
private Text fileNameText;
public int RoomId { get; set; }
public string RouteName { get; set; }
public string FileName { get; set; }
private void Start()
{
UIManager.AddEvent(btn, EventTriggerType.PointerClick, (e) =>
{
modal.SetActive(true);
modal.GetComponent<GameRoomDownLoad>().ComeIntoStep2(FileName);
if (!modal.transform.parent.Find("MapList").gameObject.activeSelf)
{
modal.SetActive(true);
modal.GetComponent<GameRoomDownLoad>().ComeIntoStep2(FileName, RouteName);
}
else
{
modal.SetActive(false);
}
//transform.parent.parent.parent.gameObject.SetActive(false);
});
}
public void Init(int roomId,string fileName,GameObject downloadPanel)
public void Init(int roomId,string fileName,string routeName,GameObject downloadPanel)
{
modal = downloadPanel;
fileNameText = transform.Find("Text").GetComponent<Text>();
RoomId = roomId;
fileNameText.text = fileName;
RouteName = routeName;
fileNameText.text = routeName;
FileName = fileName;
}
private void Update()
{
if (Loom.DownLoadTaskList.ContainsKey(FileName))
if (Loom.DownloadStack.ContainsKey(FileName))
{
UpdateProcess(Loom.DownLoadTaskList[FileName]);
UpdateProcess(Loom.DownloadStack[FileName].Process);
}
}
@@ -55,11 +64,12 @@ class GameRoomDownloadTask : MonoBehaviour
done.SetActive(true);
doneTxt.SetActive(true);
icon.SetActive(false);
Loom.DownloadStack.Remove(FileName);
canvasGroup.DOFade(0, 2).onComplete += () =>
{
slider.gameObject.SetActive(false);
gameObject.Destroy();
Loom.DownLoadTaskList.Remove(FileName);
Loom.DownloadStack.Remove(FileName);
};
}
}
@@ -72,7 +72,7 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
var path = PFConstants.VideoFolder;
var filepath = path + "/" + fileName;
transform.Find("DownLoadModal").gameObject.SetActive(map.EnableAR && !File.Exists(filepath));
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, (e) =>
UIManager.AddEvent(downloadBtn, EventTriggerType.PointerClick, async (e) =>
{
downloadBtn.SetActive(false);
downloading.SetActive(true);
@@ -80,19 +80,12 @@ public class GameRoomMapItem : MonoBehaviour, IPointerExitHandler, IPointerEnter
slider.gameObject.SetActive(true);
var progress = Progress.Create<float>(x =>
{
Loom.DownLoadTaskList[map.FileName] = x;
Loom.DownloadStack[map.FileName].Process = x;
slider.value = x;
LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)this.slider.transform);
if (x == 1)
{
transform.Find("DownLoadModal").gameObject.SetActive(false);
}
else
{
transform.Find("DownLoadModal").gameObject.SetActive(true);
}
transform.Find("DownLoadModal").gameObject.SetActive(x!=1);
});
Loom.Download(map, progress);
await Loom.DownloadLoadARDataAndVideo(map, progress);
});
transform.Find("Name").GetComponent<Text>().text = myMap.Name;