- Home /
Application.LoadLevel() changes lighting for some reason?
I'm making a very simple game. Basically after the play misses three object, the game will reload the scene he was just on.
So i would use Application.LoadLevel("_Scene_00");
However, for some reason whenever the game reloads _Scene_00, the lighting darkens dramatically. I'm using a directional light, and even after the scene change it is still in the same spot.
Before:
After:
It appears, this error re-surfaces every few versions? Did not have any problems in previous versions, but in 5.5 it's screwed up. :( Good thing, disabling auto build, as mentioned below, fixes it.
Answer by Wolfdog · Apr 04, 2015 at 10:25 AM
After building the game, everything is working again, so no worries.
To fix it in the Editor, go to Window -> Lighting -> Lightmap Tab -> Disable Continuous Baking -> Press Build to bake the lighting once manually.
Note that if you add more lights or make some changes, you have to bake the lightmap again.
If you were courious you have to do this for each level and have somewhere to keep the settings
Answer by ScarredBison · Feb 29, 2016 at 04:12 PM
Window > Lighting > Other Settings. Turn off Auto and press Build.
FYI this just worked for me in 2017.3 (the suggestion in the top comment seems to be outdated).
I tried it with version 2017.3.1f1 but it's still doing it as soon as I change the scene in the game view.
Answer by One Ring · Mar 11, 2015 at 11:37 AM
I'm having the same problem, it seems to be something to do with the global illumination, I have not found a fix, however the problem doesn't seem to impact the build, just playing in the editor. Trying building and running that, hopefully the editor will be fixed in a future patch or something.
Yeah it actually works well in the build. Just really irritating when you are trying to test levels and the lighting goes out.
Just want to also say that While changing my settings in lighting and also depending on my sky box i had Different effects some times depending changing the sky box back to default it fixed my issues
The fix is to go to Window -> Lighting -> Lightmap Tab -> Disable Continuous Baking -> Press Build to bake the lighting once manually. And now the lighting remains consistent. Original: http://forum.unity3d.com/threads/application-loadlevel-application-loadedlevel-resets-level-but-causes-light-intensity-to-change.308248/#post-2006396
This actually works but my scene is a little dark
Answer by sr3d · Oct 29, 2015 at 11:25 AM
In both of your scenes go to Window --> Lighting --> Lightmaps and disable auto and manually click Bake. Leave the auto checkbox off. Do this for both of your scenes, the start menu scene and your game scene. In both scenes the auto checkbox must be off and have a lightmap snapshot up above in the lightmap snapshot field.
Thanks for the black magic... Need to apply for both scenes.. I always thought the Lighting setting is applied for all the scenes...
Answer by helgewl · Sep 17, 2015 at 12:16 PM
In Unity 5.2.0f3, if you call DynamicGI.UpdateEnvironment() after scene has loaded in the editor, this will fix some of the missing GI. I have implemented this workaround in a persistent (DontDestoyOnLoad) MonoBehaviour:
void OnLevelWasLoaded(int level) {
#if UNITY_EDITOR && (UNITY_5_0 || UNITY_5_1 || UNITY_5_2_0)
if (UnityEditor.Lightmapping.giWorkflowMode == UnityEditor.Lightmapping.GIWorkflowMode.Iterative) {
DynamicGI.UpdateEnvironment();
}
#endif
}
Actually, some scenes would still have render issues when loaded. I am now starting a co-routine that does a second DynamicGI.UpdateEnvironment() after WaitForEndOfFrame.
Your answer
Follow this Question
Related Questions
Load level that was previously loaded! 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Scene Asset Bundle - LoadLevelAdditive and OnLevelWasLoaded 1 Answer
Way to have 2D Sprites lit by Lights? 3 Answers