unity小技巧:實(shí)現(xiàn)拖拽效果
2023-06-09 19:41 作者:塵風(fēng)一枚 | 我要投稿

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class MoveUI : MonoBehaviour,?IDragHandler
{
??private new RectTransform transform;
??private void Awake()
??{
????transform = GetComponent<RectTransform>();
??}
??public void OnDrag(PointerEventData eventData)
??{
????this.transform.anchoredPosition += eventData.delta;
??}
}
標(biāo)簽: