[独游开发210212]Unity EventSystem中OnBeginDrag等问题
作者:互联网
Unity EventSystem中OnBeginDrag等问题:
描述:
最近做着玩想用鼠标拖拽背包物品,用上了EventSystem。出现在canvas中无法拖拽的问题using UnityEngine;
using UnityEngine.EventSystems;
public class ItemOnDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public void OnBeginDrag(PointerEventData eventData)
{
transform.position = eventData.position;
}
public void OnDrag(PointerEventData eventData)
{
transform.position = eventData.position;
}
public void OnEndDrag(PointerEventData eventData)
{
}
}
解决方法
勾选canvas中的 Override Sorting后设置sort order。
标签:210212,EventSystem,void,OnBeginDrag,PointerEventData,position,eventData,public 来源: https://blog.csdn.net/NoMonSterhunterL/article/details/113795181