mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-16 00:07:52 +08:00
Added Search page and AutoCompleter
This commit is contained in:
@ -12,7 +12,8 @@ namespace UnityExplorer.UI.Widgets
|
||||
public bool Enabled => m_enabled;
|
||||
private bool m_enabled;
|
||||
|
||||
public Action<ButtonCell<T>> OnClick;
|
||||
public Action<int> OnClick;
|
||||
public int CurrentDataIndex;
|
||||
|
||||
public ButtonListSource<T> list;
|
||||
|
||||
@ -30,7 +31,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
this.buttonText = text;
|
||||
this.button = button;
|
||||
|
||||
button.onClick.AddListener(() => { OnClick?.Invoke(this); });
|
||||
button.onClick.AddListener(() => { OnClick?.Invoke(CurrentDataIndex); });
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
|
@ -21,7 +21,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
public Func<List<T>> GetEntries;
|
||||
public Action<ButtonCell<T>, int> SetICell;
|
||||
public Func<T, string, bool> ShouldDisplay;
|
||||
public Action<ButtonCell<T>> OnCellClicked;
|
||||
public Action<int> OnCellClicked;
|
||||
|
||||
public string CurrentFilter
|
||||
{
|
||||
@ -30,11 +30,11 @@ namespace UnityExplorer.UI.Widgets
|
||||
}
|
||||
private string currentFilter;
|
||||
|
||||
public ButtonListSource(ScrollPool infiniteScroller, Func<List<T>> getEntriesMethod,
|
||||
public ButtonListSource(ScrollPool scrollPool, Func<List<T>> getEntriesMethod,
|
||||
Action<ButtonCell<T>, int> setICellMethod, Func<T, string, bool> shouldDisplayMethod,
|
||||
Action<ButtonCell<T>> onCellClickedMethod)
|
||||
Action<int> onCellClickedMethod)
|
||||
{
|
||||
Scroller = infiniteScroller;
|
||||
Scroller = scrollPool;
|
||||
|
||||
GetEntries = getEntriesMethod;
|
||||
SetICell = setICellMethod;
|
||||
@ -44,13 +44,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
public void Init()
|
||||
{
|
||||
RuntimeProvider.Instance.StartCoroutine(InitCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator InitCoroutine()
|
||||
{
|
||||
yield return null;
|
||||
|
||||
var proto = ButtonCell<T>.CreatePrototypeCell(Scroller.UIRoot);
|
||||
|
||||
RefreshData();
|
||||
@ -90,11 +83,15 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
public void SetCell(ICell cell, int index)
|
||||
{
|
||||
if (currentEntries == null)
|
||||
RefreshData();
|
||||
|
||||
if (index < 0 || index >= currentEntries.Count)
|
||||
cell.Disable();
|
||||
else
|
||||
{
|
||||
cell.Enable();
|
||||
(cell as ButtonCell<T>).CurrentDataIndex = index;
|
||||
SetICell.Invoke((ButtonCell<T>)cell, index);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user