mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-07 18:13:35 +08:00
rename "InfiniteScrollRect" to "ScrollPool"
This commit is contained in:
parent
2e5fb72716
commit
bcc89455a7
@ -692,7 +692,7 @@ namespace UnityExplorer.UI
|
|||||||
return dropdownObj;
|
return dropdownObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InfiniteScrollRect CreateInfiniteScroll(GameObject parent, string name, out GameObject uiRoot,
|
public static ScrollPool CreateInfiniteScroll(GameObject parent, string name, out GameObject uiRoot,
|
||||||
out GameObject content, Color? bgColor = null, bool autoResizeSliderHandle = true)
|
out GameObject content, Color? bgColor = null, bool autoResizeSliderHandle = true)
|
||||||
{
|
{
|
||||||
var mainObj = CreateUIObject(name, parent, new Vector2(1, 1));
|
var mainObj = CreateUIObject(name, parent, new Vector2(1, 1));
|
||||||
@ -752,7 +752,7 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
uiRoot = mainObj;
|
uiRoot = mainObj;
|
||||||
|
|
||||||
var infiniteScroll = new InfiniteScrollRect(scrollRect);
|
var infiniteScroll = new ScrollPool(scrollRect);
|
||||||
infiniteScroll.AutoResizeHandleRect = autoResizeSliderHandle;
|
infiniteScroll.AutoResizeHandleRect = autoResizeSliderHandle;
|
||||||
|
|
||||||
return infiniteScroll;
|
return infiniteScroll;
|
||||||
|
@ -6,7 +6,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
{
|
{
|
||||||
public interface IListDataSource
|
public interface IPoolDataSource
|
||||||
{
|
{
|
||||||
int ItemCount { get; }
|
int ItemCount { get; }
|
||||||
|
|
@ -9,15 +9,15 @@ using UnityExplorer.UI.Models;
|
|||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
{
|
{
|
||||||
public class InfiniteScrollRect : UIBehaviourModel
|
public class ScrollPool : UIBehaviourModel
|
||||||
{
|
{
|
||||||
public InfiniteScrollRect(ScrollRect scrollRect)
|
public ScrollPool(ScrollRect scrollRect)
|
||||||
{
|
{
|
||||||
this.scrollRect = scrollRect;
|
this.scrollRect = scrollRect;
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IListDataSource DataSource;
|
public IPoolDataSource DataSource;
|
||||||
|
|
||||||
public int PoolCount => _cachedCells.Count;
|
public int PoolCount => _cachedCells.Count;
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
/// Initialize with the provided DataSource
|
/// Initialize with the provided DataSource
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dataSource"></param>
|
/// <param name="dataSource"></param>
|
||||||
public void Initialize(IListDataSource dataSource)
|
public void Initialize(IPoolDataSource dataSource)
|
||||||
{
|
{
|
||||||
DataSource = dataSource;
|
DataSource = dataSource;
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
ReloadData(DataSource);
|
ReloadData(DataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadData(IListDataSource dataSource)
|
public void ReloadData(IPoolDataSource dataSource)
|
||||||
{
|
{
|
||||||
if (scrollRect.onValueChanged == null)
|
if (scrollRect.onValueChanged == null)
|
||||||
return;
|
return;
|
@ -18,6 +18,8 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
corners[3] = bottomLeft + new Vector3(rect.rect.width, 0, 0);
|
corners[3] = bottomLeft + new Vector3(rect.rect.width, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// again, using position and rect instead of
|
||||||
|
|
||||||
public static float MaxY(this RectTransform rect) => rect.position.y - rect.rect.height;
|
public static float MaxY(this RectTransform rect) => rect.position.y - rect.rect.height;
|
||||||
|
|
||||||
public static float MinY(this RectTransform rect) => rect.position.y;
|
public static float MinY(this RectTransform rect) => rect.position.y;
|
@ -8,9 +8,9 @@ using UnityExplorer.UI.Widgets;
|
|||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
{
|
{
|
||||||
public class SimpleListSource<T> : IListDataSource
|
public class SimpleListSource<T> : IPoolDataSource
|
||||||
{
|
{
|
||||||
internal InfiniteScrollRect Scroller;
|
internal ScrollPool Scroller;
|
||||||
|
|
||||||
public Func<List<T>> GetEntries;
|
public Func<List<T>> GetEntries;
|
||||||
public List<T> currentEntries;
|
public List<T> currentEntries;
|
||||||
@ -29,7 +29,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
}
|
}
|
||||||
private string currentFilter;
|
private string currentFilter;
|
||||||
|
|
||||||
public SimpleListSource(InfiniteScrollRect infiniteScroller, Func<List<T>> getEntriesMethod,
|
public SimpleListSource(ScrollPool infiniteScroller, Func<List<T>> getEntriesMethod,
|
||||||
Func<RectTransform, SimpleCell<T>> createCellMethod, Action<SimpleCell<T>, int> setICellMethod,
|
Func<RectTransform, SimpleCell<T>> createCellMethod, Action<SimpleCell<T>, int> setICellMethod,
|
||||||
Func<T, string, bool> shouldFilterMethod)
|
Func<T, string, bool> shouldFilterMethod)
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ using UnityExplorer.UI.Widgets;
|
|||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
{
|
{
|
||||||
public class TransformTree : IListDataSource
|
public class TransformTree : IPoolDataSource
|
||||||
{
|
{
|
||||||
public Func<IEnumerable<GameObject>> GetRootEntriesMethod;
|
public Func<IEnumerable<GameObject>> GetRootEntriesMethod;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
}
|
}
|
||||||
private string currentFilter;
|
private string currentFilter;
|
||||||
|
|
||||||
internal InfiniteScrollRect Scroller;
|
internal ScrollPool Scroller;
|
||||||
|
|
||||||
internal readonly List<CachedTransform> displayedObjects = new List<CachedTransform>();
|
internal readonly List<CachedTransform> displayedObjects = new List<CachedTransform>();
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
public int ItemCount => displayedObjects.Count;
|
public int ItemCount => displayedObjects.Count;
|
||||||
|
|
||||||
public TransformTree(InfiniteScrollRect infiniteScroller)
|
public TransformTree(ScrollPool infiniteScroller)
|
||||||
{
|
{
|
||||||
Scroller = infiniteScroller;
|
Scroller = infiniteScroller;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user