Search Unity

Issues with scenes

Discussion in 'Getting Started' started by Injax, Jan 16, 2020.

  1. Injax

    Injax

    Joined:
    Jan 1, 2020
    Posts:
    6
    I've just started Unity two to three weeks ago for a school project and I have no previous coding experience.

    I've been following a endless 2D runner tutorial however I have been having issues regarding the enabling and disabling of scenes. Essentially, I have a Pause Menu and a Death Menu. Whenever my character dies the Death Menu is enabled allowing the user to restart, go to main menu etc. But I can't figure out how to design it so the Pause Menu cannot be enabled whilst the Death Menu is enabled.

    01.PNG 02.PNG
     

    Attached Files:

    • 01.PNG
      01.PNG
      File size:
      38.8 KB
      Views:
      341
    • 02.PNG
      02.PNG
      File size:
      24.3 KB
      Views:
      340
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'd add a reference to the DeathMenu in the PauseMenu script. Your current code in PauseMenu.Update, have it first check if the DeathMenu is disabled, only if that is the case to you then do your current check for the escape key. I'd write it really quick, but I don't know what the Death Menu being enabled actually means in your game (does it mean a GameObject is set active? Does it mean a component has been enabled? etc).

    Also, in the future post your code using [ CODE] tags directly into the forum, so people can easily just copy and edit it to show you what to change. Otherwise with images they have to retype it all based on what is in the image.
     
  3. Injax

    Injax

    Joined:
    Jan 1, 2020
    Posts:
    6
    Cheers for the reply, a game object with the Death Menu script is being enabled/disabled. My original idea was to check if the DeathMenu was enabled before the key was pressed with an if statement as you suggested but I didn't know how to word it.