下载界面增加开始按钮,登陆注册bug修改
This commit is contained in:
1 parent
470d52b1bc
commit
09514e2a8a
5 files changed
+1645
-1337
No files matched your search
@@ -11,13 +11,14 @@ using UnityEngine.UI;
|
||||
public class DownloadController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Transform Button,Loading,Exit;
|
||||
Transform Btn, Loading,Exit,BtnStart;
|
||||
ScrollRect scroll;
|
||||
string path;
|
||||
[SerializeField] Transform log;
|
||||
void Start()
|
||||
{
|
||||
Button = transform.Find("Panel/BtnConfirm");
|
||||
Btn = transform.Find("Panel/BtnConfirm");
|
||||
BtnStart = transform.Find("Panel/BtnStart");
|
||||
Loading = transform.Find("Panel/LoadingContainer");
|
||||
scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
|
||||
Exit = transform.Find("Panel/Exit");
|
||||
@@ -25,29 +26,39 @@ public class DownloadController : PFUIPanel
|
||||
{
|
||||
Utils.showToast(gameObject, "Please update to the latest version.");
|
||||
});
|
||||
SetType(false);
|
||||
SetType(1);
|
||||
//Button.GetComponent<Button>().enabled = false;
|
||||
//Button.GetComponent<Button>().interactable = false;
|
||||
path = Application.persistentDataPath + "/PowerFun.exe";
|
||||
UIManager.AddEvent(Button.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
UIManager.AddEvent(Btn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Application.Quit();
|
||||
Utils.ExecFile(path);
|
||||
});
|
||||
UIManager.AddEvent(BtnStart.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (_base) =>
|
||||
{
|
||||
if (App.UpdateObject != null)
|
||||
{
|
||||
BtnStart.GetComponent<Button>().enabled = false;
|
||||
BtnStart.GetComponent<Button>().interactable = false;
|
||||
StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (a, b, isComplete) =>
|
||||
{
|
||||
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {a.ToString("#0")}M / {b.ToString("#0")}M";// string.Format(, a, b);
|
||||
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)(a / b);
|
||||
if (isComplete)
|
||||
{
|
||||
SetType(3);
|
||||
|
||||
PlayerPrefs.SetString("exeVersion", App.UpdateObject.Code);
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
//transform
|
||||
if (App.UpdateObject != null)
|
||||
{
|
||||
StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (a, b, isComplete) =>
|
||||
{
|
||||
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {a.ToString("#0")}M / {b.ToString("#0")}M";// string.Format(, a, b);
|
||||
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)(a / b);
|
||||
if (isComplete)
|
||||
{
|
||||
SetType(true);
|
||||
PlayerPrefs.SetString("exeVersion", App.UpdateObject.Code);
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
}
|
||||
}));
|
||||
|
||||
for (var i = 0; i < App.UpdateObject.UpdateLog.Count; i++)
|
||||
{
|
||||
var newLog = Instantiate<Transform>(log);
|
||||
@@ -96,6 +107,7 @@ public class DownloadController : PFUIPanel
|
||||
{
|
||||
File.Delete(desFileName + ".pfdownload");
|
||||
}
|
||||
SetType(2);
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||
request.Timeout = 5000;
|
||||
WebResponse response = request.GetResponse();
|
||||
@@ -124,11 +136,29 @@ public class DownloadController : PFUIPanel
|
||||
}
|
||||
OnDownloadProgressEvent.Invoke(dDownloadedLength, dTotalLength, true);
|
||||
}
|
||||
void SetType(bool f)
|
||||
void SetType(int a)
|
||||
{
|
||||
// true 显示 button false 显示loading
|
||||
Button.gameObject.SetActive(f);
|
||||
Loading.gameObject.SetActive(!f);
|
||||
switch (a)
|
||||
{
|
||||
case 1:
|
||||
// true 显示 button false 显示loading
|
||||
Btn.gameObject.SetActive(false);
|
||||
Loading.gameObject.SetActive(false);
|
||||
BtnStart.gameObject.SetActive(true);
|
||||
break;
|
||||
case 2:
|
||||
Btn.gameObject.SetActive(false);
|
||||
Loading.gameObject.SetActive(true);
|
||||
BtnStart.gameObject.SetActive(false);
|
||||
break;
|
||||
case 3:
|
||||
Btn.gameObject.SetActive(true);
|
||||
Loading.gameObject.SetActive(false);
|
||||
BtnStart.gameObject.SetActive(false);
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
Reference in new issue
Block a user