+EA 23.253 Nightly - Plugin.UI
December 26, 2025
1 file modified. 1 new file created.
Important Changes
None.
UIList
public class Callback<T1, T2> : ICallback where T2 : Component
cs
public UIList list;
public Action<T1, int> onDragReorder;
public Func<T1, bool> canDragReorder;
public bool useSort => onSort != null;
public bool useOnClick => onClick != null;public Component Instantiate(object obj, Transform parent)
cs
{
onInstantiate((T1)obj, val);
}
if (onDragReorder != null)
{
UIListDragItem orCreate = val.GetOrCreate<UIListDragItem>();
orCreate.list = list;
orCreate.item = obj;
}
return val;
}cs
}
}
public void OnDragReorder(object obj, int a)
{
if (onDragReorder != null)
{
onDragReorder((T1)obj, a);
}
}
public bool CanDragReorder(object obj)
{
if (canDragReorder != null)
{
return canDragReorder((T1)obj);
}
return false;
}
public Component GetComponent(Transform t)
{
return t.GetComponent<T2>();cs
int OnSort(object obj, SortMode mode);
void OnRefresh();
void OnDragReorder(object obj, int a);
bool CanDragReorder(object obj);
}
public struct ButtonPaircs
private int highlightIndex;
private object dragTarget;
private int dragBeginIndex;
private int dragHoverIndex;
[NonSerialized]
public UIScrollView dragScrollView;
[NonSerialized]
public RectTransform dragViewport;
[NonSerialized]
public float dragEdgeSize;
[NonSerialized]
public float dragScrollSpeed = 2.5f;
public LayoutGroup layoutItems => _layoutItems ?? (_layoutItems = GetComponent<LayoutGroup>());
public GridLayoutGroup gridLayout => layoutItems as GridLayoutGroup;cs
}
}
public bool IsDragging => dragTarget != null;
public void AddCollection(ICollection collection)
{
foreach (object item in collection)cs
}
layoutItems.DestroyChildren();
}
public void BeginItemDrag(UIListDragItem drag)
{
if (callbacks.CanDragReorder(drag.item))
{
dragTarget = drag.item;
dragBeginIndex = drag.transform.GetSiblingIndex();
}
}
public void EndItemDrag(UIListDragItem drag)
{
if (dragTarget != null)
{
int num = dragHoverIndex - dragBeginIndex;
dragTarget = null;
if (num != 0)
{
callbacks.OnDragReorder(drag.item, num);
}
}
}
public void UpdateItemDragHover(UIListDragItem drag)
{
if (callbacks.CanDragReorder(drag.item) && dragTarget != null && dragTarget != drag.item)
{
dragHoverIndex = drag.transform.GetSiblingIndex();
GetPair(dragTarget).component?.transform.SetSiblingIndex(dragHoverIndex);
}
}
private void Update()
{
if (IsDragging)
{
AutoScrollWhileDragging();
}
}
private void AutoScrollWhileDragging()
{
if ((bool)dragViewport && (bool)dragScrollView)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(dragViewport, Input.mousePosition, null, out var localPoint);
float y = localPoint.y;
float num = dragViewport.rect.height * 0.5f;
float num2 = 0f;
if (y < 0f - num + dragEdgeSize)
{
float num3 = Mathf.InverseLerp(0f - num + dragEdgeSize, 0f - num, y);
num2 = (0f - dragScrollSpeed) * num3;
}
else if (y > num - dragEdgeSize)
{
float num4 = Mathf.InverseLerp(num - dragEdgeSize, num, y);
num2 = dragScrollSpeed * num4;
}
if (num2 != 0f)
{
float verticalNormalizedPosition = dragScrollView.verticalNormalizedPosition;
dragScrollView.verticalNormalizedPosition = Mathf.Clamp01(verticalNormalizedPosition + num2 * Time.unscaledDeltaTime);
}
}
}
}+UIListDragItem
File Created
cs
using UnityEngine;
using UnityEngine.EventSystems;
public class UIListDragItem : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler
{
public UIList list;
public object item;
public void OnBeginDrag(PointerEventData eventData)
{
list.BeginItemDrag(this);
}
public void OnDrag(PointerEventData eventData)
{
}
public void OnEndDrag(PointerEventData eventData)
{
list.EndItemDrag(this);
}
public void OnPointerEnter(PointerEventData eventData)
{
list.UpdateItemDragHover(this);
}
}