add: public accessable reset function

pull/453/head
Robert Wartenberg 2023-08-16 12:02:41 +02:00
parent 90fd22498f
commit c06cd38081
1 changed files with 29 additions and 9 deletions

View File

@ -49,6 +49,9 @@ namespace UnityEngine.UI.Extensions
private GameObject _itemTemplate; private GameObject _itemTemplate;
private bool _initialized; private bool _initialized;
private string _defaultMainButtonCaption = null;
private Color _defaultNormalColor;
[SerializeField] [SerializeField]
private float _scrollBarWidth = 20.0f; private float _scrollBarWidth = 20.0f;
public float ScrollBarWidth public float ScrollBarWidth
@ -121,6 +124,9 @@ namespace UnityEngine.UI.Extensions
_rectTransform = GetComponent<RectTransform>(); _rectTransform = GetComponent<RectTransform>();
_mainButton = new DropDownListButton(_rectTransform.Find("MainButton").gameObject); _mainButton = new DropDownListButton(_rectTransform.Find("MainButton").gameObject);
_defaultMainButtonCaption = _mainButton.txt.text;
_defaultNormalColor = _mainButton.btn.colors.normalColor;
_overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>(); _overlayRT = _rectTransform.Find("Overlay").GetComponent<RectTransform>();
_overlayRT.gameObject.SetActive(false); _overlayRT.gameObject.SetActive(false);
_scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>(); _scrollPanelRT = _overlayRT.Find("ScrollPanel").GetComponent<RectTransform>();
@ -266,7 +272,21 @@ namespace UnityEngine.UI.Extensions
RedrawPanel(); RedrawPanel();
} }
public void ResetItems() public void ResetDropDown()
{
if (!_initialized)
return;
_mainButton.txt.text = _defaultMainButtonCaption;
for (int i = 0; i < _itemsPanelRT.childCount; i++)
_panelItems[i].btnImg.color = _defaultNormalColor;
_selectedIndex = -1;
_initialized = false;
Initialize();
}
public void ResetItems()
{ {
Items.Clear(); Items.Clear();
RebuildPanel(); RebuildPanel();