Skip to content

Instantly share code, notes, and snippets.

@uhziel
Created December 2, 2013 10:31
Show Gist options
  • Select an option

  • Save uhziel/7747676 to your computer and use it in GitHub Desktop.

Select an option

Save uhziel/7747676 to your computer and use it in GitHub Desktop.
显示有多少个手指头按上屏幕
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