首先看一下效果图
通过鼠标可以对物品进行拖拽
代码也是非常的简单
protected override void OnDragDropRelease(GameObject surface)
{
base.OnDragDropRelease(surface);
if (surface) {
this.transform.parent = surface.transform;
this.transform.localPosition = Vector3.zero;
} else {
this.transform.localPosition = Vector3.zero;
}
}