- Home /
how to save scene when switch another scene?
hi, i want to make another page for my application in which there would be 3d object rotating on canvas. i made another scene for that. but when i switch to another scene and return back light become dim. i don't know what happened.
i also generate coins (prefab), which go disappear after coming on first scene. thanks
Answer by RIw · Mar 30, 2016 at 02:12 PM
You can use Serialization or...you can simply use this: http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html
Answer by Fredex8 · Mar 30, 2016 at 02:33 PM
The lights dimming like that is caused by it not rebuilding the lightmap. I believe this only happens when switching scenes when playing the game from the editor though and not in a standalone build.
You can solve this issue in the editor by going to Window>Lighting, unticking Auto and clicking Build to store the lightmap.
'Serialization' is a pretty generic term which doesn't really explain what to do and DontDestroyOnLoad
seems like a good way of just hogging extra memory unnecessarily if used on all the objects. If all you need it to do is remember how many coins were on screen and their positions then a script using DontDestroyOnLoad just for itself and which stores the coin positions and instantiates them again in the same place when the scene is revisited seems like it would perhaps be more sensible. It depends how frequently you need the scene to be reloaded, how complex it is and therefore how long it takes to load.
Your answer
Follow this Question
Related Questions
Change Scene keeping Character and GUI Canvas 1 Answer
Scene loading problem 5 Answers
Help with error message "Overwriting the same path as another open scene is not allowed" 0 Answers
,Enums not being passed between scripts properly 1 Answer
CheckConsistency: GameObject does not reference component Animator. Fixing. 0 Answers