public void OnDirChange(GameObject go, SlideVector dir) { if (dir == SlideVector.down) { go.SetActive(false); closeBtn.gameObject.SetActive(true); } }
public void OnDrag(GameObject go, PointerEventData data) { touchSecond = data.position; timer += Time.deltaTime; //计时器 if (timer > offsetTime) { touchSecond = data.position; //记录结束下的位置 Vector2 slideDirection = touchFirst - touchSecond; float x = slideDirection.x; float y = slideDirection.y; if (y + SlidingDistance < x && y > -x - SlidingDistance) { if (currentVector == SlideVector.left) { return; } Debug.Log("left"); currentVector = SlideVector.left; } else if (y > x + SlidingDistance && y < -x - SlidingDistance) { if (currentVector == SlideVector.right) { return; } Debug.Log("right"); currentVector = SlideVector.right; } else if (y > x + SlidingDistance && y - SlidingDistance > -x) { if (currentVector == SlideVector.down) { return; } Debug.Log("down"); currentVector = SlideVector.down; } else if (y + SlidingDistance < x && y < -x - SlidingDistance) { if (currentVector == SlideVector.up) { return; } Debug.Log("up"); currentVector = SlideVector.up; } OnDirChange(gameObject, currentVector); timer = 0; touchFirst = touchSecond; } }
public void OnUp(GameObject go, PointerEventData data) { currentVector = SlideVector.nullVector; }