一、背景图如下
如上图所示中的物品,需要实现一个可拖拽功能
二、添加脚本和碰撞器
注意找到标注红线的四个地方
三、编辑脚本
using UnityEngine;
using System.Collections;
public class InventoryItem : UIDragDropItem {
//物品拖放结束后响应此函数
protected override void OnDragDropRelease(GameObject surface)
{
base.OnDragDropRelease (surface);
if(surface != null)
print (surface.tag);
}
}