下载速度,修改文案

This commit is contained in:
CaiYanPeng 2021-07-28 21:09:34 +08:00
parent abf913b467
commit 5c96b10385
12 changed files with 203 additions and 380 deletions

View File

@ -498,7 +498,7 @@ PrefabInstance:
- target: {fileID: 2018962972499165240, guid: d1deda2310a3a7241a8e0d559585b30d,
type: 3}
propertyPath: m_SizeDelta.x
value: -160
value: -40
objectReference: {fileID: 0}
- target: {fileID: 2018962972499165240, guid: d1deda2310a3a7241a8e0d559585b30d,
type: 3}

View File

@ -1,125 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &324517120097755922
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7867355229879358215}
- component: {fileID: 401565169364265975}
- component: {fileID: 4917847300674325243}
- component: {fileID: 8712137697155684395}
- component: {fileID: 4576862853245034537}
m_Layer: 5
m_Name: Scroll View
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &7867355229879358215
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 324517120097755922}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4690766463415434102}
m_Father: {fileID: 3706567255822698944}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -130}
m_SizeDelta: {x: 670, y: 294}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &401565169364265975
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 324517120097755922}
m_CullTransparentMesh: 0
--- !u!114 &4917847300674325243
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 324517120097755922}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.13725491, g: 0.13725491, b: 0.1764706, a: 0.9019608}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &8712137697155684395
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 324517120097755922}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 8500537348802214361}
m_Horizontal: 0
m_Vertical: 1
m_MovementType: 1
m_Elasticity: 0.1
m_Inertia: 1
m_DecelerationRate: 0.135
m_ScrollSensitivity: 50
m_Viewport: {fileID: 4690766463415434102}
m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 0}
m_HorizontalScrollbarVisibility: 2
m_VerticalScrollbarVisibility: 2
m_HorizontalScrollbarSpacing: -3
m_VerticalScrollbarSpacing: -3
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &4576862853245034537
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 324517120097755922}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3}
m_Name:
m_EditorClassIdentifier:
radius: 20
--- !u!1 &811666851805408220
GameObject:
m_ObjectHideFlags: 0
@ -229,7 +109,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3706567255822698944}
m_RootOrder: 6
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
@ -381,171 +261,6 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
log: {fileID: 0}
--- !u!1 &1758557965530623874
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4690766463415434102}
- component: {fileID: 5569518739105718044}
- component: {fileID: 6359231010102307868}
- component: {fileID: 2532492257110289613}
m_Layer: 5
m_Name: Viewport
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4690766463415434102
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1758557965530623874}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8500537348802214361}
m_Father: {fileID: 7867355229879358215}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!222 &5569518739105718044
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1758557965530623874}
m_CullTransparentMesh: 0
--- !u!114 &6359231010102307868
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1758557965530623874}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2532492257110289613
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1758557965530623874}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 0
--- !u!1 &1826171464485337471
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8500537348802214361}
- component: {fileID: 8094871915948962448}
- component: {fileID: 2674253312174825381}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8500537348802214361
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1826171464485337471}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4690766463415434102}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &8094871915948962448
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1826171464485337471}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 0
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_Spacing: 0
m_ChildForceExpandWidth: 1
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 1
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
--- !u!114 &2674253312174825381
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1826171464485337471}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &2877611761125301550
GameObject:
m_ObjectHideFlags: 0
@ -581,7 +296,6 @@ RectTransform:
- {fileID: 6797571756054001242}
- {fileID: 5365663280637269737}
- {fileID: 519173366022166441}
- {fileID: 7867355229879358215}
- {fileID: 1924737827584117062}
m_Father: {fileID: 1496775926230021875}
m_RootOrder: 0
@ -589,7 +303,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 710, y: 502}
m_SizeDelta: {x: 710, y: 276}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3962950446887068915
CanvasRenderer:
@ -871,11 +585,11 @@ RectTransform:
m_Father: {fileID: 3706567255822698944}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -212}
m_SizeDelta: {x: 0, y: -464}
m_Pivot: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 0}
m_AnchoredPosition: {x: 0, y: 20}
m_SizeDelta: {x: 710, y: 38}
m_Pivot: {x: 0.5, y: 0}
--- !u!222 &1463918263422329144
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1080,7 +794,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_Pivot.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1095,7 +809,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1105,7 +819,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1160,7 +874,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -444
value: 20
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1250,7 +964,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_Pivot.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1265,7 +979,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1275,7 +989,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
@ -1330,7 +1044,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -444
value: 20
objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}

