Search Unity

Muliti-scene lighting issue

Discussion in 'Global Illumination' started by GoesTo11, Feb 2, 2019.

  1. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    In my project, I have a number of minigames. Each one of those minigames can be played in a number of different environments. Originally, I had all of the environments load up with the minigame and to change the environment, I just activated the particular environment the player chose and deactivated the others.

    That became unwieldy as I added additional and larger environments. So I had the brilliant idea of making the player and the core of the minigame one scene and then load in the environement as another scene. Gameflow wise it works great, the player can choose to change the envriornment whenever they want.

    However, this has totally messed up the lighting in my scenes. The game appears to be using the global lighting settings (especially the skybox) from the minigame when I want it to use the settings from the environment. Since the environements are different, they need different lighting.

    Is there a way to fix this or am I going to have to rethink my multi-scene environment scheme? Thanks in advance.
     
  2. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    153
    Hey GoesTo11,

    so since we're dealing with Global Illumination, when loading several scenes they have to have a common reference. In your case, the player scene probably doesn't have anything set up, but the environment scenes do. We usually go by this rule: The current active scene drives the common settings, and everything else that was loaded gets tacked onto it.

    In your case, you could either set the environment via a script, or make the environment scene that you loaded active. Both should work to get the skybox back.

    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.SetActiveScene.html

    Does that work for you?

    Cheers
     
    GoesTo11 likes this.
  3. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    Thanks, I spent the weekend trying to put the minigames as prefabs but that caused it's own issues. I reverted to an older version today, re-upgraded it into 2018.4 and the lighting already looked much better. I'm not sure why. Anyway, one environment was still messed up and I added a script to an object in the scene with the start function:

    Code (CSharp):
    1. void Start()
    2.     {
    3.         SceneManager.SetActiveScene(this.gameObject.scene);
    4.     }
    That appears to have done the trick. Thanks.
     
    thefranke likes this.