I have this script that when its 7-18(7am-6am) its day and the lights and skybox changes and when its 20-5(8pm-5am) the lights change and the skybox. The night time works but when it should be day, its just dawn/dusk skybox and lights, please help!
#pragma strict
var Day_SkyBox:Material;
var Night_SkyBox:Material;
var DawnDusk_SkyBox:Material;
public var Day :GameObject;
public var Night :GameObject;
public var DawnDusk :GameObject;
var dt = Date();
var timetext : GUIText;
function Update () {
var day = dt.Now.Day.ToString();
var month = dt.Now.Month.ToString();
var year = dt.Now.Year.ToString();
var hours = dt.Now.Hour.ToString();
var minutes = dt.Now.Minute.ToString();
if (parseInt(minutes) < 10) minutes = "0" + minutes;
var seconds = dt.Now.Second.ToString();
if(parseInt(seconds) < 10) seconds = "0" + seconds;
timetext.text = day + "/" + month + "/" + year + " " + hours + ":" + minutes + ":" + seconds;
{
//Day
if(parseInt(hours) > 6 && parseInt(hours) < 19)
{
Day.SetActive(true);
Night.SetActive(false);
DawnDusk.SetActive(false);
RenderSettings.skybox = Day_SkyBox;
}
//Night
if(parseInt(hours) > 19 && parseInt(hours) < 6)
{
Day.SetActive(false);
Night.SetActive(true);
DawnDusk.SetActive(false);
RenderSettings.skybox = Night_SkyBox;
} else {
//Dawn/Dusk
Day.SetActive(false);
Night.SetActive(false);
DawnDusk.SetActive(true);
RenderSettings.skybox = DawnDusk_SkyBox;
}
}
}