You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
public class DragUI : MonoBehaviour, IPointerClickHandler, IBeginDragHandler, IDragHandler, IEndDragHandler
|
|
{
|
|
[Header("组件获取")]
|
|
[SerializeField] private Image dragImage;
|
|
|
|
private InventoryUI inventoryUI => GetComponentInParent<InventoryUI>();
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|
{
|
|
inventoryUI.dragItem.enabled = true;
|
|
inventoryUI.dragItem.sprite = dragImage.sprite;
|
|
// inventoryUI.dragItem.SetNativeSize();
|
|
}
|
|
|
|
public void OnDrag(PointerEventData eventData)
|
|
{
|
|
inventoryUI.dragItem.transform.position = Input.mousePosition;
|
|
}
|
|
|
|
public void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
inventoryUI.dragItem.enabled = false;
|
|
Debug.Log(eventData.pointerCurrentRaycast.gameObject);
|
|
|
|
}
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
}
|
|
|
|
|