EasyTouch5

总结:

 

这里面的一些功能,就可以拿来做移动或者PC的很多功能了,这是一个很有用的插件。

 

禁用0618错误

EasyTouch4_x的写法:

using HedgehogTeam.EasyTouch;

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

/// <summary>

/// 有订阅方法,在不用的时候一定要取消订阅

/// </summary>

public class EasyTouch4_x : MonoBehaviour

{

//在OnEnable中订阅EasyTouch的事件

private void OnEnable()

    {

        EasyTouch.On_TouchStart += OnTouchStart;

        EasyTouch.On_TouchUp += OnTouchEnd;

        EasyTouch.On_Swipe += OnSwipe;

    }

//在OnDisable与OnDestroy中取消订阅OnEnable中对应的事件

private void OnDisable()

    {

        EasyTouch.On_TouchStart -= OnTouchStart;

        EasyTouch.On_TouchUp -= OnTouchEnd;

        EasyTouch.On_Swipe -= OnSwipe;

    }

private void OnDestroy()

    {

        EasyTouch.On_TouchStart -= OnTouchStart;

        EasyTouch.On_TouchUp -= OnTouchEnd;

        EasyTouch.On_Swipe -= OnSwipe;

    }

void OnTouchStart(Gesture gesture)//必须包含这个参数Gesture gesture

    {

        Debug.Log("OnTouchStart");

        Debug.Log("StartPosition" + gesture.startPosition);

    }

void OnTouchEnd(Gesture gesture)

    {

        Debug.Log("OnTouchEnd");

        Debug.Log("ActionTime" + gesture.actionTime);

    }

void OnSwipe(Gesture gesture)

    {

        Debug.Log("Swip");

        Debug.Log("Type" + gesture.touchType);

    }

}

EasyTouch5_x的新写法:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using HedgehogTeam.EasyTouch;

public class EasyTouch5_x : MonoBehaviour {

//EasyTouch5.x版本中的新特性可以不用书写订阅事件等一套语句

private void Update()

    {

//通过currentGesture获取当前玩家输入的手势

        Gesture currentGesture = EasyTouch.current;

//当前手势等于这个则执行

//currentGesture != null是为了防止一开始没有输入时报空指针

if (currentGesture != null&& EasyTouch.EvtType.On_TouchStart==currentGesture.type)

        {

            OnTouchStart(currentGesture);

        }

if (currentGesture != null && EasyTouch.EvtType.On_TouchUp == currentGesture.type)

        {

            OnTouchEnd(currentGesture);

        }

if (currentGesture != null && EasyTouch.EvtType.On_Swipe == currentGesture.type)

        {

            OnSwipe(currentGesture);

        }

    }

void OnTouchStart(Gesture gesture)//必须包含这个参数Gesture gesture

    {

        Debug.Log("OnTouchStart");

        Debug.Log("StartPosition" + gesture.startPosition);

    }

void OnTouchEnd(Gesture gesture)

    {

        Debug.Log("OnTouchEnd");

        Debug.Log("ActionTime" + gesture.actionTime);

    }

void OnSwipe(Gesture gesture)

    {

        Debug.Log("Swip");

        Debug.Log("Type" + gesture.touchType);

    }

}

QuickGestureDemo

有这几个操作:

 

缩放Pinch

 

这个需要勾选

 

 

5.0的新特性:EasyTouchTrigger

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Kerven_HKW

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值