Skip to main content

Posts

Showing posts from 2017

Generic Swipe control for unity

Hi Guys,

Its been a long time since i posted anything, This time i am going to post something very useful but this time its more clean and inheritable.

You can inherit this Swipe Control script to any of your child classes and do task related to that child object. I will put an example below.


Enjoy!




using UnityEngine;
using System.Collections;

publicclassSwipeControll:MonoBehaviour
{
publicboolActive=true;

publicboolSwipeVertical=true;
publicboolSwipeHorizontal=true;

publicfloatminSwipeDistY;
publicfloatminSwipeDistX;
[HideInInspector]
publicboolHitSwipe=false;
protectedVector2startPos;



publicvirtualvoidActionUpSwipe()
{
//Debug.Log("SwipeUp");
}

publicvirtualvoidActionDownSwipe()
{
//Debug.Log("SwipeDown");
}

publicvirtualvoidActionRightSwipe()
{
//D