- Home /
Executing Code by Scenes
I have a game manager that persists in al scenes and that controls the game logic and the scenes. I'm finding that I have to check for Application.loadedLevel in every Start() and Update(). Is there a better way to do this? Should I be structuring my code differently? This is the nly way I could think of to save high scores and display them in a high score scene.
Answer by Huacanacha · Apr 06, 2015 at 04:31 AM
App wide logic should persist across all scenes. For the most part this logic should't be concerned with what happens within scenes.
Scene specific logic should be handled by something that is loaded as part of the scene.
It sounds like you should break your game manager up into one app wide game manager plus one "scene manager" for each scene. Things will be much cleaner this way.
Yeah, in my project I use SceneLogic script to handle some level specific logic, and Scene$$anonymous$$anager, which is store current SceneLogic, switches the scenes if needed and catches OnLevelWasLoaded to get new SceneLogic from newly loaded scene
Your answer
![](https://koobas.hobune.stream/wayback/20220613192212im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
An OS design issue: File types associated with their appropriate programs 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Most convenient and fast way to persist/access/modify many values from scene to scene? (C#) 0 Answers
Persistence of saving data not working 2 Answers