From c14f7cec7451cf28568486ec94d4804b9cb1bfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E8=88=B9=E6=A0=9E=E4=BB=94?= Date: Thu, 20 Apr 2023 16:18:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resources/Prefab/UI/Cards/CardListView.prefab | 4 ++-- .../Prefab/UI/Deck/DeckCardListView.prefab | 2 +- Assets/Scripts/Logic/CardManager.cs | 2 +- Assets/Scripts/Logic/Data/Card.cs | 2 +- Assets/Scripts/Logic/Data/Series.cs | 4 ++-- Assets/Scripts/Logic/DownloadData.cs | 6 +++++- Assets/Scripts/Logic/DownloadImage.cs | 13 +++++++++---- 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Assets/Resources/Prefab/UI/Cards/CardListView.prefab b/Assets/Resources/Prefab/UI/Cards/CardListView.prefab index babfc6c3..f4a47105 100644 --- a/Assets/Resources/Prefab/UI/Cards/CardListView.prefab +++ b/Assets/Resources/Prefab/UI/Cards/CardListView.prefab @@ -3863,9 +3863,9 @@ MonoBehaviour: scrollRect: {fileID: 2373949832944046736} top: 30 bottom: 30 - interval: 10 + interval: 6 elem: {fileID: -7887652861602639447, guid: 690fc32fa58083545a25ccbc922a4ea5, type: 3} - elemCount: 20 + elemCount: 10 --- !u!1 &2440221074765671710 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Resources/Prefab/UI/Deck/DeckCardListView.prefab b/Assets/Resources/Prefab/UI/Deck/DeckCardListView.prefab index dad24a19..7e4e157b 100644 --- a/Assets/Resources/Prefab/UI/Deck/DeckCardListView.prefab +++ b/Assets/Resources/Prefab/UI/Deck/DeckCardListView.prefab @@ -298,7 +298,7 @@ MonoBehaviour: bottom: 30 interval: 10 elem: {fileID: -7887652861602639447, guid: 690fc32fa58083545a25ccbc922a4ea5, type: 3} - elemCount: 20 + elemCount: 6 --- !u!1 &1335748695387864072 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Logic/CardManager.cs b/Assets/Scripts/Logic/CardManager.cs index 0a72bc53..1d8a34ae 100644 --- a/Assets/Scripts/Logic/CardManager.cs +++ b/Assets/Scripts/Logic/CardManager.cs @@ -56,7 +56,7 @@ public class CardManager : SingletonMono if (!File.Exists(SeriesListPath)) { //尝试读取Resource包体自带 - TextAsset tx = Resources.Load("data/SeriesList.json"); + TextAsset tx = Resources.Load("data/SeriesList"); if (tx == null) return; else diff --git a/Assets/Scripts/Logic/Data/Card.cs b/Assets/Scripts/Logic/Data/Card.cs index a987effc..b2ba3b69 100644 --- a/Assets/Scripts/Logic/Data/Card.cs +++ b/Assets/Scripts/Logic/Data/Card.cs @@ -30,7 +30,7 @@ public class Card } get { - if(_img == null) + if (_img == null) { LoadImg(); } diff --git a/Assets/Scripts/Logic/Data/Series.cs b/Assets/Scripts/Logic/Data/Series.cs index e4296a50..06722946 100644 --- a/Assets/Scripts/Logic/Data/Series.cs +++ b/Assets/Scripts/Logic/Data/Series.cs @@ -102,7 +102,7 @@ public class Series if (!File.Exists(path)) { //尝试读取本地的 - TextAsset tx = Resources.Load($"data/{Name.Replace("/", "")}/Cards.json"); + TextAsset tx = Resources.Load($"data/{Name.Replace("/", "")}/Cards"); if (tx == null) return; else @@ -120,7 +120,7 @@ public class Series for (int i = 0; i < data.Count; i++) { Card card = new Card(data[i]); - card.CheckImgFile(); + //card.CheckImgFile(); AddCard(card); } } diff --git a/Assets/Scripts/Logic/DownloadData.cs b/Assets/Scripts/Logic/DownloadData.cs index 63aab222..885af87e 100644 --- a/Assets/Scripts/Logic/DownloadData.cs +++ b/Assets/Scripts/Logic/DownloadData.cs @@ -165,16 +165,20 @@ public class DownloadData : SingletonMono if (retry < 5) { Debug.Log($"重新尝试:{url} - 次数{retry}"); + webRequest.Dispose(); yield return StartCoroutine(DownloadText(url, success, fail, retry + 1)); } else + { fail?.Invoke(webRequest.error); + webRequest.Dispose(); + } yield break; } // 从网络请求中获取文本内容 string text = webRequest.downloadHandler.text; - + webRequest.Dispose(); success?.Invoke(text); diff --git a/Assets/Scripts/Logic/DownloadImage.cs b/Assets/Scripts/Logic/DownloadImage.cs index 719f8e3c..4d657ea2 100644 --- a/Assets/Scripts/Logic/DownloadImage.cs +++ b/Assets/Scripts/Logic/DownloadImage.cs @@ -16,7 +16,7 @@ public class DownlaodImage : SingletonMono Queue DownloadQueue = new Queue(); bool downloading; - Texture2D RebirthBG; + static Texture2D RebirthBG; /// /// 获取一个图片 @@ -29,8 +29,8 @@ public class DownlaodImage : SingletonMono if (texture2D == null) { texture2D = (RebirthBG == null) ? LoadRebirthBG() : RebirthBG; - DownloadQueue.Enqueue(card); - if (!downloading) StartCoroutine(DownLoadQueue()); + //DownloadQueue.Enqueue(card); + //if (!downloading) StartCoroutine(DownLoadQueue()); } return texture2D; @@ -146,6 +146,7 @@ public class DownlaodImage : SingletonMono downloading = true; while (DownloadQueue.TryDequeue(out Card card)) { + //Logger.Log($"DownloadQueue:{DownloadQueue.Count}"); //尝试在Resource下加载 string path = ""; var resq = Resources.LoadAsync(path); @@ -161,6 +162,9 @@ public class DownlaodImage : SingletonMono else //没有则下载 yield return StartCoroutine(DownloadingImg(card)); + + yield return null; + } downloading = false; } @@ -182,10 +186,11 @@ public class DownlaodImage : SingletonMono Debug.Log($"重新尝试:{card.Num} - 次数{retry}"); yield return StartCoroutine(DownloadingImg(card, retry + 1)); } + webRequest.Dispose(); yield break; } byte[] bytes = webRequest.downloadHandler.data; - + webRequest.Dispose(); Texture2D texture = null; if (card.Type == CardType.Rebirth) { -- GitLab