//마우스

    if (Input.GetMouseButtonDown(0))
    {
      firstPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
    }
    if (Input.GetMouseButtonUp(0))
    {
      secondPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
      if (secondPressPos.y < 100 || secondPressPos.y > 450) return;
      if (firstPressPos.y < 100 || firstPressPos.y > 450) return;
      currentSwipe = new Vector2(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
      currentSwipe.Normalize();

      //swipe upwards
      if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
      {
        Swipe(0);
      }
      //swipe down
      if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
      {
        Swipe(1);
      }
      //swipe left
      if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
      {
        Swipe(2);
      }
      //swipe right
      if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
      {
        Swipe(3);
      }
    }


//터치
if (Input.touches.Length > 0)
    {
      Touch t = Input.GetTouch(0);
      if (t.phase == TouchPhase.Began)
      {
        firstPressPos = new Vector2(t.position.x, t.position.y);
      }
      if (t.phase == TouchPhase.Ended)
      {
        secondPressPos = new Vector2(t.position.x, t.position.y);
        if (secondPressPos.y < 100 || secondPressPos.y > 450) return;
        if (firstPressPos.y < 100 || firstPressPos.y > 450) return;
        currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
        currentSwipe.Normalize();

        //swipe upwards
        if (currentSwipe.y > 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
        {
          Swipe(0);
        }
        //swipe down
        if (currentSwipe.y < 0 && currentSwipe.x > -0.5f && currentSwipe.x < 0.5f)
        {
          Swipe(1);
          //swipe left
          if (currentSwipe.x < 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
          {
            Swipe(2);
          }
          //swipe right
          if (currentSwipe.x > 0 && currentSwipe.y > -0.5f && currentSwipe.y < 0.5f)
          {
            Swipe(3);
          }
        }
      }
    }



이거 스와이프 유니티게임실행시켜서 마우스로할땐 되는데 어플로 가니까 터치가 말썽을 부리네..


스와이프 가능영역 나누고 싶었던건데 서로 좌표값이 다른가??


1. 투명이미지를 만들어서 터치영역 좌표에서 RayCast해서 체크한다.


2. 좌표값 화면상에 띄워서 확인한다(Debug.Log 처럼)


어떻게 해결을 해야할까