From 8dde7520ada3b853c7fe17635887c71870ab96e9 Mon Sep 17 00:00:00 2001 From: CaiYanPeng Date: Wed, 29 Dec 2021 17:05:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/UI/Prefab/MainNav-mobile.prefab | 13 ++++ .../Panel/Mobile/NewRouteDetailPanel.prefab | 41 ++++++++++++ .../Panel/Mobile/NewRouteOverviewPanel.prefab | 47 ++++++++++++- Assets/Scripts/UI/Prefab/NewMainNav.cs | 20 +++++- .../Scripts/UI/Prefab/Panel/HomeController.cs | 4 +- .../UI/Prefab/Panel/MapListExtraController.cs | 1 + .../Prefab/Panel/NewRouteDetailController.cs | 66 ++++++++++++++++++- .../Scripts/UI/Prefab/ResultList/RouteItem.cs | 2 +- Assets/Scripts/Utils/Utils.cs | 11 +++- ProjectSettings/GraphicsSettings.asset | 1 + 10 files changed, 193 insertions(+), 13 deletions(-) diff --git a/Assets/Resources/UI/Prefab/MainNav-mobile.prefab b/Assets/Resources/UI/Prefab/MainNav-mobile.prefab index e7f13456..037aff64 100644 --- a/Assets/Resources/UI/Prefab/MainNav-mobile.prefab +++ b/Assets/Resources/UI/Prefab/MainNav-mobile.prefab @@ -27,6 +27,7 @@ GameObject: - component: {fileID: 7793409217181307314} - component: {fileID: 2752079573212952071} - component: {fileID: 8699752019427605733} + - component: {fileID: 2781699126086311677} m_Layer: 5 m_Name: MainNav-mobile m_TagString: Untagged @@ -153,6 +154,18 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: fca4162bdac783449b37ea751c075353, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!225 &2781699126086311677 +CanvasGroup: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2638424933752433026} + m_Enabled: 1 + m_Alpha: 1 + m_Interactable: 1 + m_BlocksRaycasts: 1 + m_IgnoreParentGroups: 0 --- !u!114 &7073224465767460078 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteDetailPanel.prefab b/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteDetailPanel.prefab index 73ec98d6..f6bfc06c 100644 --- a/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteDetailPanel.prefab +++ b/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteDetailPanel.prefab @@ -2569,6 +2569,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7f7db27f83919ce49a865d9187ff71aa, type: 3} m_Name: m_EditorClassIdentifier: + newNav: {fileID: 0} --- !u!1001 &5638733952332257752 PrefabInstance: m_ObjectHideFlags: 0 @@ -2626,6 +2627,21 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 20 + objectReference: {fileID: 0} - target: {fileID: 1617869899094122649, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_SizeDelta.x @@ -3011,6 +3027,11 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 20 objectReference: {fileID: 0} + - target: {fileID: 6376947731341292573, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8197454007437855745, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_AnchorMax.y @@ -3026,6 +3047,26 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 20 objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8526344065104504758, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_AnchorMax.y diff --git a/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteOverviewPanel.prefab b/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteOverviewPanel.prefab index b4f3ac4d..a1a1f398 100644 --- a/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteOverviewPanel.prefab +++ b/Assets/Resources/UI/Prefab/Panel/Mobile/NewRouteOverviewPanel.prefab @@ -64,7 +64,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2a5c5c544b798fb429007a737f082aa6, type: 3} + m_Sprite: {fileID: 21300000, guid: b665fce0f8cd8cd44a5762350c902f5a, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -520,7 +520,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2a5c5c544b798fb429007a737f082aa6, type: 3} + m_Sprite: {fileID: 21300000, guid: f2c28367c40d22848bc4051e5195ce7f, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -1681,6 +1681,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 198d3ec3822927f44af9fb241ac00195, type: 3} m_Name: m_EditorClassIdentifier: + newNav: {fileID: 0} --- !u!225 &1735218495705024833 CanvasGroup: m_ObjectHideFlags: 0 @@ -2217,7 +2218,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2a5c5c544b798fb429007a737f082aa6, type: 3} + m_Sprite: {fileID: 21300000, guid: 1bd86fd45230aa24c98846ea6354c3a4, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -2284,6 +2285,21 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1592441871873768741, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 20 + objectReference: {fileID: 0} - target: {fileID: 1617869899094122649, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_SizeDelta.x @@ -2669,6 +2685,11 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 20 objectReference: {fileID: 0} + - target: {fileID: 6376947731341292573, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8197454007437855745, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_AnchorMax.y @@ -2684,6 +2705,26 @@ PrefabInstance: propertyPath: m_AnchoredPosition.x value: 20 objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMax.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8382612560249065530, guid: 240a4465e4dc90848a0efc1a9520c658, + type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} - target: {fileID: 8526344065104504758, guid: 240a4465e4dc90848a0efc1a9520c658, type: 3} propertyPath: m_AnchorMax.y diff --git a/Assets/Scripts/UI/Prefab/NewMainNav.cs b/Assets/Scripts/UI/Prefab/NewMainNav.cs index 2df746ca..e0bce618 100644 --- a/Assets/Scripts/UI/Prefab/NewMainNav.cs +++ b/Assets/Scripts/UI/Prefab/NewMainNav.cs @@ -225,10 +225,28 @@ public class NewMainNav : MonoBehaviour { } - + bool isTouch = false; + float hideTime = 5; // Update is called once per frame void Update() { + if (Input.touchCount > 0) + { + Debug.Log(235); + isTouch = true; + GetComponent().DOFade(1, 0.5f); + } + hideTime -= Time.deltaTime; + if (hideTime < 0) + { + if (!isTouch) + { + GetComponent().DOFade(0.4f, 0.5f); + } + isTouch = false; + hideTime += 5; + } + Debug.Log(Input.touchCount); if (delayTime < 0) { Debug.Log("小时"); diff --git a/Assets/Scripts/UI/Prefab/Panel/HomeController.cs b/Assets/Scripts/UI/Prefab/Panel/HomeController.cs index 4f79fe7a..c4536bb0 100644 --- a/Assets/Scripts/UI/Prefab/Panel/HomeController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/HomeController.cs @@ -246,8 +246,8 @@ public class HomeController : PFUIPanel { Utils.DisplayHead(todayData.Find("Avatar").GetComponent(), App.CurrentUser.WxHeadImg); todayData.Find("Datas/Distance/Value").GetComponent().text = $"{summary.ContinuesDay}"+ (summary.ContinuesDay > 1 ? App.GetLocalString("DAYS") : App.GetLocalString("DAY")); - todayData.Find("Datas/Climb/Value").GetComponent().text = $"{summary.TotalDistance.ToString("#0")}KM";//$"{double.Parse(summary.TotalClimb, CultureInfo.InvariantCulture).ToString("0")}M"; - todayData.Find("Datas/Carlories/Value").GetComponent().text = $"{summary.TotalKj.ToString("#0")}KCAL"; + todayData.Find("Datas/Climb/Value").GetComponent().text = $"{summary.ContinuesKm.ToString("#0")}KM";//$"{double.Parse(summary.TotalClimb, CultureInfo.InvariantCulture).ToString("0")}M"; + todayData.Find("Datas/Carlories/Value").GetComponent().text = $"{summary.ContinuesKcal.ToString("#0")}KCAL"; //todayData.Find("Datas/Distance/Rank").GetComponent().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0")}"; todayData.Find("Datas/Climb/Rank").GetComponent().text = summary.CurrentTotalDistance == 0 ? "——" : $"+{summary.CurrentTotalDistance.ToString("#0")}"; todayData.Find("Datas/Carlories/Rank").GetComponent().text = summary.CurrentTotalKcal == 0 ? "——" : $"+{summary.CurrentTotalKcal.ToString("#0")}"; diff --git a/Assets/Scripts/UI/Prefab/Panel/MapListExtraController.cs b/Assets/Scripts/UI/Prefab/Panel/MapListExtraController.cs index ee74693a..ea451625 100644 --- a/Assets/Scripts/UI/Prefab/Panel/MapListExtraController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/MapListExtraController.cs @@ -96,6 +96,7 @@ public class MapListExtraController : PFUIPanel var item = Instantiate(tmpCollectItem); item.GetComponent().Initial(area, GetComponent().caches); item.SetParent(p2.Find("Scroll View/Viewport/Content")); + item.localScale = Vector3.one; } } } diff --git a/Assets/Scripts/UI/Prefab/Panel/NewRouteDetailController.cs b/Assets/Scripts/UI/Prefab/Panel/NewRouteDetailController.cs index 919e6899..25e33874 100644 --- a/Assets/Scripts/UI/Prefab/Panel/NewRouteDetailController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/NewRouteDetailController.cs @@ -145,10 +145,31 @@ public class NewRouteDetailController : PFUIPanel .text = string.Empty; transform.Find("Container/Left/Desc").GetComponent() .text = string.Empty; - if (area.BannerImage != null) + if (area.CoverImage != null) { - Utils.DisplayImageTempDict(left.Find("Icon").GetComponent(), area.CoverImage, caches); - Utils.DisplayImageTempDict(left.Find("Thumbnail").GetComponent(), area.CoverImage, caches); + Utils.DisplayImageTempDict(left.Find("Icon").GetComponent(), area.CoverImage, caches + , b => + { +#if UNITY_EDITOR + var _t = new Texture2D(4, 4, TextureFormat.DXT5, false); +#else +#if UNITY_IOS + var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false); + Debug.Log("使用了壓縮"); +#elif UNITY_ANDROID + var _t = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false); + Debug.Log("使用了壓縮"); +#else //pc + var _t = new Texture2D(4, 4, TextureFormat.DXT5,false); +#endif +#endif + _t.LoadImage(b); + //Graphics.CopyTexture(t, _t); + //Debug.Log($"{t.width},{t.height}"); + left.Find("Thumbnail").GetComponent().texture = + ScaleTextureCutOut(_t, 0, _t.height / 2, _t.width / 3, _t.height / 3); + }); + //Utils.DisplayImageTempDict(left.Find("Thumbnail").GetComponent(), area.CoverImage, caches); } Debug.Log(153 + area.IsFav.ToString()); @@ -157,7 +178,46 @@ public class NewRouteDetailController : PFUIPanel GetList(); } + Texture2D ScaleTextureCutOut(Texture2D originalTexture, float startX, float startY, float originalWidth, float originalHeight) + { + originalWidth = Mathf.Clamp(originalWidth, 0, Mathf.Max(originalTexture.width - startX, 0)); + originalHeight = Mathf.Clamp(originalHeight, 0, Mathf.Max(originalTexture.height - startY, 0)); + Texture2D newTexture = new Texture2D(Mathf.CeilToInt(originalWidth), Mathf.CeilToInt(originalHeight)); + int maxX = originalTexture.width - 1; + int maxY = originalTexture.height - 1; + for (int y = 0; y < newTexture.height; y++) + { + for (int x = 0; x < newTexture.width; x++) + { + float targetX = x + startX; + float targetY = y + startY; + int x1 = Mathf.Min(maxX, Mathf.FloorToInt(targetX)); + int y1 = Mathf.Min(maxY, Mathf.FloorToInt(targetY)); + int x2 = Mathf.Min(maxX, x1 + 1); + int y2 = Mathf.Min(maxY, y1 + 1); + float u = targetX - x1; + float v = targetY - y1; + float w1 = (1 - u) * (1 - v); + float w2 = u * (1 - v); + float w3 = (1 - u) * v; + float w4 = u * v; + Color color1 = originalTexture.GetPixel(x1, y1); + Color color2 = originalTexture.GetPixel(x2, y1); + Color color3 = originalTexture.GetPixel(x1, y2); + Color color4 = originalTexture.GetPixel(x2, y2); + Color color = new Color(Mathf.Clamp01(color1.r * w1 + color2.r * w2 + color3.r * w3 + color4.r * w4), + Mathf.Clamp01(color1.g * w1 + color2.g * w2 + color3.g * w3 + color4.g * w4), + Mathf.Clamp01(color1.b * w1 + color2.b * w2 + color3.b * w3 + color4.b * w4), + Mathf.Clamp01(color1.a * w1 + color2.a * w2 + color3.a * w3 + color4.a * w4) + ); + newTexture.SetPixel(x, y, color); + } + } + newTexture.anisoLevel = 2; + newTexture.Apply(); + return newTexture; + } private void OnEndDrag(BaseEventData arg0) { Debug.Log(scroll.verticalNormalizedPosition); diff --git a/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs b/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs index f20a794a..048fc711 100644 --- a/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs +++ b/Assets/Scripts/UI/Prefab/ResultList/RouteItem.cs @@ -183,7 +183,7 @@ public class RouteItem : MonoBehaviour Debug.Log(App.CurrentUser.WebHost); if (App.weChatController.IsWeChatAppInstalled()) { - App.weChatController.ShareWebpageToWX(0, "http://192.168.0.101:3081/RoutesRecords/" + result.RankingId, result.RouteName, "By " + App.CurrentUser.Nickname, null); + App.weChatController.ShareWebpageToWX(0, $"http://{App.CurrentUser.WebHost}/RoutesRecords/" + result.RankingId, result.RouteName, "By " + App.CurrentUser.Nickname, null); } else { diff --git a/Assets/Scripts/Utils/Utils.cs b/Assets/Scripts/Utils/Utils.cs index c2bed53e..ef372826 100644 --- a/Assets/Scripts/Utils/Utils.cs +++ b/Assets/Scripts/Utils/Utils.cs @@ -10,6 +10,7 @@ using System.Net.NetworkInformation; using System.Net.Sockets; using System.Runtime.InteropServices; using UnityEngine; +using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; @@ -386,7 +387,7 @@ namespace Assets.Scripts /// /// /// - public static void DisplayImageTempDict(MaskableGraphic img, string url, Dictionary caches = null) + public static void DisplayImageTempDict(MaskableGraphic img, string url, Dictionary caches = null,UnityAction callback = null) { if (string.IsNullOrEmpty(url)) return; @@ -411,7 +412,7 @@ namespace Assets.Scripts { caches.Add(url, texture); } - })); + },callback)); } @@ -438,7 +439,7 @@ namespace Assets.Scripts } } } - static IEnumerator DownloadImage(MaskableGraphic img,string MediaUrl, Action action = null) + static IEnumerator DownloadImage(MaskableGraphic img,string MediaUrl, Action action = null,UnityAction callback = null) { UnityWebRequest request = UnityWebRequest.Get(MediaUrl); yield return request.SendWebRequest(); @@ -461,6 +462,10 @@ namespace Assets.Scripts { action.Invoke(texture); } + if (callback != null) + { + callback.Invoke(data); + } } } public static Texture GetDownloadTexture(string MediaUrl, byte[] data) diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 4706883c..9b996cb4 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -38,6 +38,7 @@ GraphicsSettings: - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}