MainMenu = escape = MainMenu

Hi all.
I have a problem i have a code when i press escape it loads my main menu,
but i want when i press it again it loads my scene back.
Is it posible and how?
Thank you.

yesh, in update function use a boolean:

var menu:boolean=false;//declare bollean

//add to update function
if (Input.GetKey (KeyCode.Escape)) menu=!menu;

//add in OnGui funciton

if (menu) ...... //do gui

when you load a scene the actual scene is completely removed and when you load your scene back it will start new (not in the state you left it).
you have several possibilities:
using unity pro you can loadleveladditive your menu and remove it manually afterwards
storing your gamescene and restoring it (kind of savegame).
if your gamestate consists only from a hand full of objects you can make them dontdestroyonload and keep them this way between switching scenes but this makes handling, creation + manual destruction complicated.
displaying the menu only as gui in the gamescene without switching to another scene.

i suggest going for the last one as it requires less effort and should be the cleanest solution.

Hi thanx for you feedbacks i got some pause menu script and i created my main menu.But when i use my pause menu script a click back to main menu sceen it loads my scene but suddenly my main menu buttons won’t work.If you understanded this can you help me :wink: thank you.

Here’s the Pause menu that i used:

Bump

Bump :slight_smile:

But im pretty sure you can pause the scene and open up a GUI or something…

It’s ok thanx for feedback i soled it :smile: