modify
This commit is contained in:
parent
4b02614cc5
commit
1f7b111a23
@ -418,7 +418,7 @@ public class RecyclerViewEditor : Editor
|
||||
if (rv == null) return;
|
||||
if (_showScrollBar.boolValue)
|
||||
{
|
||||
Direction direction = (Direction)alignment.enumValueIndex;
|
||||
Direction direction = (Direction)this.direction.enumValueIndex;
|
||||
if (direction == Direction.Vertical)
|
||||
{
|
||||
const string path = "Packages/com.alicizax.unity.ui.extension/Editor/RecyclerView/Res/vertical.prefab";
|
||||
|
@ -7,6 +7,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
public abstract class LayoutManager : ILayoutManager
|
||||
{
|
||||
protected Vector2 viewportSize;
|
||||
|
||||
public Vector2 ViewportSize
|
||||
{
|
||||
get => viewportSize;
|
||||
@ -14,6 +15,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Vector2 contentSize;
|
||||
|
||||
public Vector2 ContentSize
|
||||
{
|
||||
get => contentSize;
|
||||
@ -21,6 +23,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Vector2 contentOffset;
|
||||
|
||||
public Vector2 ContentOffset
|
||||
{
|
||||
get => contentOffset;
|
||||
@ -28,6 +31,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Vector2 viewportOffset;
|
||||
|
||||
public Vector2 ViewportOffset
|
||||
{
|
||||
get => viewportOffset;
|
||||
@ -35,6 +39,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected IAdapter adapter;
|
||||
|
||||
public IAdapter Adapter
|
||||
{
|
||||
get => adapter;
|
||||
@ -42,6 +47,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected ViewProvider viewProvider;
|
||||
|
||||
public ViewProvider ViewProvider
|
||||
{
|
||||
get => viewProvider;
|
||||
@ -49,6 +55,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected RecyclerView recyclerView;
|
||||
|
||||
public virtual RecyclerView RecyclerView
|
||||
{
|
||||
get => recyclerView;
|
||||
@ -56,6 +63,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Direction direction;
|
||||
|
||||
public Direction Direction
|
||||
{
|
||||
get => direction;
|
||||
@ -63,6 +71,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Alignment alignment;
|
||||
|
||||
public Alignment Alignment
|
||||
{
|
||||
get => alignment;
|
||||
@ -70,6 +79,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Vector2 spacing;
|
||||
|
||||
public Vector2 Spacing
|
||||
{
|
||||
get => spacing;
|
||||
@ -77,6 +87,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected Vector2 padding;
|
||||
|
||||
public Vector2 Padding
|
||||
{
|
||||
get => padding;
|
||||
@ -84,6 +95,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected int unit = 1;
|
||||
|
||||
public int Unit
|
||||
{
|
||||
get => unit;
|
||||
@ -91,6 +103,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
}
|
||||
|
||||
protected bool canScroll;
|
||||
|
||||
public bool CanScroll
|
||||
{
|
||||
get => canScroll;
|
||||
@ -99,7 +112,9 @@ namespace AlicizaX.UI.RecyclerView
|
||||
|
||||
public float ScrollPosition => recyclerView.GetScrollPosition();
|
||||
|
||||
public LayoutManager() { }
|
||||
public LayoutManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetContentSize()
|
||||
{
|
||||
@ -120,9 +135,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
public virtual void Layout(ViewHolder viewHolder, int index)
|
||||
{
|
||||
Vector2 pos = CalculatePosition(index);
|
||||
Vector3 position = direction == Direction.Vertical ?
|
||||
new Vector3(pos.x - contentOffset.x, -pos.y + contentOffset.y, 0) :
|
||||
new Vector3(pos.x - contentOffset.x, -pos.y + contentOffset.y, 0);
|
||||
Vector3 position = direction == Direction.Vertical ? new Vector3(pos.x - contentOffset.x, -pos.y + contentOffset.y, 0) : new Vector3(pos.x - contentOffset.x, -pos.y + contentOffset.y, 0);
|
||||
viewHolder.RectTransform.anchoredPosition3D = position;
|
||||
}
|
||||
|
||||
@ -142,7 +155,9 @@ namespace AlicizaX.UI.RecyclerView
|
||||
|
||||
public abstract int PositionToIndex(float position);
|
||||
|
||||
public virtual void DoItemAnimation() { }
|
||||
public virtual void DoItemAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool IsFullVisibleStart(int index)
|
||||
{
|
||||
@ -207,6 +222,7 @@ namespace AlicizaX.UI.RecyclerView
|
||||
{
|
||||
len = alignment == Alignment.Center ? Mathf.Min(contentSize.x, viewportSize.x) : viewportSize.x;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -218,9 +234,9 @@ namespace AlicizaX.UI.RecyclerView
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
Vertical = 1,
|
||||
Horizontal = 2,
|
||||
Custom = 10
|
||||
Vertical,
|
||||
Horizontal,
|
||||
Custom,
|
||||
}
|
||||
|
||||
public enum Alignment
|
||||
|
Loading…
Reference in New Issue
Block a user