Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/UIWidgets/TreeViewNodeDragSupport.cs
2026-02-21 16:45:37 +08:00

58 lines
1.2 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
namespace UIWidgets
{
[RequireComponent(typeof(TreeViewComponent))]
public class TreeViewNodeDragSupport : DragSupport<TreeNode<TreeViewItem>>
{
[SerializeField]
public ListViewIconsItemComponent DragInfo;
protected virtual void Start()
{
if (DragInfo != null)
{
DragInfo.gameObject.SetActive(false);
}
}
protected override void InitDrag(PointerEventData eventData)
{
base.Data = GetComponent<TreeViewComponent>().Node;
ShowDragInfo();
}
protected virtual void ShowDragInfo()
{
if (!(DragInfo == null))
{
DragInfo.transform.SetParent(base.DragPoint, false);
DragInfo.transform.localPosition = new Vector3(-5f, 5f, 0f);
DragInfo.SetData(new ListViewIconsItemDescription
{
Name = base.Data.Item.Name,
LocalizedName = base.Data.Item.LocalizedName,
Icon = base.Data.Item.Icon,
Value = base.Data.Item.Value
});
DragInfo.gameObject.SetActive(true);
}
}
protected virtual void HideDragInfo()
{
if (!(DragInfo == null))
{
DragInfo.gameObject.SetActive(false);
}
}
public override void Dropped(bool success)
{
HideDragInfo();
base.Dropped(success);
}
}
}