Browse Source

修复null exception

大爷 1 year ago
parent
commit
2366f754d1
1 changed files with 7 additions and 4 deletions
  1. 7 4
      Unity/Assets/Scripts/Codes/HotfixView/Client/UI/HUD/CreateHUD.cs

+ 7 - 4
Unity/Assets/Scripts/Codes/HotfixView/Client/UI/HUD/CreateHUD.cs

@@ -1,5 +1,6 @@
 using ET.EventType;
 using FairyGUI;
+using System.Collections.Generic;
 using UnityEngine;
 
 namespace ET.Client
@@ -148,7 +149,9 @@ namespace ET.Client
             var list = HUDComonent.listRank;
             if (list == null) return;
 
-            for (int i = 0; i < a.InfoList.Count && i < list.numChildren; i++)
+            List < ET.RankInfo > datalist = a.InfoList ?? new List<ET.RankInfo>();
+
+            for (int i = 0; i < datalist.Count && i < list.numChildren; i++)
             {
                 var chd = list.GetChildAt(i).asCom;
                 if(chd == null)
@@ -156,17 +159,17 @@ namespace ET.Client
                     return;
                 }
                 var txt = chd.GetChild("text");
-                txt.text = a.InfoList[i].Name;
+                txt.text = datalist[i].Name;
                 var mask = chd.GetChild("compIcon").asCom;
                 var icon = mask.GetChild("iconLoader").asLoader;
-                var url = a.InfoList[i].Url;
+                var url = datalist[i].Url;
                 if (!string.IsNullOrEmpty(url))
                 {
                     LoadHeadIcon(icon, url).Coroutine();
                 }
                 chd.visible = true;
             }
-            for(int i = a.InfoList.Count; i < list.numChildren; i++)
+            for(int i = datalist.Count; i < list.numChildren; i++)
             {
                 var chd = list.GetChildAt(i);
                 if(chd != null)