WXMC/proj/unity/Assets/WishGodUI.cs
2024-12-04 16:18:46 +08:00

39 lines
856 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class WishGodUI : MonoBehaviour, IDragHandler, IBeginDragHandler
{
Vector3 worldPos;
Vector3 offset;
public void OnBeginDrag(PointerEventData eventData)
{
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(transform.GetComponent<RectTransform>(), Input.mousePosition
, eventData.enterEventCamera, out worldPos))
{
offset = transform.position - worldPos;
}
}
public void OnDrag(PointerEventData eventData)
{
transform.position = offset + Input.mousePosition;
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}