unity做单机游戏,暂停游戏,显示菜单(毕设过程中的一点小心得)
Time.timescale=0;//暂停游戏
Time.timescale=1//恢复在听的游戏
游戏暂停的过程中仍然可以对UI进行操作,比如按键的修改,声音大小的控制。代码也不是很难,还是给大家看一下例子,灵活运用
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StopGame : MonoBehaviour {
bool isStop=true ;//标志位,来判断游戏是否需要被暂停
public GameObject option;//这是我的设置UI界面
// Update is called once per frame
void Update () {
//游戏需