Skip to content

Commit 4dd561d

Browse files
committed
chore: Improve the dropdown lang usage a bit
1 parent 9ab7736 commit 4dd561d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Assets/JCSUnity/Scripts/UI/Dropdown/JCS_DropdownLanguage.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ private void AddListener()
7171
/// </summary>
7272
public void Refresh()
7373
{
74-
if (mRemoveAllOptions)
74+
Refresh(mRemoveAllOptions);
75+
}
76+
public void Refresh(bool removeAllOptions)
77+
{
78+
if (removeAllOptions)
7579
ClearOptions();
7680

7781
foreach (SystemLanguage option in mOptions)

Assets/JCSUnity/Scripts/Util/JCS_UIUtil.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using UnityEngine;
1616
using UnityEngine.UI;
1717
using UnityEngine.EventSystems;
18+
using MyBox;
1819

1920
#if TMP_PRO
2021
using TMPro;
@@ -306,6 +307,9 @@ public static void Dropdown_AddOption(JCS_DropdownObject dd, string inText)
306307
/// <returns> Current selected text value. </returns>
307308
public static string Dropdown_GetItemValue(Dropdown dd, int index)
308309
{
310+
if (dd == null || dd.options.IsNullOrEmpty())
311+
return string.Empty;
312+
309313
return dd.options[index].text;
310314
}
311315

@@ -418,6 +422,9 @@ public static Dropdown Dropdown_AddOption(Dropdown dd, string inText)
418422
/// <returns> Current selected text value. </returns>
419423
public static string Dropdown_GetItemValue(TMP_Dropdown dd, int index)
420424
{
425+
if (dd == null || dd.options.IsNullOrEmpty())
426+
return string.Empty;
427+
421428
return dd.options[index].text;
422429
}
423430

0 commit comments

Comments
 (0)