我试图让团结认识到我从左向右滑动,我已经解决了这个问题,但我的问题是,直到我把手指从屏幕上抬起来它才明白这一点.
我的问题是我怎么做它让它知道我走了然后再向左然后再向右所有而不用我的手指屏幕
这是我到目前为止的代码
using UnityEngine;
using System.Collections;
public class Gestures : MonoBehaviour {
private Vector2 fingerStart;
private Vector2 fingerEnd;
public int leftRight = 0;
public int upDown = 0;
void Update () {
foreach(Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
fingerStart = touch.position;
fingerEnd = touch.position;
}
if (touch.phase == TouchPhase.Moved )
{
fingerEnd = touch.position;
}
if(touch.phase == TouchPhase.Ended)
{
if((fingerStart.x - fingerEnd.x) > 80 || (fingerStart.x - fingerEnd.x) < -80) // Side to side Swipe …Run Code Online (Sandbox Code Playgroud)