- Home /
How to load (restart) last scene
My question is simple ( I am kinda new) I have 2 scenes Home & Game In Game Scene I have a Pause Menu and using it I wanna go back to my home scene I have done everything the only problem I am facing is that MOST PROBABLY My home screen is not restarting. Everything is disabled as if I just pressed 'start game'. Please help
This is my script -
public Animator transitionAnimm; //fade
public string sceneName;
public void PlayGame()
{
StartCoroutine(LoadScene());
}
IEnumerator LoadScene()
{
transitionAnimm.SetTrigger("goback");//fade
yield return new WaitForSeconds(1.5f);//for smooth fading
SceneManager.LoadScene(sceneName);//'Home'
}
}
What do you mean by everything is disabled? 2. Are you eventually changing Time.TimeScale?
Animations in my home scene stops when I return from game sceen and buttons won't work
Do you have all the scenes loaded in your build settings: ToolBar> File>Build Settings?
yes done. I can go to game scene from home scene but can't go back to my home scene from game scene. The home scene gets loaded but the UI won't work.
Answer by Hatzz · Mar 05, 2019 at 06:43 PM
public ienumerator ienum; public void CutScene() { } public Animator transitionAnimm; public string sceneName; public void PlayGame() { StartCoroutine(LoadScene()); } IEnumerator LoadScene() { transitionAnimm.SetTrigger("goback");//trigger yield return new WaitForSeconds(1.5f);//for smooth fading SceneManager.LoadScene(sceneName);//'Home' }
There you go :)
Answer by Nocktion · Nov 04, 2018 at 12:11 PM
The SceneManager.LoadScene doesn't restart your scene it simply loads it again. So if you disable objects in the Home scene when switching to the game, then you have to enable it again when you switch back.
I hope my explanation is understanable (I'm not sure)