如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
今天学习怎么制作背包,遇到了一些问题先来看看最终的效果图:这篇文章来自HYPERLINK"http://www.gopedu.com/"狗刨学习网开始做的时候,来来去去折腾了很久,最后知道了好的方法给盒子预设体添加一个碰撞器,然后Apply,所拖的盒子预设体都会添加上碰撞器要交换物品位置,首先要给其添加BoxColluder和UIDragDropItem脚本在写一个脚本继承UIDragDropItemprotectedoverridevoidOnDragDropRelease(GameObjectsurface){base.OnDragDropRelease(surface);//调用父类的OnDragDropRelease(surface)方法if(surface.tag=="Cell"){this.transform.parent=surface.transform;//把背包放入格子里面this.transform.localPosition=Vector3.zero;//把背包居中}elseif(surface.tag=="Knapsack"){//第一个背包:拖动的背包//第二个背包:将要被交换的背包Transformparent=surface.transform.parent;//得到第二个格子Transform对象surface.transform.parent=this.transform.parent;//把第二个背包放入第一个格子里面surface.transform.localPosition=Vector3.zero;//把第二个背包居中this.transform.parent=parent;//把第一个背包放入第二个格子里面this.transform.localPosition=Vector3.zero;//把第一个背包居中}}