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