From eef47bd6b4ee1132684c670aa1dbec4cb7e323a6 Mon Sep 17 00:00:00 2001 From: Chomper9981 Date: Fri, 20 Mar 2026 14:16:04 +0700 Subject: [PATCH] fix null proplem in quickBar --- .../Scripts/Objet/Shortcut/CECShortcutSet.cs | 4 ++++ .../Scripts/UI/GamePlay/CdlgQuickBar.cs | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Objet/Shortcut/CECShortcutSet.cs b/Assets/PerfectWorld/Scripts/Objet/Shortcut/CECShortcutSet.cs index cdddcd410b..4fd93fce73 100644 --- a/Assets/PerfectWorld/Scripts/Objet/Shortcut/CECShortcutSet.cs +++ b/Assets/PerfectWorld/Scripts/Objet/Shortcut/CECShortcutSet.cs @@ -762,6 +762,10 @@ namespace BrewMonster /// public int GetShortcutNum() { + if(m_aShortcuts == null || m_aShortcuts.Count == 0) + { + return 0; + } return m_aShortcuts.Count; } diff --git a/Assets/PerfectWorld/Scripts/UI/GamePlay/CdlgQuickBar.cs b/Assets/PerfectWorld/Scripts/UI/GamePlay/CdlgQuickBar.cs index 5157754cd9..b29d19d512 100644 --- a/Assets/PerfectWorld/Scripts/UI/GamePlay/CdlgQuickBar.cs +++ b/Assets/PerfectWorld/Scripts/UI/GamePlay/CdlgQuickBar.cs @@ -50,6 +50,10 @@ namespace BrewMonster } public bool UpdateShortcuts() { + if(AUIImagePictureList == null || AUIImagePictureList.Count == 0) + { + return false; + } CECShortcut pSC; CECSCSkill pSCSkill; AUIImagePicture pCell; @@ -60,13 +64,15 @@ namespace BrewMonster int nCurPanel9 = GetCurPanel1(); int nCurPanel8 = GetCurPanel2(); CECHostPlayer pHost = EC_Game.GetGameRun().GetHostPlayer(); - if (pHost == null) return false; + if (pHost == null) + return false; var a_pSCS = new List(); var a_pszPanel = new List(); GetQuickBarNameAndSC(pHost, a_pszPanel, a_pSCS, nCurPanel9, nCurPanel8); if (a_pSCS == null || a_pSCS.Count < 2) return false; + if(currentListIndex >= a_pSCS.Count ) { currentListIndex = 0; @@ -80,7 +86,12 @@ namespace BrewMonster // } // currentOffsetIndex += a_pSCS[i].GetShortcutNum(); // } - int nSlots = Mathf.Min(a_pSCS[currentListIndex].GetShortcutNum(), AUIImagePictureList.Count); + var shortcutNum = a_pSCS[currentListIndex]?.GetShortcutNum() ?? 0; + if(shortcutNum <= 0) + { + return false; + } + int nSlots = Mathf.Min(shortcutNum, AUIImagePictureList.Count); for (int j = 0; j < nSlots; j++) { pCell = AUIImagePictureList[j];