Some UI cleanups, improving caching and reduce image allocation

This commit is contained in:
Sinai
2021-04-25 21:20:50 +10:00
parent fda5afae46
commit f3cd84804d
19 changed files with 304 additions and 500 deletions

View File

@ -16,7 +16,7 @@ namespace UnityExplorer.UI.Widgets
internal ScrollPool Scroller;
public int ItemCount => currentEntries.Count;
public List<T> currentEntries;
public readonly List<T> currentEntries = new List<T>();
public Func<List<T>> GetEntries;
public Action<ButtonCell<T>, int> SetICell;
@ -54,7 +54,7 @@ namespace UnityExplorer.UI.Widgets
public void RefreshData()
{
var allEntries = GetEntries.Invoke();
var list = new List<T>();
currentEntries.Clear();
foreach (var entry in allEntries)
{
@ -63,13 +63,11 @@ namespace UnityExplorer.UI.Widgets
if (!ShouldDisplay.Invoke(entry, currentFilter))
continue;
list.Add(entry);
currentEntries.Add(entry);
}
else
list.Add(entry);
currentEntries.Add(entry);
}
currentEntries = list;
}
public ICell CreateCell(RectTransform rect)