// Update is called once per frame void Update() { if (isDown == false || moved == true || dragActive == true) { return; } if (Time.time - beginTime > loapPressDelay) { scroRect.vertical = false; dragActive = true; itemStartPos = rectTran.anchoredPosition; dragToItem = null; viewDragActivePos = view.position; } }
void SetDraggedPosition(PointerEventData data) { if (offset == data.position - inputStartPos) { return; } offset = data.position - inputStartPos; rectTran.anchoredPosition = itemStartPos + GetPos(offset); Vector2 org = new Vector2(rectTran.position.x + 1.8f, rectTran.position.y - 1.3f); count = Physics2D.OverlapPointNonAlloc(org, coll); if (count == 0) { return; } bool hasOldFunc = false; for (int i = 0; i < count; i++) { if (coll[i].transform.parent == null) { continue; } if (coll[i].transform.parent == this.transform) { continue; } if (dragToItem != null && dragToItem.transform == coll[i].transform.parent) { hasOldFunc = true; break; } ManifestFunc func = coll[i].transform.parent.GetComponent <ManifestFunc>(); if (func == null) { continue; } if (dragToItem != null) { dragToItem.goBack(dragToItem.view); } dragToItem = func; dragToItem.GoToWorldPos(dragToItem.view, viewDragActivePos); func.transform.SetSiblingIndex(50); return; } if (hasOldFunc == false) { if (dragToItem != null) { dragToItem.goBack(dragToItem.view); dragToItem = null; } } }