Updates from testing
parent
0e99d8e63f
commit
dcd43da6b8
|
@ -95,8 +95,10 @@ namespace UnityEngine.UI.Extensions
|
|||
}
|
||||
}
|
||||
|
||||
//TODO design as foldout for Inspector
|
||||
public Color ValidSelectionTextColor = Color.green;
|
||||
public float DropdownOffset = 10f;
|
||||
|
||||
//TODO design as foldout for Inspector
|
||||
public Color ValidSelectionTextColor = Color.green;
|
||||
public Color MatchingItemsRemainingTextColor = Color.black;
|
||||
public Color NoItemsRemainingTextColor = Color.red;
|
||||
|
||||
|
@ -226,11 +228,19 @@ namespace UnityEngine.UI.Extensions
|
|||
/// </summary>
|
||||
private void RebuildPanel()
|
||||
{
|
||||
if (_isPanelActive) ToggleDropdownPanel();
|
||||
|
||||
//panel starts with all options
|
||||
_panelItems.Clear();
|
||||
_prunedPanelItems.Clear();
|
||||
panelObjects.Clear();
|
||||
|
||||
//clear Autocomplete children in scene
|
||||
foreach (Transform child in _itemsPanelRT.transform)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
foreach (string option in AvailableOptions)
|
||||
{
|
||||
_panelItems.Add(option.ToLower());
|
||||
|
@ -334,7 +344,7 @@ namespace UnityEngine.UI.Extensions
|
|||
|
||||
if (_panelItems.Count < 1) return;
|
||||
|
||||
float dropdownHeight = _rectTransform.sizeDelta.y * Mathf.Min(_itemsToDisplay, _panelItems.Count);
|
||||
float dropdownHeight = _rectTransform.sizeDelta.y * Mathf.Min(_itemsToDisplay, _panelItems.Count) + DropdownOffset;
|
||||
|
||||
_scrollPanelRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, dropdownHeight);
|
||||
_scrollPanelRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _rectTransform.sizeDelta.x);
|
||||
|
@ -395,7 +405,7 @@ namespace UnityEngine.UI.Extensions
|
|||
/// Toggle the drop down list
|
||||
/// </summary>
|
||||
/// <param name="directClick"> whether an item was directly clicked on</param>
|
||||
public void ToggleDropdownPanel(bool directClick)
|
||||
public void ToggleDropdownPanel(bool directClick = false)
|
||||
{
|
||||
_isPanelActive = !_isPanelActive;
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ namespace UnityEngine.UI.Extensions
|
|||
[SerializeField]
|
||||
private int _itemsToDisplay;
|
||||
|
||||
[SerializeField]
|
||||
private bool _sortItems = true;
|
||||
|
||||
[System.Serializable]
|
||||
public class SelectionChangedEvent : UnityEngine.Events.UnityEvent<string>
|
||||
{
|
||||
|
@ -178,7 +181,7 @@ namespace UnityEngine.UI.Extensions
|
|||
{
|
||||
_panelItems.Add(option.ToLower());
|
||||
}
|
||||
_panelItems.Sort();
|
||||
if(_sortItems) _panelItems.Sort();
|
||||
|
||||
List<GameObject> itemObjs = new List<GameObject>(panelObjects.Values);
|
||||
panelObjects.Clear();
|
||||
|
|
Loading…
Reference in New Issue