目录
1.OnTouchStart,OnTouchUp,OnSwipe
(一)EasyTouch基础使用
1.OnTouchStart,OnTouchUp,OnSwipe
using UnityEngine;
using HedgehogTeam.EasyTouch;
public class Test : MonoBehaviour
{
private void Update()
{
Gesture currentGesture = EasyTouch.current;
if (currentGesture != null&¤tGesture.type ==EasyTouch .EvtType .On_TouchStart )
{
OnTouchStart(currentGesture);
}
if(currentGesture != null && currentGesture .type ==EasyTouch .EvtType .On_TouchUp)
{
OnTouchUp(currentGesture);
}
if(currentGesture != null && currentGesture .type ==EasyTouch .EvtType .On_Swipe)
{
OnSwipe(currentGesture);
}
}
void OnTouchStart(Gesture gesture)
{
Debug.Log("OnTouchStart! StartPosition:" + gesture.startPosition);
}
void OnTouchUp(Gesture gesture)
{
Debug.Log("OnTouchUp! ActionTime:" + gesture.actionTime);
}
void OnSwipe(Gesture gesture)
{
Debug.Log("OnSwipe! Type:" + gesture.swipe );
}
}
2.QuickGesture
先给cube添加脚本“QuickGestureDemo”
using UnityEngine;
public class QuickGestureDemo : MonoBehaviour
{
public void PrintNum(int num)
{
Debug.Log(num);
}
}
(1)Quick Drag
(2)Quick Enter Over Exit
(3)Quick Long Tap
(4)Quick Pinch(按住alt,可以模拟双指)
(5)Quick Swipe
(6)Quick Tap
(7) Quick Touch
(8)Quick Twist
(二)EasyTouch JoyStick
using UnityEngine;
public class EasyTouchTest : MonoBehaviour
{
public float speed = 1;
public void CubeTranslate(Vector2 direction)
{
transform.Translate(new Vector3(direction.x * Time.deltaTime * speed, 0, direction.y * Time.deltaTime * speed));
}
public void Fire()
{
Debug.Log("fire");
}
public void FireAlways()
{
Debug.Log("FireAlways");
}
public void CloseWnd()
{
Debug.Log("CloseWnd");
}
}