Search Unity

Bug Problem with lighting when launching SceneManager.LoadSceneAsync.

Discussion in 'Scripting' started by fdojruiz, Nov 23, 2022.

  1. fdojruiz

    fdojruiz

    Joined:
    May 9, 2022
    Posts:
    8
    Hello.
    I have a problem with lighting. I have two scenes, and when I want to go to the next one I use this method.

    Code (CSharp):
    1.     IEnumerator LoadingScene(string nameScene)
    2.     {
    3.      
    4.         pnlScreenLoading.SetActive(true);
    5.         AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(nameScene, LoadSceneMode.Single);
    6.  
    7.         while (!asyncOperation.isDone)
    8.         {
    9.             float progress = Mathf.Clamp01(asyncOperation.progress / .9f);
    10.             barLoading.fillAmount = progress;
    11.             yield return null;
    12.         }
    13.     }
    What this method does is display a loading screen while asynchronously starting to load the next scene. This works fine.
    The problem is that when loading the next scene everything appears very dark, as if the intensity of the ambient light had been lowered. Attached image of the ambient light values of both scenes at runtime.

    This problem only occurs when moving from one scene to another, if I launch a scene individually the lights look correct.

    I have no idea why the lights are dimming, I hope you can help me.

    Thanks.
     

    Attached Files:

  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,726
    fdojruiz likes this.
  3. fdojruiz

    fdojruiz

    Joined:
    May 9, 2022
    Posts:
    8