Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5: Losing Skybox/Sun/Fog on LoadLevelAdditive

Discussion in 'Editor & General Support' started by cranky, Mar 19, 2015.

  1. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    When using LoadLevelAdditive, my scene no longer contains the skybox, sun, and fog references I had previously set. They are set to None, which are the settings for the initial scene loaded. I understand this is the Unity intended behavior, but I need to apply the scene's environment lighting and fog when I call LoadLevelAdditive. I do not believe that manually reassigning them via scripting is an acceptable alternative, as reassigning them in the inspector still looks off. It seems as if the ambient light and reflection light from the skybox isn't being displayed correctly when I manually reassign the settings.

    What can I do to fix this problem? Thanks!

    EDIT: Assigning these values via scripting after loading the scene does not change the result -- there are no reflections.

    RenderSettings.skyBox
    RenderSettings.ambientMode
    RenderSettings.defaultReflectionMode
    RenderSettings.reflectionIntensity
    RenderSettings.reflectionBounces
     
    Last edited: Mar 19, 2015
  2. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    320
    I have experienced the same sort of problem. Changing the RenderSettings at runtime seems to have no effect on reflected lighting.
     
  3. StarGamess

    StarGamess

    Joined:
    Jul 21, 2014
    Posts:
    179
    Did you find a solution yet?
     
  4. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    I just don't use load level additive to load my levels. I made my common objects into resources and load them when I load the map.
     
  5. Piflik

    Piflik

    Joined:
    Sep 11, 2011
    Posts:
    289
    To expand on this: not only are the settins missing from the additively loaded scenes, they also don't use the settings (aside from Ambient Light Intensity) from the originally loaded scene.
     
  6. Byrcholk

    Byrcholk

    Joined:
    Mar 31, 2016
    Posts:
    2
    I also thought that I was losing fog when adding a scene additively. However, at least in my case, the fog was being lost when I unloaded a scene, and only when I unloaded the scene that was at the top of the hierarchy when I turned fog on.

    I am turning on fog using RenderSettings in a script attached to the camera. This scripted fog was not displayed until I changed a project setting: Edit > Project Settings > Graphics > Shader Stripping > Fog Modes to “Manual”.

    I have created a small project to reproduce this problem and sent a problem report to Unity ((Case 789589) Fog disappears when a scene is Unloaded).
    EDIT: Apparently, things are working as designed. Scripted lighting settings are associated with the main scene (top scene in the hierarchy) of a multiple scene display. If the main scene is unloaded, the scripted lighting settings are lost and the lighting settings of the next scene in the hierarchy are applied. If the scripted lighting settings are still designed, the scripted lighting settings must be reapplied after the main scene is unloaded.

    These workarounds to the problem seem to be available:
    • Never unload the first scene of a multiple scene display as long as fog is desired.
    • After unloading a scene, check to see if fog has been turned off, and if still required, turn fog back on.

    In my project, I have adopted the second workaround to check after unloading because (at least for testing purposes) I can want to start the game from any scene in the project.
     
    Last edited: Apr 20, 2016
    unity_medway likes this.
  7. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Hi @Byrcholk ?
    Can you recommend what can I do if I need opposite to what your requirement is ?
    I need my camera (which is in the top level scene and is persistent object) to render sky-boxes from the scenes that I am loading additively. My camera is showing sky-box from the first scene (The top level scene that I am loading only once) but I want it to load sky-boxes from each of the other new scene.
     
  8. phoenix0330

    phoenix0330

    Joined:
    Dec 4, 2010
    Posts:
    65
  9. Burkard

    Burkard

    Joined:
    Feb 22, 2014
    Posts:
    13
  10. BadumTsss

    BadumTsss

    Joined:
    Sep 14, 2019
    Posts:
    1
    I add component skybox to the camera. SOLVED for me.
     
  11. MarcSpraragen

    MarcSpraragen

    Joined:
    Jun 29, 2020
    Posts:
    8
    I had come to a similar conclusion and was looking here for backup before testing! So glad you had found that solution.
     
  12. florinel2102

    florinel2102

    Joined:
    May 21, 2019
    Posts:
    75
    Hello , for me worked the next line of codes (put in a script system)
    Code (CSharp):
    1. SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
    2.  
    3.     private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
    4.     {
    5.         if (SceneManager.GetActiveScene().name == "BASE")
    6.         {
    7.             RenderSettings.ambientIntesity = 0f;
    8.  
    9.             SceneManager.activeSceneChanged -= SceneManager_activeSceneChanged;
    10.         }
    11.     }