I forget Unity all. Human is amazing.

How to get tap in Unity is the following,

// Update is called once per frame
void Update () {
	if (Input.touchCount > 0) {
		Touch myTouch = Input.GetTouch (0);					// get first tap
		// Touch[] myTouches = Input.touches;				// if you get multi tap
		// for(int i = 0; i < Input.touchCount; i++){}		// process in for loop

		// process for tap
		Vector2 vec2 = myTouch.position;
		Debug.Log("(" + vec2.x + ", " + vec2.y + ")" );

		// start, move, and finish of tap
		if(myTouch.phase == TouchPhase.Began)
		{
			// start tap
		}
		else if (myTouch.phase == TouchPhase.Moved)
		{
			// move tap
		}
		else if (myTouch.phase == TouchPhase.Ended)
		{
			// finish tap
		}
	}

}

Add the above script to any object.

 

References:

https://unity3d.com/jp/learn/tutorials/topics/mobile-touch/multi-touch-input?playlist=45798

https://docs.unity3d.com/ScriptReference/Touch.html?_ga=2.133886541.23970780.1495464928-455626883.1490587154

Categories: Memo

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.