View File

@ -2357,7 +2357,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &3317469123450094096
RectTransform:
m_ObjectHideFlags: 0

View File

@ -5101,6 +5101,11 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 1429559311419137021}
m_Modifications:
- target: {fileID: 1601033436969501121, guid: 5ee52e0b78bd38244a2b473e2236800c,
type: 3}
propertyPath: m_SizeDelta.x
value: 6
objectReference: {fileID: 0}
- target: {fileID: 1975648157075935214, guid: 5ee52e0b78bd38244a2b473e2236800c,
type: 3}
propertyPath: m_Material

View File

@ -1261,7 +1261,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 499.1, y: -29.5}
m_SizeDelta: {x: 67, y: 20}
m_SizeDelta: {x: 82, y: 20}
m_Pivot: {x: 0, y: 1}
--- !u!222 &4393121095389363787
CanvasRenderer:
@ -2602,7 +2602,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Mine
m_Text: Join In
--- !u!114 &7323859407491872305
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -9,7 +9,7 @@ namespace Assets.Scripts.UI.Prefab.MapList
{
public class MapFilterOptions
{
public static List<Dropdown.OptionData> distances = new string[] {"全部",
public static List<Dropdown.OptionData> distances = new string[] {"All",
"0-5KM",
"5-10KM",
"10-20KM",
@ -17,10 +17,10 @@ namespace Assets.Scripts.UI.Prefab.MapList
"30-50KM",
"50-100KM",
"100-200KM",
"200-无限制", }.Select(x=>new Dropdown.OptionData(x)).ToList();
"Over 200KM", }.Select(x=>new Dropdown.OptionData(x)).ToList();
public static Dictionary<string, string> distanceDict = new Dictionary<string, string>()
{
{"全部","" },
{"All","" },
{"0-5KM","0-5" },
{"5-10KM","5-10" },
{"10-20KM","10-20" },
@ -28,7 +28,7 @@ namespace Assets.Scripts.UI.Prefab.MapList
{"30-50KM","30-50" },
{"50-100KM","50-100" },
{"100-200KM","100-200" },
{"200-无限制","200-99999" },
{"Over 200KM","200-99999" },
};
public static Dictionary<string,string> diffDict = new Dictionary<string, string>()
{

View File

@ -62,8 +62,11 @@ public class HomeController : PFUIPanel
//Application.OpenURL("https://powerfun.oss-cn-shanghai.aliyuncs.com/Releases/PowerFunWorkouts.exe");
return;
}
Utils.ExecFile(path);
Application.Quit();
UIManager.ShowConfirm("Confirm", "Switch to PowerFun Workouts?\nWe will close the Powerfun and start PowerFun Workouts.", () =>
{
Utils.ExecFile(path);
Application.Quit();
});
});
UIManager.AddEvent(BtnTraining.gameObject, EventTriggerType.PointerEnter, OnHover);
UIManager.AddEvent(BtnTraining.gameObject, EventTriggerType.PointerExit, OnExit);

View File

@ -398,8 +398,6 @@ public class MapListController : PFUIPanel
public override void Show()
{
var cg = this.GetComponent<CanvasGroup>();
cg.alpha = 0;
base.Show();
if (App.TextureCache.ContainsKey("rotateImage"))
{
@ -409,6 +407,8 @@ public class MapListController : PFUIPanel
{
transform.Find("RawImage").GetComponent<RawImage>().texture = App.DefaultRotateTexture;
}
var cg = this.GetComponent<CanvasGroup>();
cg.alpha = 0;
cg.DOFade(1f, .3f);
}
}

View File

@ -30,7 +30,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
Utils.DisplayImage(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, true);
Utils.DisplayImage(transform.Find("AltitudeCurve").GetComponent<RawImage>(), mapCompetition.AltitudeGraph, true);
transform.Find("InfoContainer/Text").GetComponent<Text>().SetTextWithEllipsis(mapCompetition.Title);
transform.Find("GetReadyContainer").gameObject.SetActive(mapCompetition.Status != 3);
transform.Find("GetReadyContainer").gameObject.SetActive(true);
transform.Find("GetReadyContainer-2").gameObject.SetActive(mapCompetition.Status == 1);
//transform.Find("Text").GetComponent<Text>().text = mapCompetition.Title;
//props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance > 1000 ? "#0" : "#0.00")}KM";

View File

@ -12,7 +12,9 @@ public class RaceScript : PFUIPanel
public override void Show()
{
base.Show();
transform.GetComponent<CanvasGroup>().DOFade(1, 0.5f);
var cg = this.GetComponent<CanvasGroup>();
cg.alpha = 0;
cg.DOFade(1f, .5f);
}
protected void StartTime()
{
@ -93,12 +95,18 @@ public class RaceScript : PFUIPanel
}
}
}
else if (map.Status == 4)
else if (map.Status == 3)
{
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "Start Time";
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text =
map.StartTime.ToString("yyyy-MM-dd HH:mm");
}
else if (map.Status == 4)
{
currentItem.Find("GetReadyContainer/Title").GetComponent<Text>().text = "End Time";
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text =
map.FirstEndTime.HasValue?
map.FirstEndTime.Value.ToString("yyyy-MM-dd HH:mm"):map.EndTime.ToString("yyyy-MM-dd HH:mm");
map.FirstEndTime.HasValue ?
map.FirstEndTime.Value.ToString("yyyy-MM-dd HH:mm") : map.EndTime.ToString("yyyy-MM-dd HH:mm");
}
else
{

View File

@ -29,7 +29,7 @@ public class DownloadController : PFUIPanel
SetType(1);
//Button.GetComponent<Button>().enabled = false;
//Button.GetComponent<Button>().interactable = false;
path = Application.persistentDataPath + "/PowerFun.exe";
path = Application.temporaryCachePath + "/PowerFun.exe";
UIManager.AddEvent(Btn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
{
Application.Quit();
@ -41,10 +41,10 @@ public class DownloadController : PFUIPanel
{
BtnStart.GetComponent<Button>().enabled = false;
BtnStart.GetComponent<Button>().interactable = false;
StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (a, b, isComplete) =>
StartCoroutine(DownLoadExe(App.UpdateObject.Url, path, (p, 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);
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {Math.Round(p * 100, 0)}%";// string.Format(, a, b);
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)p;
if (isComplete)
{
SetType(3);
@ -73,7 +73,7 @@ public class DownloadController : PFUIPanel
}
}
/*下载文件*/
IEnumerator DownLoadExe(string url, string desFileName, Action<double, double, bool> OnDownloadProgressEvent)
IEnumerator DownLoadExe(string url, string desFileName, Action<double, bool> OnDownloadProgressEvent)
{
string version = null;
if (App.UpdateObject != null)
@ -108,33 +108,75 @@ public class DownloadController : PFUIPanel
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())
//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);
using (var uwr = UnityWebRequest.Get(url))
{
nReadSize = netStream.Read(nbytes, 0, packLength);
while (nReadSize > 0)
var operation = uwr.SendWebRequest();
while (!operation.isDone)
{
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);
/*
* as BugFinder metnioned in the comments
* what you want to track is uwr.downloadProgress
*/
var downloadDataProgress = uwr.downloadProgress * 100;
/*
* use a float division here
* I don't know what type downloadDataProgress is
* but if it is an int than you will always get
* an int division <somethingSmallerThan100>/100 = 0
*/
//progressBar.fillAmount = downloadDataProgress / 100.0f;
OnDownloadProgressEvent.Invoke(uwr.downloadProgress, false);
Debug.Log("Download: " + downloadDataProgress);
yield return null;
}
ByteArrayToFile(path + ".pfdownload", uwr.downloadHandler.data);
OnDownloadProgressEvent.Invoke(1, true);
}
}
public bool ByteArrayToFile(string fileName, byte[] byteArray)
{
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
fs.Write(byteArray, 0, byteArray.Length);
return true;
}
}
catch (Exception ex)
{
Debug.LogError(ex);
return false;
}
OnDownloadProgressEvent.Invoke(dDownloadedLength, dTotalLength, true);
}
void SetType(int a)
{

View File

@ -24,7 +24,7 @@ public class DownloadWorkoutsController : PFUIPanel
Btn = transform.Find("Panel/BtnConfirm");
BtnStart = transform.Find("Panel/BtnStart");
Loading = transform.Find("Panel/LoadingContainer");
scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
//scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
Exit = transform.Find("Panel/Exit");
BtnStart.GetComponent<Button>().enabled = true;
BtnStart.GetComponent<Button>().interactable = true;
@ -35,7 +35,7 @@ public class DownloadWorkoutsController : PFUIPanel
Btn = transform.Find("Panel/BtnConfirm");
BtnStart = transform.Find("Panel/BtnStart");
Loading = transform.Find("Panel/LoadingContainer");
scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
//scroll = transform.Find("Panel/Scroll View").GetComponent<ScrollRect>();
Exit = transform.Find("Panel/Exit");
SetType(1);
UIManager.AddEvent(Exit.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
@ -59,14 +59,15 @@ public class DownloadWorkoutsController : PFUIPanel
//Button.GetComponent<Button>().enabled = false;
//Button.GetComponent<Button>().interactable = false;
path = Application.persistentDataPath + "/PowerFunWorkouts.exe";
path = Application.temporaryCachePath + "/PowerFunWorkouts.exe";
Debug.Log(path);
UIManager.AddEvent(Btn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
{
//Application.Quit();
UIManager.ShowConfirm("Confirm", @"Switch to PowerFun Workouts? We will close the Powerfun and start PowerFun Workouts", () =>
UIManager.ShowConfirm("Confirm", "Switch to PowerFun Workouts?\nWe will close the Powerfun and start PowerFun Workouts.", () =>
{
Utils.ExecFile(path);
UIManager.CloseConfirm();
Application.Quit();
});
});
UIManager.AddEvent(BtnStart.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick,async (_base) =>
@ -80,11 +81,11 @@ public class DownloadWorkoutsController : PFUIPanel
BtnStart.GetComponent<Button>().enabled = false;
BtnStart.GetComponent<Button>().interactable = false;
Debug.Log(path);
StartCoroutine(DownLoadExe(wpf.Url, path, (a, b, isComplete) =>
StartCoroutine(DownLoadExe(wpf.Url, path, (p, isComplete) =>
{
Debug.Log($"{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);
//Debug.Log($"{a} {b} {isComplete}");
transform.Find("Panel/LoadingContainer/Text").GetComponent<Text>().text = $"Downloaded {Math.Round(p * 100,0)}%";// string.Format(, a, b);
transform.Find("Panel/LoadingContainer/Loading").GetComponent<Image>().fillAmount = (float)p;
if (isComplete)
{
SetType(3);
@ -132,7 +133,7 @@ public class DownloadWorkoutsController : PFUIPanel
HttpWebRequest request;
Stream _fs, _netStream;
/*下载文件*/
IEnumerator DownLoadExe(string url, string desFileName, Action<double, double, bool> OnDownloadProgressEvent)
IEnumerator DownLoadExe(string url, string desFileName, Action<double, bool> OnDownloadProgressEvent)
{
string version = null;
if (wpf != null)
@ -151,7 +152,12 @@ public class DownloadWorkoutsController : PFUIPanel
if (version == PlayerPrefs.GetString("exeVersion_w"))
{
//Application.Quit();
Utils.ExecFile(desFileName);
UIManager.ShowConfirm("Confirm", "Switch to PowerFun Workouts?\nWe will close the Powerfun and start PowerFun Workouts.", () =>
{
Utils.ExecFile(desFileName);
Application.Quit();
});
yield break;
}
else
@ -167,36 +173,81 @@ public class DownloadWorkoutsController : PFUIPanel
File.Delete(desFileName + ".pfdownload");
}
SetType(2);
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Timeout = 5000;
//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())
//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())
//{
// _fs = fs;
// _netStream = netStream;
// 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);
using (var uwr = UnityWebRequest.Get(url))
{
_fs = fs;
_netStream = netStream;
nReadSize = netStream.Read(nbytes, 0, packLength);
while (nReadSize > 0)
var operation = uwr.SendWebRequest();
while (!operation.isDone)
{
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);
/*
* as BugFinder metnioned in the comments
* what you want to track is uwr.downloadProgress
*/
var downloadDataProgress = uwr.downloadProgress * 100;
/*
* use a float division here
* I don't know what type downloadDataProgress is
* but if it is an int than you will always get
* an int division <somethingSmallerThan100>/100 = 0
*/
//progressBar.fillAmount = downloadDataProgress / 100.0f;
OnDownloadProgressEvent.Invoke(uwr.downloadProgress,false);
Debug.Log("Download: " + downloadDataProgress);
yield return null;
}
ByteArrayToFile(path+".pfdownload", uwr.downloadHandler.data);
OnDownloadProgressEvent.Invoke(1, true);
}
}
public bool ByteArrayToFile(string fileName, byte[] byteArray)
{
try
{
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
fs.Write(byteArray, 0, byteArray.Length);
return true;
}
}
catch (Exception ex)
{
Debug.LogError(ex);
return false;
}
OnDownloadProgressEvent.Invoke(dDownloadedLength, dTotalLength, true);
}
void SetType(int a)
{