using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pause : MonoBehaviour
{
public bool gamePause;// Start is called before the first frame updatevoidStart(){
gamePause = false;// 监测状态,初始化的时候表示没有暂停}// Update is called once per framevoidUpdate(){if(Input.GetKeyDown(KeyCode.Space)&& gamePause == false){
Time.timeScale =0;// 默认值是 1,设置为 0.5f,则是把速度降低一半,设置为 0 则暂停// 设置为 5 则为 5 倍速
gamePause = true;}elseif(Input.GetKeyDown(KeyCode.Space)&& gamePause == true){
Time.timeScale =1;// 在暂停过程按下空格,恢复原速度
gamePause = false;}}}