- Home /
How can I have several scenes running at the same time?
I have made a simple clicker game where you have to click a button to create gold and a simple animation plays when you do that. Eventually you can automatize the process of making gold, meaning you get 1 gold per second without doing anything. I have also created a separate scene which displays the total amount of gold you mined and a bunch of achievements, which are implemented as a simple text that is gray by default and changes its color to green when the achievement is completed. You can also switch between scenes with a button. But, whenever I switch to the achievements scene, auto mining stops working as well as any animations in the main scene. I have tried loading scenes with LoadSceneMode.Additive but it creates an additional instance of a scene each time when the player switches between them, resulting in a numerous amount of scenes making me have more than 1 audio and event listener. My question is how can I keep my main scene running while I have achievements scene selected and how can I only have one event and audio listener at all times? ,
Answer by MickyX · Jun 05 at 09:19 PM
To start I want to say I'm not sure why you want to use other scenes for that, sounds like it would suit a game object that you show and hide when needed. But that aside
Perform a check to see if the scene is already loaded before calling LoadSceneMode.Additive, that will stop duplicate scenes. Same with AudioListener and Events. Either create a script that destroys them if one already exists, or write a script that only Instantiates them if there isn't one already in the scene.
Personally I would look for a different way to create what you want rather than having multiple scenes for something like achievements.
Thank you. I ended up attaching main game and achievements to two different game object and switching between them. Much easier than tinkering with scenes especially for a beginner like me.
Your answer
Follow this Question
Related Questions
Referencing a gameobject in another scene 1 Answer
How Do I Link Different Scenes? 4 Answers
Change Scene keeping Character and GUI Canvas 1 Answer
Load Scene Bug 0 Answers
Can't find game object / script after scene re-enter 1 Answer