{
[SerializeField] Gradient directionalLightGradient;
[SerializeField] Gradient ambientLightGradient;
[SerializeField, Range (1, 3600)] float timeDayInSecond = 60;
[SerializeField, Range(0f, 1f)] float timeProgress;
[SerializeField] Light dirLight;
Vector3 defaultAngles;
void Start ()
{
defaultAngles = dirLight.transform.localEulerAngles;
}
void Update ()
{
if (Application.isPlaying)
timeProgress += Time.deltaTime / timeDayInSecond;
if (timeProgress > 1f)
timeProgress = 0f;
dirLight.color = directionalLightGradient.Evaluate (timeProgress);
RenderSettings.ambientLight = ambientLightGradient.Evaluate (timeProgress);
dirLight.transform.localEulerAngles = new Vector3(x: 360f * timeProgress - 90, y: defaultAngles.y, defaultAngles.z);
}
}
https://www.youtube.com/watch?v=FvLtZYGe7TY&ab_channel=InsaneOne-%D0%A0%D0%B0%D0%B7%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%BA%D0%B0%D0%B8%D0%B3%D1%80
new Vector3(x: 360f * timeProgress - 90, y: defaultAngles.y, defaultAngles.z);
скрипт взят с видео