So I have a day night cycle scripts that control the sun and skybox at different time of day. My issue is skybox is linked to each scene individually unlike the sun, so I can't manage it on a game master object with Don't Destroy Onload. Eg. at noon the skybox is supposed to change which does change but if you go to the next scene (where the change did not take place in) the skybox of the next scene is not going to respond to the change, so it will remain default skybox. Here is the part of the script that handles the sun and skybox change:
public void SunOut()
{
if (GameTimeManager.Time.Hour == 7)
{
if( GetDifference(GameTimeManager.Time, sunOutTime)== 7) //at 7:07AM sun comes out
{
GetComponent<Light>().intensity = 1.5f;
Debug.Log("Sun comes out");
RenderSettings.skybox = morningSkybox;
}
}
}
public void Noon()
{
if (GameTimeManager.Time.Hour == 12)
{
if (GetDifference(GameTimeManager.Time, noonTime ) == 1) //at 12:01
{
GetComponent<Light>().intensity = 2f;
RenderSettings.skybox = noonSkybox;
}
}
}