- Home /
Main Menu Canvas and SetActive
I have a Scene that has 2 Canvases - Main Menu and Level Selector (Has buttons for Level 1, Level 2 etc). When the game is initially loaded, The Main Menu Canvas is Active and the Level Selector is Not Active. When you click on the Level Selector button, it swaps these around (Main Menu Canvas isn't active and Level Selector is Active).
When I load a new scene (Such as clicking on Level 2) and press the back button to return to the above scene - obviously it resets to original state which is with the Main menu canvas - active , levels canvas- Inactive.
My Question is, How would you set the scene to be so that it goes back to the state where Levels canvas is active. I've read some things about OnSceneloaded but was unsure if that was the best way to approach this.
Answer by Nistroy · Feb 14, 2021 at 05:36 PM
It's simple @HBishop . In fact when you move from one scene to another any changes are not saved! So that means that if you move to another level and come back to the previous scene, your Main Menu and your level selector will be reset. You can have two alternatives to your problem: Either you save the changes with a save file, or you create a GameManager with a script that saves the changes to your game and this GameManager you place in DontDestroyOnLoad. I don't know if I'm clear, I'm French haha :). If you want me to make an example for you, tell me
No, that's perfect. I have a Game$$anonymous$$anager but didn't think to use it for canvas management by making it a DDOL. Thank you so much!