01.使用到easytouch 的腳本的場景都需要添加EasyTouch物體

解決報錯
#pragma warning disable 0618
02.腳本中引入
using HedgehogTeam.EasyTouch;
03.4_X的使用
using System.Collections;
using System.Collections.Generic;
using HedgehogTeam.EasyTouch;
using UnityEngine;
public class EasyTouch4_XDemp : MonoBehaviour
{
/// <summary>
///訂閱注冊事件
/// </summary>
private void OnEnable()
{
EasyTouch.On_TouchStart += TouchStart;
EasyTouch.On_TouchUp += TouchUp;
EasyTouch.On_Swipe += TouchSwipe;
}
private void OnDisable()
{
EasyTouch.On_TouchStart -= TouchStart;
EasyTouch.On_TouchUp -= TouchUp;
EasyTouch.On_Swipe -= TouchSwipe;
}
private void OnDestroy()
{
}
private void TouchStart(Gesture gesture)
{
Debug.Log("開始點選:"+gesture.startPosition);
}
private void TouchUp(Gesture gesture)
{
Debug.Log("擡起時間:" + gesture.actionTime);
}
private void TouchSwipe(Gesture gesture)
{
Debug.Log("拖拽:" + gesture.position);
Debug.Log("拖拽類型:" + gesture.swipe);
}
}
using System.Collections;
using System.Collections.Generic;
using HedgehogTeam.EasyTouch;
using UnityEngine;
public class EasyTouch5_XDemo : MonoBehaviour
{
private void Update()
{
//擷取目前觸摸的單利類
Gesture currentGesture= EasyTouch.current;
if (currentGesture!=null&¤tGesture.type== EasyTouch.EvtType.On_TouchStart)
{
TouchStart(currentGesture);
}
else if (currentGesture != null && currentGesture.type == EasyTouch.EvtType.On_TouchUp)
{
TouchUp(currentGesture);
}
else if (currentGesture != null && currentGesture.type == EasyTouch.EvtType.On_Swipe)
{
TouchSwipe(currentGesture);
}
}
private void TouchStart(Gesture gesture)
{
Debug.Log("開始點選:" + gesture.startPosition);
}
private void TouchUp(Gesture gesture)
{
Debug.Log("擡起時間:" + gesture.actionTime);
}
private void TouchSwipe(Gesture gesture)
{
Debug.Log("拖拽:" + gesture.position);
Debug.Log("拖拽類型:" + gesture.swipe);
}
}