Hello
I wrote currently a game code, but im stuck with a big problem. I want that, when the esc key is pressed, the menu is showed.
That is my hierarchy:
Canvas
Panel
TextScore // to show the score on the screen
FinishMenu // when the level is complete
QuitButton
MenuButton
NextButton
EscapeMenu // whenn you press esc key, menu is showed
QuitButton
MenuButton
ReplayButton
ContinueButton
FallDownMenu // when the player die, the menu is showed
QuitButton
MenuButton
ReplayButton
PauseButtonImage // Image ( || ) for pause on the screen
a) when the level is complete, a menu is showed with differents buttons like in the hierarchy. it works
b) when the player (gameObject) dies, a menu is showed. It works like a)
c) But while you play and try the esc key, the game is paused but the menu is not showed
that is the code
public GameObject escapeMenues;
public bool isPaus;
private int escCount = 0;
public Text textScoreText;
public Text topScoreTop;
void Start()
{
isPaus = false;
escapeMenues.SetActive(false);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape) && escCount == 0)
{
setPause();
SetCountText();
escapeMenues.SetActive(true);
escCount = 1;
}
if (Input.GetKeyDown(KeyCode.Escape) && escCount == 1)
{
setPause();
escapeMenues.SetActive(false);
escCount = 0;
}
}
public void loadNaechsteLevel()
{
//Application.LoadLevel(_levelName);
Application.LoadLevel(Application.loadedLevel + 1);
}
public void loadSelbeLevel()
{
Application.LoadLevel(Application.loadedLevel);
}
public void loadMenu()
{
Application.LoadLevel("Menus");
}
public void VerlasseDasSpiel()
{
Application.Quit();
}
public void setPause()
{
if (!isPaus)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
isPaus = !isPaus;
}
void SetCountText()
{
textScoreText.text = RotateSphere.countPickUp.ToString();
topScoreTop.text = RotateSphere.topScore.ToString();
}
I assigned public GameObject escapeMenues with EscapeMenu in my hierarchy
I also tried to debug it. I wrote some Debug.Log(); in to if (Input.GetKeyDown(KeyCode.Escape) && escCount == 0). It works of cause, then the game is paused but the menu is not showed.
The plattform is android
Please i need you help, thank you !!