暂停菜单,健康栏不会暂停

时间:2016-05-15 18:57:19

标签: unity3d

每当我按下退出按钮时,我的游戏暂停并显示gui但我在画布上的健康栏不会暂停..这是我的代码..任何建议

using UnityEngine;
using System.Collections;
public class PauseMenu : MonoBehaviour {
bool paused = false;
void Update()
{
    if(Input.GetButtonDown("pauseButton"))
        paused = togglePause();
}
void OnGUI()
{
    if(paused)
    {
        if(GUI.Button(new Rect(Screen.width/2-        100,Screen.height/2+1,180,40),"Resume Game"))
            paused = togglePause();
    }
}
bool togglePause()
{
    if(Time.timeScale == 0f)
    {
        Time.timeScale = 1f;
        return(false);
    }
    else
    {
        Time.timeScale = 0f;
        return(true);    
    }
}
}

1 个答案:

答案 0 :(得分:1)

Time.timeScale = 0并没有阻止一切。

如果它会阻止你的游戏冻结并完全没有响应的一切。如果您的损坏被称为例如在Update中并且不使用Time.deltaTime它仍然会被调用。

相关问题