Created
December 2, 2013 10:31
-
-
Save uhziel/7747676 to your computer and use it in GitHub Desktop.
显示有多少个手指头按上屏幕
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class touchit : MonoBehaviour { | |
| private string result = "none"; | |
| // Use this for initialization | |
| void Start () { | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| int fingerCount = 0; | |
| foreach (Touch touch in Input.touches) { | |
| if (touch.phase != TouchPhase.Canceled || touch.phase != TouchPhase.Ended) { | |
| fingerCount++; | |
| } | |
| } | |
| if (fingerCount > 0) | |
| result = "You have " + fingerCount + " fingers touching the screen."; | |
| } | |
| void OnGUI () { | |
| GUI.Label (new Rect (0.0f, 0.0f, 1000.0f, 20.0f), result); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment