Unity学习笔记:NGUI背包物品拖拽逻辑

    技术2022-07-12  74

    子类化拖拽容器组件,复写拖拽结束逻辑。

    using UnityEngine; using System.Collections; public class MyDrag : UIDragDropItem { //拖拽结束时 //surface拖拽结束时碰到的精灵 protected override void OnDragDropRelease(GameObject surface) { base.OnDragDropRelease(surface); Transform releaseParent = transform.parent; if (surface != null) { if (surface.tag == "Back"){ transform.parent = surface.transform; transform.localPosition = Vector3.zero; } else if (surface.tag == "Obj"){ Transform surfaceParent = surface.transform.parent; transform.parent = surfaceParent; transform.localPosition = Vector3.zero; surface.transform.parent = releaseParent; surface.transform.localPosition = Vector3.zero; } } else transform.localPosition = Vector3.zero; } }

     

    Processed: 0.010, SQL: 9