Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo
This commit is contained in:
commit
cfcb302a31
Binary file not shown.
|
Before Width: | Height: | Size: 1022 B After Width: | Height: | Size: 1.5 KiB |
@ -46,7 +46,7 @@ TextureImporter:
|
|||||||
alignment: 0
|
alignment: 0
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
spritePixelsToUnits: 100
|
spritePixelsToUnits: 100
|
||||||
spriteBorder: {x: 15, y: 15, z: 15, w: 15}
|
spriteBorder: {x: 30, y: 30, z: 30, w: 30}
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
alphaUsage: 1
|
alphaUsage: 1
|
||||||
alphaIsTransparency: 1
|
alphaIsTransparency: 1
|
||||||
|
|||||||
1307
Assets/Resources/UI/Prefab/Panel/DownloadWorkoutsModal.prefab
Normal file
1307
Assets/Resources/UI/Prefab/Panel/DownloadWorkoutsModal.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a70dccad18e97dd46b2b739e228989cc
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -332,6 +332,7 @@ GameObject:
|
|||||||
- component: {fileID: 3445340291243714514}
|
- component: {fileID: 3445340291243714514}
|
||||||
- component: {fileID: 3445340291243714524}
|
- component: {fileID: 3445340291243714524}
|
||||||
- component: {fileID: 3340209317336321644}
|
- component: {fileID: 3340209317336321644}
|
||||||
|
- component: {fileID: 2919480864831927539}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: RaceHomePanel
|
m_Name: RaceHomePanel
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -382,6 +383,18 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 93263b6a2a269ae4fb052ec2c022251c, type: 3}
|
m_Script: {fileID: 11500000, guid: 93263b6a2a269ae4fb052ec2c022251c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!225 &2919480864831927539
|
||||||
|
CanvasGroup:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 3445340291243714513}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Alpha: 1
|
||||||
|
m_Interactable: 1
|
||||||
|
m_BlocksRaycasts: 1
|
||||||
|
m_IgnoreParentGroups: 0
|
||||||
--- !u!1 &4573235035984813200
|
--- !u!1 &4573235035984813200
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -673,7 +673,7 @@ RectTransform:
|
|||||||
m_GameObject: {fileID: 1372050265900358655}
|
m_GameObject: {fileID: 1372050265900358655}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1.5779092, y: 1.5779092, z: 1.5779092}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 71653441858533815}
|
- {fileID: 71653441858533815}
|
||||||
- {fileID: 71653441061169207}
|
- {fileID: 71653441061169207}
|
||||||
@ -812,6 +812,7 @@ GameObject:
|
|||||||
- component: {fileID: 1673965681348374004}
|
- component: {fileID: 1673965681348374004}
|
||||||
- component: {fileID: 1673965681348374010}
|
- component: {fileID: 1673965681348374010}
|
||||||
- component: {fileID: 3032364714008089124}
|
- component: {fileID: 3032364714008089124}
|
||||||
|
- component: {fileID: 7732217181960295751}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: RaceListPanel
|
m_Name: RaceListPanel
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -862,6 +863,18 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 82b3faa60bd657241a826920f2d8ad14, type: 3}
|
m_Script: {fileID: 11500000, guid: 82b3faa60bd657241a826920f2d8ad14, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!225 &7732217181960295751
|
||||||
|
CanvasGroup:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1673965681348374007}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Alpha: 0
|
||||||
|
m_Interactable: 1
|
||||||
|
m_BlocksRaycasts: 1
|
||||||
|
m_IgnoreParentGroups: 0
|
||||||
--- !u!1 &2363214934641726875
|
--- !u!1 &2363214934641726875
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -519,7 +519,7 @@ namespace Assets.Scripts.Apis
|
|||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
|
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
|
||||||
request.Accept = "application/json";
|
request.Accept = "application/json";
|
||||||
request.Headers.Add("Language", "Zh-cn");
|
request.Headers.Add("Language", "en");
|
||||||
request.CookieContainer = new CookieContainer();
|
request.CookieContainer = new CookieContainer();
|
||||||
foreach (Cookie item in cookies)
|
foreach (Cookie item in cookies)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -82,7 +82,7 @@ namespace Assets.Scripts.UI.Control
|
|||||||
{
|
{
|
||||||
case Type.Normal:
|
case Type.Normal:
|
||||||
{
|
{
|
||||||
image.color = ConvertColor("#414251");
|
image.color = ConvertColor("#303030");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type.Border:
|
case Type.Border:
|
||||||
@ -152,7 +152,7 @@ namespace Assets.Scripts.UI.Control
|
|||||||
{
|
{
|
||||||
case Type.Normal:
|
case Type.Normal:
|
||||||
{
|
{
|
||||||
image.color = ConvertColor("#414251");
|
image.color = ConvertColor("#303030");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Type.Border:
|
case Type.Border:
|
||||||
|
|||||||
@ -340,6 +340,10 @@ public class EditUserController : PFUIPanel
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.CurrentUser = JObject.FromObject(result.data).ToObject<UserResultModel>();
|
App.CurrentUser = JObject.FromObject(result.data).ToObject<UserResultModel>();
|
||||||
|
if (App.CurrentUser.Birthday.HasValue)
|
||||||
|
{
|
||||||
|
App.CurrentUser.Birthday = App.CurrentUser.Birthday.Value.ToLocalTime();
|
||||||
|
}
|
||||||
var userinfos = UIManager.Instance.userInfos;
|
var userinfos = UIManager.Instance.userInfos;
|
||||||
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
|
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
|
|||||||
@ -13,12 +13,17 @@ public class RaceHomeScript : RaceScript
|
|||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
private ScrollRect scroll;
|
private ScrollRect scroll;
|
||||||
private Transform content,rightContainer,leftContainer,btnGoList,avatar;
|
private Transform content,rightContainer,leftContainer,btnGoList;
|
||||||
private float contentSize;
|
private float contentSize;
|
||||||
private int count;
|
private int count;
|
||||||
private Button L, R;
|
private Button L, R;
|
||||||
//当前鼠标悬浮的卡片
|
//当前鼠标悬浮的卡片
|
||||||
async void Start()
|
public override void Show()
|
||||||
|
{
|
||||||
|
base.Show();
|
||||||
|
handleAvatar();
|
||||||
|
}
|
||||||
|
void Start()
|
||||||
{
|
{
|
||||||
scroll = transform.Find("LeftContainer/Swiper").GetComponent<ScrollRect>();
|
scroll = transform.Find("LeftContainer/Swiper").GetComponent<ScrollRect>();
|
||||||
content = scroll.content;
|
content = scroll.content;
|
||||||
@ -43,38 +48,31 @@ public class RaceHomeScript : RaceScript
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
StartTime();
|
StartTime();
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (App.CurrentUser == null) //App.CurrentUser == null
|
|
||||||
{
|
|
||||||
await Login();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
rightContainer = transform.Find("RightContainer");
|
rightContainer = transform.Find("RightContainer");
|
||||||
leftContainer = transform.Find("LeftContainer");
|
leftContainer = transform.Find("LeftContainer");
|
||||||
btnGoList = rightContainer.Find("Container-2/BtnGoList");
|
btnGoList = rightContainer.Find("Container-2/BtnGoList");
|
||||||
UIManager.AddEvent(btnGoList.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
UIManager.AddEvent(btnGoList.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||||
{
|
{
|
||||||
UIManager.ShowRaceListPanel();
|
transform.GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = () =>
|
||||||
|
{
|
||||||
|
UIManager.ShowRaceListPanel();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
avatar = transform.Find("Avatar");
|
handleAvatar();
|
||||||
if (avatar != null)
|
GetData();
|
||||||
{
|
}
|
||||||
Utils.DisplayImage(avatar.GetComponent<RawImage>(), App.CurrentUser.WxHeadImg, true);
|
|
||||||
UIManager.AddEvent(avatar.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
async void GetData()
|
||||||
{
|
{
|
||||||
UIManager.ShowUserInfoPanel();
|
var r = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 7, order: 0);
|
||||||
});
|
var activityList = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 3, activity: 1, order: 1);
|
||||||
}
|
DisplayMaps(r.data, activityList.data);
|
||||||
var r = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 7,order:0);
|
|
||||||
var activityList = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 3, activity: 1,order:1);
|
|
||||||
DisplayMaps(r.data,activityList.data);
|
|
||||||
Initial();
|
Initial();
|
||||||
Utils.StartTimeUnLimit(10, () =>
|
Utils.StartTimeUnLimit(10, () =>
|
||||||
{
|
{
|
||||||
goRight();
|
goRight();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayMaps(List<MapCompetition> list, List<MapCompetition> activityList)
|
private void DisplayMaps(List<MapCompetition> list, List<MapCompetition> activityList)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@ -46,7 +46,10 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
|||||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = mapCompetition.ApplyCount.ToString();
|
transform.Find("CountContainer/Text").GetComponent<Text>().text = mapCompetition.ApplyCount.ToString();
|
||||||
SetStatus(mapCompetition);
|
SetStatus(mapCompetition);
|
||||||
SetButtonGroup(mapCompetition);
|
SetButtonGroup(mapCompetition);
|
||||||
this.parent = parent;
|
if (parent != null)
|
||||||
|
{
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
this.mapCompetition = mapCompetition;
|
this.mapCompetition = mapCompetition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using Assets.Scripts;
|
using Assets.Scripts;
|
||||||
using Assets.Scripts.Apis.Models;
|
using Assets.Scripts.Apis.Models;
|
||||||
using Assets.Scripts.UI.Prefab.Race;
|
using Assets.Scripts.UI.Prefab.Race;
|
||||||
|
using DG.Tweening;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -21,15 +22,14 @@ public class RaceListScript : RaceScript
|
|||||||
private List<string> statusOptions = new List<string>();
|
private List<string> statusOptions = new List<string>();
|
||||||
bool isReserve = false;
|
bool isReserve = false;
|
||||||
int order = 1;
|
int order = 1;
|
||||||
//筛选条件
|
public override void Show()
|
||||||
async void Start()
|
{
|
||||||
|
base.Show();
|
||||||
|
handleAvatar();
|
||||||
|
}
|
||||||
|
//筛选条件
|
||||||
|
void Start()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (App.CurrentUser == null) //App.CurrentUser == null
|
|
||||||
{
|
|
||||||
await Login();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
scroll = transform.Find("ListContainer/List").gameObject;
|
scroll = transform.Find("ListContainer/List").gameObject;
|
||||||
if (scroll != null)
|
if (scroll != null)
|
||||||
{
|
{
|
||||||
@ -108,18 +108,13 @@ public class RaceListScript : RaceScript
|
|||||||
{
|
{
|
||||||
UIManager.AddEvent(btnReturn.gameObject, EventTriggerType.PointerClick, (b) =>
|
UIManager.AddEvent(btnReturn.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||||
{
|
{
|
||||||
UIManager.ShowRaceHomePanel(true);
|
transform.GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = () =>
|
||||||
});
|
{
|
||||||
}
|
UIManager.ShowRaceHomePanel(true);
|
||||||
avatar = transform.Find("Avatar");
|
};
|
||||||
if (avatar != null)
|
|
||||||
{
|
|
||||||
Utils.DisplayImage(avatar.GetComponent<RawImage>(), App.CurrentUser.WxHeadImg, true);
|
|
||||||
UIManager.AddEvent(avatar.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
|
||||||
{
|
|
||||||
UIManager.ShowUserInfoPanel();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
handleAvatar();
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +129,6 @@ public class RaceListScript : RaceScript
|
|||||||
{
|
{
|
||||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||||
{
|
{
|
||||||
Debug.Log(scroll.GetComponent<ScrollRect>().verticalNormalizedPosition);
|
|
||||||
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Assets.Scripts;
|
using Assets.Scripts;
|
||||||
|
using DG.Tweening;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -8,6 +9,11 @@ public class RaceScript : PFUIPanel
|
|||||||
{
|
{
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
protected Transform currentItem { get; set; }
|
protected Transform currentItem { get; set; }
|
||||||
|
public override void Show()
|
||||||
|
{
|
||||||
|
base.Show();
|
||||||
|
transform.GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||||
|
}
|
||||||
protected void StartTime()
|
protected void StartTime()
|
||||||
{
|
{
|
||||||
timerFlag = true;
|
timerFlag = true;
|
||||||
@ -34,6 +40,20 @@ public class RaceScript : PFUIPanel
|
|||||||
StopTime();
|
StopTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private Transform avatar;
|
||||||
|
protected void handleAvatar()
|
||||||
|
{
|
||||||
|
avatar = transform.Find("Avatar");
|
||||||
|
if (avatar != null)
|
||||||
|
{
|
||||||
|
Debug.Log(App.CurrentUser.WxHeadImg);
|
||||||
|
Utils.DisplayImage(avatar.GetComponent<RawImage>(), App.CurrentUser.WxHeadImg, true);
|
||||||
|
UIManager.AddEvent(avatar.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||||
|
{
|
||||||
|
UIManager.ShowUserInfoPanel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
/*参考代码
|
/*参考代码
|
||||||
var second = Math.Ceiling((Now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
|
var second = Math.Ceiling((Now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
|
||||||
|
|
||||||
@ -54,7 +74,6 @@ public class RaceScript : PFUIPanel
|
|||||||
if (currentItem != null && currentItem.Find("GetReadyContainer").gameObject.activeSelf)
|
if (currentItem != null && currentItem.Find("GetReadyContainer").gameObject.activeSelf)
|
||||||
{
|
{
|
||||||
var map = currentItem.GetComponent<RaceItemScript>().mapCompetition;
|
var map = currentItem.GetComponent<RaceItemScript>().mapCompetition;
|
||||||
Debug.Log(map.Status);
|
|
||||||
if (map.Status == 1)
|
if (map.Status == 1)
|
||||||
{
|
{
|
||||||
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "Application Start Time";
|
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "Application Start Time";
|
||||||
@ -67,16 +86,21 @@ public class RaceScript : PFUIPanel
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Dictionary<int,>
|
//Dictionary<int,>
|
||||||
var time = (map.Status == 1 ? map.StartTime.ToLocalTime() : map.EndTime.ToLocalTime()) - UIManager.Now.GetDateTime();
|
var time = (map.Status == 2 ? map.StartTime.ToLocalTime() : map.EndTime.ToLocalTime()) - UIManager.Now.GetDateTime();
|
||||||
if (time.TotalSeconds < 0)
|
if (time.TotalSeconds < 0)
|
||||||
{
|
{
|
||||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 0;
|
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 0;
|
||||||
|
var res = ConfigHelper.mapCompetitionApi.GetById(map.Id);
|
||||||
|
if (res.result)
|
||||||
|
{
|
||||||
|
currentItem.GetComponent<RaceItemScript>().Initial(res.data, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 1;
|
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 1;
|
||||||
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text
|
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text
|
||||||
= map.Status == 1 ? "Get Ready" : "Riding Time";
|
= map.Status == 2 ? "Get Ready" : "Riding Time";
|
||||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text
|
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text
|
||||||
= Utils.GetCountDown(time);
|
= Utils.GetCountDown(time);
|
||||||
}
|
}
|
||||||
|
|||||||
168
Assets/Scripts/UI/Prefab/Update/DownloadWorkoutsController.cs
Normal file
168
Assets/Scripts/UI/Prefab/Update/DownloadWorkoutsController.cs
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
using Assets.Scripts;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class DownloadWorkoutsController : PFUIPanel
|
||||||
|
{
|
||||||
|
// Start is called before the first frame update
|
||||||
|
Transform Btn, Loading,Exit,BtnStart;
|
||||||
|
ScrollRect scroll;
|
||||||
|
string path;
|
||||||
|
[SerializeField] Transform log;
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
UIManager.AddEvent(Exit.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||||
|
{
|
||||||
|
Utils.showToast(gameObject, "Please update to the latest version.");
|
||||||
|
});
|
||||||
|
SetType(1);
|
||||||
|
//Button.GetComponent<Button>().enabled = false;
|
||||||
|
//Button.GetComponent<Button>().interactable = false;
|
||||||
|
path = Application.persistentDataPath + "/PowerFun.exe";
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (var i = 0; i < App.UpdateObject.UpdateLog.Count; i++)
|
||||||
|
{
|
||||||
|
var newLog = Instantiate<Transform>(log);
|
||||||
|
newLog.GetComponent<DownloadLog>().Initial(App.UpdateObject.UpdateLog[i]);
|
||||||
|
if (i == App.UpdateObject.UpdateLog.Count - 1)
|
||||||
|
{
|
||||||
|
newLog.GetComponent<DownloadLog>().HideLine();
|
||||||
|
}
|
||||||
|
newLog.SetParent(scroll.content);
|
||||||
|
newLog.localScale = Vector3.one;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*下载文件*/
|
||||||
|
IEnumerator DownLoadExe(string url, string desFileName, Action<double, double, bool> OnDownloadProgressEvent)
|
||||||
|
{
|
||||||
|
string version = null;
|
||||||
|
if (App.UpdateObject != null)
|
||||||
|
{
|
||||||
|
version = App.UpdateObject.Code;
|
||||||
|
}
|
||||||
|
if (File.Exists(desFileName))
|
||||||
|
{
|
||||||
|
//if(PlayerPrefs.GetString("exeVersion")==)
|
||||||
|
if (version == null)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (version == PlayerPrefs.GetString("exeVersion"))
|
||||||
|
{
|
||||||
|
Application.Quit();
|
||||||
|
Utils.ExecFile(desFileName);
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Delete(desFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//File.Delete(desFileName);
|
||||||
|
}
|
||||||
|
if (File.Exists(desFileName + ".pfdownload"))
|
||||||
|
{
|
||||||
|
File.Delete(desFileName + ".pfdownload");
|
||||||
|
}
|
||||||
|
SetType(2);
|
||||||
|
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||||
|
request.Timeout = 5000;
|
||||||
|
WebResponse response = request.GetResponse();
|
||||||
|
//UnityWebRequest request = UnityWebRequest.Get(url);
|
||||||
|
//yield return request.SendWebRequest();
|
||||||
|
int packLength = 1024 * 20;
|
||||||
|
int nReadSize = 0;
|
||||||
|
byte[] nbytes = new byte[packLength];
|
||||||
|
double dDownloadedLength = 0, dTotalLength = 0;
|
||||||
|
long countLength = response.ContentLength;
|
||||||
|
using (FileStream fs = new FileStream(desFileName + ".pfdownload", FileMode.Create))
|
||||||
|
using (Stream netStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
nReadSize = netStream.Read(nbytes, 0, packLength);
|
||||||
|
while (nReadSize > 0)
|
||||||
|
{
|
||||||
|
fs.Write(nbytes, 0, nReadSize);
|
||||||
|
nReadSize = netStream.Read(nbytes, 0, packLength);
|
||||||
|
dDownloadedLength = fs.Length * 1.0 / (1024 * 1024);
|
||||||
|
dTotalLength = countLength * 1.0 / (1024 * 1024);
|
||||||
|
OnDownloadProgressEvent.Invoke(dDownloadedLength, dTotalLength, false);
|
||||||
|
//string ss = string.Format("已下载 {0:F}M / {1:F}M", dDownloadedLength, dTotalLength);
|
||||||
|
//Debug.Log(ss);
|
||||||
|
yield return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OnDownloadProgressEvent.Invoke(dDownloadedLength, dTotalLength, true);
|
||||||
|
}
|
||||||
|
void SetType(int a)
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 81b820d9d4046d241b2e472e6a81b430
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -169,6 +169,21 @@ public class UIManager : MonoBehaviour
|
|||||||
UIManager.Show(UIManager.Instance.RaceListPanel, UIManager.Instance.MainPanel);
|
UIManager.Show(UIManager.Instance.RaceListPanel, UIManager.Instance.MainPanel);
|
||||||
}
|
}
|
||||||
/*比赛列表*/
|
/*比赛列表*/
|
||||||
|
/*比赛列表*/
|
||||||
|
private DownloadWorkoutsController mDownloadWorkoutsController;
|
||||||
|
public DownloadWorkoutsController DownloadWorkoutsModal
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.GetPanelInstance("DownloadWorkoutsModal", ref this.mDownloadWorkoutsController);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void ShowDownloadWorkoutsPanel()
|
||||||
|
{
|
||||||
|
UIManager.Show(UIManager.Instance.DownloadWorkoutsModal, null, true);
|
||||||
|
//UIManager.Show(UIManager.Instance.RaceListPanel, UIManager.Instance.MainPanel);
|
||||||
|
}
|
||||||
|
/*比赛列表*/
|
||||||
private PFUIPanel mModalsPanel;
|
private PFUIPanel mModalsPanel;
|
||||||
public PFUIPanel ModalsPanel
|
public PFUIPanel ModalsPanel
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user