Search code examples
c#unity-game-enginecycle

How to change the exposure of a skybox at runtime in Unity?


I have a skybox in Unity with a day/night cycle. Currently the sun changes intensity and color as the day or night progress. But I want the skybox's exposure and atmosphere thickness to change as well but I can't seem to be able to access them from my script. I tried the logical thing which was the following:

if(isNight()){
    RenderSettings.skybox.exposure -= 0.05f;
}else{
    RenderSettings.skybox.exposure += 0.05f;
}

However exposure doesn't exist, nor does atmosphere thickness. I tried accessing the skybox directly from the inspector too but no luck there. Could someone show me how to access these thing in c#?

Thanks in advance!


Solution

  • Try this

    RenderSettings.skybox.SetFloat("_Exposure", Mathf.Sin(Time.time * Mathf.Deg2Rad * 100) + 1);