2024-12-08 20:16:04 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
|
|
public class PointFollow : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
|
|
|
{
|
2024-12-09 12:00:50 +08:00
|
|
|
public Vector3 StarTransform;
|
2024-12-08 20:16:04 +08:00
|
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|
|
|
{
|
2024-12-09 12:00:50 +08:00
|
|
|
StarTransform = transform.position;
|
2024-12-08 20:16:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnDrag(PointerEventData eventData)
|
|
|
|
{
|
|
|
|
transform.position = eventData.position;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnEndDrag(PointerEventData eventData)
|
|
|
|
{
|
2024-12-09 12:00:50 +08:00
|
|
|
transform.position = StarTransform;
|
2024-12-08 20:16:04 +08:00
|
|
|
}
|
|
|
|
}
|