Version: 2020.1
public static Touch[] touches ;

描述

返回表示上一帧中所有触摸状态的对象列表。(只读)(分配临时变量)。

每个条目代表手指触摸屏幕的状态。

using UnityEngine;

public class Example : MonoBehaviour { // Prints number of fingers touching the screen void Update() { var fingerCount = 0; foreach (Touch touch in Input.touches) { if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled) { fingerCount++; } } if (fingerCount > 0) { print("User has " + fingerCount + " finger(s) touching the screen"); } } }