using System.Collections; using System.Collections.Generic; using UnityEngine; public class Calculate : MonoBehaviour { public float Height = 1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { // 按下tab键,计算掉落用时 if (Input.GetKey(KeyCode.Tab)) { float g = Mathf.Abs(Physics2D.gravity.y); float t2 = 2 * Height / g; float t = Mathf.Sqrt(t2); Debug.Log("从高度 " + Height + " 米掉落,耗时 " + t + "s"); } } }