using UnityEngine; using System.Collections; using System.Collections.Generic; [RequireComponent(typeof(SwipeManager))] public class InputController : MonoBehaviour { public SwipeMove OurPlayer; // Perhaps your playerscript? void Start() { SwipeManager swipeManager = GetComponent(); swipeManager.onSwipe += HandleSwipe; swipeManager.onLongPress += HandleLongPress; } void HandleSwipe(SwipeAction swipeAction) { //Debug.LogFormat("HandleSwipe: {0}", swipeAction); if (swipeAction.direction == SwipeDirection.Up || swipeAction.direction == SwipeDirection.UpRight) { // move up if (OurPlayer != null) OurPlayer.SlideForward(); } else if (swipeAction.direction == SwipeDirection.Right || swipeAction.direction == SwipeDirection.DownRight) { // move right if (OurPlayer != null) OurPlayer.SlideRight(); } else if (swipeAction.direction == SwipeDirection.Down || swipeAction.direction == SwipeDirection.DownLeft) { // move down if (OurPlayer != null) OurPlayer.SlideBackward(); } else if (swipeAction.direction == SwipeDirection.Left || swipeAction.direction == SwipeDirection.UpLeft) { // move left if (OurPlayer != null) OurPlayer.SlideLeft(); } else { if (OurPlayer != null) OurPlayer.SlideNone(); } } void HandleLongPress(SwipeAction swipeAction) { Debug.LogFormat("HandleLongPress: {0}", swipeAction); } }