下面这段代码演示游戏暂停
using UnityEngine; using System.Collections; public class GamePauseTest : MonoBehaviour { public float moveSpeed = 2.0f; void Update () { //move transform.Translate (new Vector3 (0, 0, moveSpeed * Time.deltaTime)); } void OnGUI () { if (GUI.Button (new Rect (140, 0, 100, 50), "暂停")) { Time.timeScale = 0; } if (GUI.Button (new Rect (280, 0, 100, 50), "继续")) { Time.timeScale = 1; } } }