public void Swipe() { if (Input.touches.Length > 0) { Touch t = Input.GetTouch(0); if (t.phase == TouchPhase.Began) { //save began touch 2d point firstPressPos = new Vector2(t.position.x, t.position.y); } if (t.phase == TouchPhase.Ended) { //save ended touch 2d point secondPressPos = new Vector2(t.position.x, t.position.y); //create vector from the two points currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y); //normalize the 2d vector currentSwipe.Normalize(); /*swipe upwards * if (currentSwipe.y > 0 currentSwipe.x > -0.5f currentSwipe.x < 0.5f) * { * Debug.Log("up swipe"); * }*/ //swipe down if (currentSwipe.y < -0.5f && notEnd) { Debug.Log("down swipe"); notMenu = false; dirY = 1; showSettMenu(); } //swipe left else if (currentSwipe.x < -0.5f && notMenu && notEnd) { Debug.Log("left swipe"); directionX = -1; inkManager.ChooseLeft(); } //swipe right else if (currentSwipe.x > 0.5f && notMenu && notEnd) { Debug.Log("right swipe"); directionX = 1; inkManager.ChooseRight(); } } } if (Input.GetMouseButtonDown(0)) { //save began touch 2d point firstPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); } if (Input.GetMouseButtonUp(1) && notMenu) { showMagazine(); } if (Input.GetMouseButtonUp(0)) { //save ended touch 2d point secondPressPos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); //create vector from the two points currentSwipe = new Vector2(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y); //normalize the 2d vector currentSwipe.Normalize(); if (currentSwipe.y < -0.5f && notEnd) { Debug.Log("down swipe"); notMenu = false; dirY = 1; showSettMenu(); } //swipe left else if (currentSwipe.x < -0.5f && notMenu && notEnd) { Debug.Log("left swipe"); directionX = -1; inkManager.ChooseLeft(); } //swipe right else if (currentSwipe.x > 0.5f && notMenu && notEnd) { Debug.Log("right swipe"); directionX = 1; inkManager.ChooseRight(); } } }