How to Restart game (Menu and Game are in same Scene)?
Menu and Game are in the same scene (just like in subway surfers) and I want to restart the run without going back to the menu
I can't put
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
and disable the menuUI with
MenuUI.SetActive(false);
right after...
What can I do?
Answer by rayan_farsat · Apr 25, 2021 at 10:34 PM
Public void RestartButton ()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex)
MenuUI.SetActive(false);
}
If all you menu objects are in the MenuUI object try this and let me know what happened
Well, there are more than just MenuUI but I made it in short.
Anyways, the thing here is that by your example, it restarts the scene (which is good) but ignores the next step (to disable the MenuUI) which is not good :/
This is where I have been stuck for the whole day...
My example is the restart button it's for try agian so you don't need to go mian menu Make another button to go to mian menu
I have that. I have the menu where I can press Play, I have the game where I can Pause/fail and press Home or Restart.
Because all of this is in the same Scene, I have the SceneManager script in "Home" Button. For the Restart I would like to make it work like your example script where it reloads and just disables all the menu stuff, but like I said, when the script gets to "SceneManger.." it ignores everything below.
Isn't there any way to make this work properly?
Your answer
Follow this Question
Related Questions
UNET Multiple online scenes 0 Answers
How do I create a disconnect button in a scene [UNET] 0 Answers
I cant addet animation to script 1 Answer