- Home /
Question by
fati36 · May 25, 2020 at 05:14 PM ·
scene-loadingrestart
Actions after LoadScene
Hey, i am loading the game scene after my Restart button. But when i reloaded scene i want to change something on scene. I tried with my code but it didnt happen is there a way to do that?
CODE;
public void RestartGame()
{
SceneManager.LoadScene("Game");
Panel.gameObject.SetActive(false); //something that i want to change on scene
}
Comment
Answer by KoenigX3 · May 25, 2020 at 05:23 PM
If you are loading another scene, you have to put that line into a script that's in the newly loaded scene.
If it's the same scene, you can use SceneManager.sceneLoaded
void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
// If scene is your game scene, change panel
}