59 lines
1.2 KiB
C#
59 lines
1.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace UIWidgets
|
|
{
|
|
[RequireComponent(typeof(ListViewIconsItemComponent))]
|
|
public class ListViewIconsDragSupport : DragSupport<ListViewIconsItemDescription>
|
|
{
|
|
[SerializeField]
|
|
public ListViewIcons ListView;
|
|
|
|
[SerializeField]
|
|
public ListViewIconsItemComponent DragInfo;
|
|
|
|
protected virtual void Start()
|
|
{
|
|
if (DragInfo != null)
|
|
{
|
|
DragInfo.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
protected override void InitDrag(PointerEventData eventData)
|
|
{
|
|
base.Data = GetComponent<ListViewIconsItemComponent>().Item;
|
|
ShowDragInfo();
|
|
}
|
|
|
|
protected virtual void ShowDragInfo()
|
|
{
|
|
if (!(DragInfo == null))
|
|
{
|
|
DragInfo.transform.SetParent(base.DragPoint, false);
|
|
DragInfo.transform.localPosition = new Vector3(-5f, 5f, 0f);
|
|
DragInfo.SetData(base.Data);
|
|
DragInfo.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
protected virtual void HideDragInfo()
|
|
{
|
|
if (!(DragInfo == null))
|
|
{
|
|
DragInfo.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public override void Dropped(bool success)
|
|
{
|
|
HideDragInfo();
|
|
if (success && ListView != null)
|
|
{
|
|
ListView.DataSource.Remove(base.Data);
|
|
}
|
|
base.Dropped(success);
|
|
}
|
|
}
|
|
}
|