Minor review corrections

pull/453/head
Simon (Darkside) Jackson 2023-10-05 16:53:04 +01:00 committed by GitHub
parent 95f1956f48
commit 289a50d796
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 5 deletions

View File

@ -64,7 +64,6 @@ namespace UnityEngine.UI.Extensions
} }
} }
// private int scrollOffset; //offset of the selected item
private int _selectedIndex = -1; private int _selectedIndex = -1;
[SerializeField] [SerializeField]
@ -101,7 +100,7 @@ namespace UnityEngine.UI.Extensions
[System.Serializable] [System.Serializable]
public class ControlDisabledEvent : Events.UnityEvent<bool> { } public class ControlDisabledEvent : Events.UnityEvent<bool> { }
// fires when item changed between enabled and disabled; // fires when item changes between enabled and disabled;
public ControlDisabledEvent OnControlDisabled; public ControlDisabledEvent OnControlDisabled;
public void Start() public void Start()
@ -275,11 +274,15 @@ namespace UnityEngine.UI.Extensions
public void ResetDropDown() public void ResetDropDown()
{ {
if (!_initialized) if (!_initialized)
{
return; return;
}
_mainButton.txt.text = _defaultMainButtonCaption; _mainButton.txt.text = _defaultMainButtonCaption;
for (int i = 0; i < _itemsPanelRT.childCount; i++) for (int i = 0; i < _itemsPanelRT.childCount; i++)
{
_panelItems[i].btnImg.color = _defaultNormalColor; _panelItems[i].btnImg.color = _defaultNormalColor;
}
_selectedIndex = -1; _selectedIndex = -1;
_initialized = false; _initialized = false;
@ -427,13 +430,24 @@ namespace UnityEngine.UI.Extensions
} }
/// <summary> /// <summary>
/// Toggle the drop down list if it's active /// Toggle the drop down list if it is active
/// </summary> /// </summary>
/// <param name="directClick">makes no difference, only for backwards compatibility reasons</param> /// <param name="directClick">Retained for backwards compatibility only.</param>
public void ToggleDropdownPanel(bool directClick) [Obsolete("DirectClick Parameter is no longer required")]
public void ToggleDropdownPanel(bool directClick = false)
{
ToggleDropdownPanel();
}
/// <summary>
/// Toggle the drop down list if it is active
/// </summary>
public void ToggleDropdownPanel()
{ {
if (!isActive) if (!isActive)
{
return; return;
}
_overlayRT.transform.localScale = new Vector3(1, 1, 1); _overlayRT.transform.localScale = new Vector3(1, 1, 1);
_scrollBarRT.transform.localScale = new Vector3(1, 1, 1); _scrollBarRT.transform.localScale = new Vector3(1, 1, 1);
@ -441,7 +455,9 @@ namespace UnityEngine.UI.Extensions
_overlayRT.gameObject.SetActive(_isPanelActive); _overlayRT.gameObject.SetActive(_isPanelActive);
if (_isPanelActive) if (_isPanelActive)
{
transform.SetAsLastSibling(); transform.SetAsLastSibling();
}
} }
/// <summary> /// <summary>
@ -450,7 +466,10 @@ namespace UnityEngine.UI.Extensions
public void HideDropDownPanel() public void HideDropDownPanel()
{ {
if (!_isPanelActive) if (!_isPanelActive)
{
return; return;
}
ToggleDropdownPanel(false); ToggleDropdownPanel(false);
} }
@ -462,7 +481,9 @@ namespace UnityEngine.UI.Extensions
public void SetActive(bool status) public void SetActive(bool status)
{ {
if (status == isActive) if (status == isActive)
{
return; return;
}
isActive = status; isActive = status;
OnControlDisabled?.Invoke(isActive); OnControlDisabled?.Invoke(isActive);
_mainButton.btn.enabled = isActive; _mainButton.btn.enabled = isActive;