- Home /
Changing scene messes up lights
I currently have two scenes in the project, and whenever I switch between them, the lights messes up. The first scene that loads is fine, but the second has its directional lights dimmed, the third has all lights dimmed and the fourth have no light at all.
It doesn't matter if I load the other scene or the same that just played.
I don't know what is causing it. I have tried the global light settings, I have checked that no script is changing any lights, I have tried overriding the light settings manually, it just won't work.
The scene change is triggered through JavaScript when the player touches a "goal" object. The script looks like this:
#pragma strict
function Update () {
transform.Rotate(1*(Time.deltaTime*10), 0,0);
}
function OnCollisionEnter(col : Collision){
if(Application.levelCount-1 > Application.loadedLevel)
Application.LoadLevel(Application.loadedLevel+1);
if(Application.levelCount-1 == Application.loadedLevel)
Application.LoadLevel(0);
Physics.gravity = new Vector3(0, -9.81, 0);
}
I have tried removing all other scripts and just have the player drop right onto the object, that gives the exact same result, so I don't think any other scripts are messing with it.
Answer by morphman86 · May 04, 2015 at 09:35 AM
Eventually I did get it to work. What exactly the issue was, I do not know, but I worked it out by creating my own skybox material, implementing it, turning off GI Baking and Continuous Baking and baked the GI manually.
Based on some tests I did, on first load if you have selected Ambient Source to be Skybox under Environment Lighting then Unity uses the Skybox as the ambient source and on subsequent load of any scene Unity ignores the Skybox as ambient source and uses the Color as the ambient source. Since the default color value for ambient source is dark grey the scene looks darker on load. It's just as if Unity is not able to find the Skybox and defaults to the Color mode for ambient source.
How to turn off GI Baking and Continuous Baking and baked the GI manually?
Answer by BenouKat · Apr 27, 2015 at 07:55 AM
It's due to the global Illumination. Try to uncheck every GI stuff, especially the "Continuous Baking" on the very bottom of the menu. Note that this "bug" only happen in Editor, you build will be fine.
I missed the Continuous Baking tickbox at the bottom when I unchecked everything... Unchecking it helped on the second scene, but not the first. Having it unchecked on the first brought down the light level to the standard GI settings (even if I had changed them). Checking it again fixed it, but whenever it switches back to the first level with it checked, it happens again.
You need to dop this on every scene. The Lightning windows isn't project related, it's scene related.
I have, but it only sets the correct lighting on Scene 1 if I leave baking on in that scene and the reverse for the second scene. If I turn it on in scene 2, that scene will be dark ins$$anonymous$$d.
However, if I do leave it turned on in scene 1, that one will become dark when it comes around the second time.
Answer by carlqwe · Apr 28, 2015 at 04:29 PM
I had the same problem heres a fix:
Before launching ur scene make sure the light isn't bugged!
If it's not bugged and it's becoming totally black then try to add other kind of lights
If it is bugged try to reposition it or/and readd it in your scene!
Hope you fix it!! ~carlqwe
Answer by MaDDoX · Feb 19, 2017 at 07:09 AM
Try copying all lighting settings and make sure to assign your baked Lighting Data Asset (at lightmaps tab) in the loading scene - and any intermediate scenes - , that worked for me.
Answer by PFast · Sep 01, 2017 at 09:05 AM
I ended up making a new scene and importing all my stuff from the broken scene by making them prefabs. Just had to reconnect a lot of variables, but fortunately it was a small-ish scene.
I didn't actually manage to fix it properly inside the same scene, but I couldn't really find any settings that were wrong. I think the scene was damaged at some point, it's meta file created problems at the start if I remember correctly. (was using Unity 2017.1)
Your answer
Follow this Question
Related Questions
Can someone help me fix my Javascript for Flickering Light? 6 Answers
2D Lighting Effects in Unity? 0 Answers
WebGl : lights does not working well 1 Answer
Lighting doesn't work properly in WebGL build 0 Answers
Shader? Light magnifying wall?? 1 Answer