zoukankan      html  css  js  c++  java
  • EasyTouch5ForSiki学院

    总结:

    这里面的一些功能,就可以拿来做移动或者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

    我爱学习,学习使我快乐。
  • 相关阅读:
    572.Subtree of Another Tree
    35.Search Insert Position(二分查找)
    198.House Robber(dp)
    724.Find Pivot Index
    705.Design HashSet
    求连通分量(深搜)
    删边(normal)
    叠放箱子问题
    数字游戏
    火车票
  • 原文地址:https://www.cnblogs.com/kerven/p/8118239.html
Copyright © 2011-2022 走看看