我正在为我的游戏写一个暂停按钮(手机游戏) .
我的暂停脚本:
using UnityEngine;
using System.Collections;
public class PauseScript : MonoBehaviour {
public bool paused;
// Use this for initialization
void Start () {
paused = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
paused = !paused;
}
if (paused)
{
Time.timeScale = 0;
}
else if (!paused)
{
Time.timeScale = 1;
}
}
public void Pause()
{
paused = !paused;
if (paused)
{
Time.timeScale = 0;
}
else if (!paused)
{
Time.timeScale = 1;
}
}
}
和Jump这样写的 jump = Input.GetButton("Fire1");
当我触摸按钮时,我的播放器会跳跃并且游戏不会暂停 .
我如何让我的游戏暂停,玩家不跳?