This commit is contained in:
2024-10-16 00:03:41 +08:00
commit 897058435c
5033 changed files with 1009728 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
namespace HedgehogTeam.EasyTouch{
public class BaseFinger{
public int fingerIndex;
public int touchCount;
public Vector2 startPosition;
public Vector2 position;
public Vector2 deltaPosition;
public float actionTime;
public float deltaTime;
public Camera pickedCamera;
public GameObject pickedObject;
public bool isGuiCamera;
public bool isOverGui;
public GameObject pickedUIElement;
public float altitudeAngle;
public float azimuthAngle;
public float maximumPossiblePressure;
public float pressure;
public float radius;
public float radiusVariance;
public TouchType touchType;
public Gesture GetGesture(){
Gesture gesture = new Gesture();
gesture.fingerIndex = fingerIndex;
gesture.touchCount = touchCount;
gesture.startPosition = startPosition;
gesture.position = position;
gesture.deltaPosition = deltaPosition;
gesture.actionTime = actionTime;
gesture.deltaTime = deltaTime;
gesture.isOverGui = isOverGui;
gesture.pickedCamera = pickedCamera;
gesture.pickedObject = pickedObject;
gesture.isGuiCamera = isGuiCamera;
gesture.pickedUIElement = pickedUIElement;
gesture.altitudeAngle = altitudeAngle;
gesture.azimuthAngle = azimuthAngle;
gesture.maximumPossiblePressure = maximumPossiblePressure;
gesture.pressure = pressure;
gesture.radius = radius;
gesture.radiusVariance = radiusVariance;
gesture.touchType = touchType;
return gesture;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 8dfe7526dc614dd4a8e7249e52174f98
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using System.Collections;
namespace HedgehogTeam.EasyTouch{
[System.Serializable]
public class ECamera{
public Camera camera;
public bool guiCamera;
public ECamera( Camera cam,bool gui){
this.camera = cam;
this.guiCamera = gui;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 524815593fe79cf46b3c7e1ae30e948e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 42241010c6f9ddc46b78abdc21d505c5
timeCreated: 1440150387
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 9cfeb5ae16bf3cc4084255c9ae7cf36f, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,246 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using System.Collections;
namespace HedgehogTeam.EasyTouch{
// This is the class that simulate touches with the mouse.
// Internal use only, DO NOT USE IT
public class EasyTouchInput{
#region private members
private Vector2[] oldMousePosition = new Vector2[2];
private int[] tapCount = new int[2];
private float[] startActionTime = new float[2];
private float[] deltaTime = new float[2];
private float[] tapeTime = new float[2];
// Complexe 2 fingers simulation
private bool bComplex=false;
private Vector2 deltaFingerPosition;
private Vector2 oldFinger2Position;
private Vector2 complexCenter;
#endregion
#region Public methods
// Return the number of touch
public int TouchCount(){
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_BLACKBERRY || UNITY_TVOS || UNITY_PSP2) && !UNITY_EDITOR)
return getTouchCount(true);
#else
return getTouchCount(false);
#endif
}
private int getTouchCount(bool realTouch){
int count=0;
if (realTouch || EasyTouch.instance.enableRemote ){
count = Input.touchCount;
}
else{
if (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)){
count=1;
if (EasyTouch.GetSecondeFingerSimulation()){
if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(EasyTouch.instance.twistKey)|| Input.GetKey(KeyCode.LeftControl) ||Input.GetKey(EasyTouch.instance.swipeKey ))
count=2;
if (Input.GetKeyUp(KeyCode.LeftAlt)|| Input.GetKeyUp(EasyTouch.instance.twistKey)|| Input.GetKeyUp(KeyCode.LeftControl)|| Input.GetKeyUp(EasyTouch.instance.swipeKey))
count=2;
}
if (count ==0){
complexCenter = Vector2.zero;
oldMousePosition[0] = new Vector2(-1,-1);
oldMousePosition[1] = new Vector2(-1,-1);
}
}
}
return count;
}
// return in Finger structure all informations on an touch
public Finger GetMouseTouch(int fingerIndex,Finger myFinger){
Finger finger;
if (myFinger!=null){
finger = myFinger;
}
else{
finger = new Finger();
finger.gesture = EasyTouch.GestureType.None;
}
if (fingerIndex==1 && (Input.GetKeyUp(KeyCode.LeftAlt)|| Input.GetKeyUp(EasyTouch.instance.twistKey)|| Input.GetKeyUp(KeyCode.LeftControl)|| Input.GetKeyUp(EasyTouch.instance.swipeKey))){
finger.fingerIndex = fingerIndex;
finger.position = oldFinger2Position;
finger.deltaPosition = finger.position - oldFinger2Position;
finger.tapCount = tapCount[fingerIndex];
finger.deltaTime = Time.realtimeSinceStartup-deltaTime[fingerIndex];
finger.phase = TouchPhase.Ended;
return finger;
}
if (Input.GetMouseButton(0)){
finger.fingerIndex = fingerIndex;
finger.position = GetPointerPosition(fingerIndex);
if (Time.realtimeSinceStartup-tapeTime[fingerIndex]>0.5){
tapCount[fingerIndex]=0;
}
if (Input.GetMouseButtonDown(0) || (fingerIndex==1 && (Input.GetKeyDown(KeyCode.LeftAlt)|| Input.GetKeyDown(EasyTouch.instance.twistKey)|| Input.GetKeyDown(KeyCode.LeftControl)|| Input.GetKeyDown(EasyTouch.instance.swipeKey)))){
// Began
finger.position = GetPointerPosition(fingerIndex);
finger.deltaPosition = Vector2.zero;
tapCount[fingerIndex]=tapCount[fingerIndex]+1;
finger.tapCount = tapCount[fingerIndex];
startActionTime[fingerIndex] = Time.realtimeSinceStartup;
deltaTime[fingerIndex] = startActionTime[fingerIndex];
finger.deltaTime = 0;
finger.phase = TouchPhase.Began;
if (fingerIndex==1){
oldFinger2Position = finger.position;
oldMousePosition[fingerIndex] = finger.position;
}
else{
oldMousePosition[fingerIndex] = finger.position;
}
if (tapCount[fingerIndex]==1){
tapeTime[fingerIndex] = Time.realtimeSinceStartup;
}
return finger;
}
finger.deltaPosition = finger.position - oldMousePosition[fingerIndex];
finger.tapCount = tapCount[fingerIndex];
finger.deltaTime = Time.realtimeSinceStartup-deltaTime[fingerIndex];
if (finger.deltaPosition.sqrMagnitude <1){
finger.phase = TouchPhase.Stationary;
}
else{
finger.phase = TouchPhase.Moved;
}
oldMousePosition[fingerIndex] = finger.position;
deltaTime[fingerIndex] = Time.realtimeSinceStartup;
return finger;
}
else if (Input.GetMouseButtonUp(0)){
finger.fingerIndex = fingerIndex;
finger.position = GetPointerPosition(fingerIndex);
finger.deltaPosition = finger.position - oldMousePosition[fingerIndex];
finger.tapCount = tapCount[fingerIndex];
finger.deltaTime = Time.realtimeSinceStartup-deltaTime[fingerIndex];
finger.phase = TouchPhase.Ended;
oldMousePosition[fingerIndex] = finger.position;
return finger;
}
return null;
}
// Get the position of the simulate second finger
public Vector2 GetSecondFingerPosition(){
Vector2 pos = new Vector2(-1,-1);
if ((Input.GetKey(KeyCode.LeftAlt)|| Input.GetKey(EasyTouch.instance.twistKey)) && (Input.GetKey(KeyCode.LeftControl)|| Input.GetKey(EasyTouch.instance.swipeKey))){
if (!bComplex){
bComplex=true;
deltaFingerPosition = (Vector2)Input.mousePosition - oldFinger2Position;
}
pos = GetComplex2finger();
return pos;
}
else if (Input.GetKey(KeyCode.LeftAlt)|| Input.GetKey(EasyTouch.instance.twistKey) ){
pos = GetPinchTwist2Finger();
bComplex = false;
return pos;
}else if (Input.GetKey(KeyCode.LeftControl)|| Input.GetKey(EasyTouch.instance.swipeKey) ){
pos =GetComplex2finger();
bComplex = false;
return pos;
}
return pos;
}
#endregion
#region Private methods
// Get the postion of simulate finger
private Vector2 GetPointerPosition(int index){
Vector2 pos;
if (index==0){
pos= Input.mousePosition;
return pos;
}
else{
return GetSecondFingerPosition();
}
}
// Simulate for a twist or pinc
private Vector2 GetPinchTwist2Finger(bool newSim=false){
Vector2 position;
if (complexCenter==Vector2.zero){
position.x = (Screen.width/2.0f) - (Input.mousePosition.x - (Screen.width/2.0f)) ;
position.y = (Screen.height/2.0f) - (Input.mousePosition.y - (Screen.height/2.0f));
}
else{
position.x = (complexCenter.x) - (Input.mousePosition.x - (complexCenter.x)) ;
position.y = (complexCenter.y) - (Input.mousePosition.y - (complexCenter.y));
}
oldFinger2Position = position;
return position;
}
// complexe Alt + Ctr
private Vector2 GetComplex2finger(){
Vector2 position;
position.x = Input.mousePosition.x - deltaFingerPosition.x;
position.y = Input.mousePosition.y - deltaFingerPosition.y;
complexCenter = new Vector2((Input.mousePosition.x+position.x)/2f, (Input.mousePosition.y+position.y)/2f);
oldFinger2Position = position;
return position;
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 404eb304606225a41845f4e87b8531cc
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;
using System.Collections.Generic;
namespace HedgehogTeam.EasyTouch{
// Represents informations on Finger for touch
// Internal use only, DO NOT USE IT
public class Finger : BaseFinger{
public float startTimeAction;
public Vector2 oldPosition;
public int tapCount; // Number of taps.
public TouchPhase phase; // Describes the phase of the touch.
public EasyTouch.GestureType gesture;
public EasyTouch.SwipeDirection oldSwipeType;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 91501b99eb179804686edef05f75f7e3
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using System.Collections;
using System;
namespace HedgehogTeam.EasyTouch{
/// <summary>
/// This is the class passed as parameter by EasyTouch events, that containing all informations about the touch that raise the event,
/// or by the tow fingers gesture that raise the event.
/// </summary>
public class Gesture : BaseFinger,ICloneable{
/// <summary>
/// The siwpe or drag type ( None, Left, Right, Up, Down, Other => look at EayTouch.SwipeType enumeration).
/// </summary>
public EasyTouch.SwipeDirection swipe;
/// <summary>
/// The length of the swipe.
/// </summary>
public float swipeLength;
/// <summary>
/// The swipe vector direction.
/// </summary>
public Vector2 swipeVector;
/// <summary>
/// The pinch length delta since last change.
/// </summary>
public float deltaPinch;
/// <summary>
/// The angle of the twist.
/// </summary>
public float twistAngle;
/// <summary>
/// The distance between two finger for a two finger gesture.
/// </summary>
public float twoFingerDistance;
public EasyTouch.EvtType type = EasyTouch.EvtType.None;
#region public method
public object Clone(){
return this.MemberwiseClone();
}
/// <summary>
/// Transforms touch position into world space, or the center position between the two touches for a two fingers gesture.
/// </summary>
/// <returns>
/// The touch to wordl point.
/// </returns>
/// <param name='z'>
/// The z position in world units from the camera or in world depending on worldZ value
/// </param>
/// <param name='worldZ'>
/// true = r
/// </param>
///
public Vector3 GetTouchToWorldPoint(float z){
return Camera.main.ScreenToWorldPoint( new Vector3( position.x, position.y,z));
}
public Vector3 GetTouchToWorldPoint( Vector3 position3D){
return Camera.main.ScreenToWorldPoint( new Vector3( position.x, position.y,Camera.main.transform.InverseTransformPoint(position3D).z));
}
/// <summary>
/// Gets the swipe or drag angle. (calculate from swipe Vector)
/// </summary>
/// <returns>
/// Float : The swipe or drag angle.
/// </returns>
public float GetSwipeOrDragAngle(){
return Mathf.Atan2( swipeVector.normalized.y,swipeVector.normalized.x) * Mathf.Rad2Deg;
}
/// <summary>
/// Normalizeds the position.
/// </summary>
/// <returns>
/// The position.
/// </returns>
public Vector2 NormalizedPosition(){
return new Vector2(100f/Screen.width*position.x/100f,100f/Screen.height*position.y/100f);
}
/// <summary>
/// Determines whether this instance is over user interface element.
/// </summary>
/// <returns><c>true</c> if this instance is over user interface element; otherwise, <c>false</c>.</returns>
public bool IsOverUIElement(){
return EasyTouch.IsFingerOverUIElement( fingerIndex);
}
/// <summary>
/// Determines whether this instance is over rect transform the specified tr camera.
/// </summary>
/// <returns><c>true</c> if this instance is over rect transform the specified tr camera; otherwise, <c>false</c>.</returns>
/// <param name="tr">Tr.</param>
/// <param name="camera">Camera.</param>
public bool IsOverRectTransform(RectTransform tr,Camera camera=null){
if (camera == null){
return RectTransformUtility.RectangleContainsScreenPoint( tr,position,null);
}
else{
return RectTransformUtility.RectangleContainsScreenPoint( tr,position,camera);
}
}
/// <summary>
/// Gets the first picked user interface element.
/// </summary>
/// <returns>The first picked user interface element.</returns>
public GameObject GetCurrentFirstPickedUIElement(bool isTwoFinger=false){
return EasyTouch.GetCurrentPickedUIElement( fingerIndex,isTwoFinger);
}
/// <summary>
/// Gets the current picked object.
/// </summary>
/// <returns>The current picked object.</returns>
public GameObject GetCurrentPickedObject(bool isTwoFinger=false){
return EasyTouch.GetCurrentPickedObject( fingerIndex,isTwoFinger);
}
#endregion
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 42d70a45bcf6a3b4cb6fbc54cefed1e4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,65 @@
/***********************************************
EasyTouch V
Copyright © 2014-2015 The Hedgehog Team
http://www.thehedgehogteam.com/Forum/
The.Hedgehog.Team@gmail.com
**********************************************/
using UnityEngine;
using System.Collections;
namespace HedgehogTeam.EasyTouch{
public class TwoFingerGesture{
public EasyTouch.GestureType currentGesture = EasyTouch.GestureType.None;
public EasyTouch.GestureType oldGesture= EasyTouch.GestureType.None;
public int finger0;
public int finger1;
public float startTimeAction;
public float timeSinceStartAction;
public Vector2 startPosition;
public Vector2 position;
public Vector2 deltaPosition;
public Vector2 oldStartPosition;
public float startDistance;
public float fingerDistance;
public float oldFingerDistance;
public bool lockPinch=false;
public bool lockTwist=true;
public float lastPinch=0;
public float lastTwistAngle = 0;
// Game Object
public GameObject pickedObject;
public GameObject oldPickedObject;
public Camera pickedCamera;
public bool isGuiCamera;
// UI
public bool isOverGui;
public GameObject pickedUIElement;
public bool dragStart=false;
public bool swipeStart=false;
public bool inSingleDoubleTaps = false;
public float tapCurentTime = 0;
public void ClearPickedObjectData(){
pickedObject = null;
oldPickedObject = null;
pickedCamera = null;
isGuiCamera = false;
}
public void ClearPickedUIData(){
isOverGui = false;
pickedUIElement = null;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b166c9002d8a98e4d9923f6b75a54197
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: