using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class LightManager : MonoBehaviour { public GameObject directLight; public static DateTime time; private const float one_day_seconds = 86400f; private const float offset = 0.0f; // Start is called before the first frame update void Start() { time = DateTime.Now; } // Update is called once per frame void Update() { DateTime start_of_today = new DateTime(time.Year, time.Month, time.Day); TimeSpan timeSpan = time - start_of_today; float total_seconds = (float)timeSpan.TotalSeconds; float x = (total_seconds - 21600) *180 / 43200 - offset; if (x > 180) x = 180; if (x < 0) x = 0; directLight.transform.rotation = Quaternion.Euler(x,72,0); if (x > 90) x = 180 - x; directLight.GetComponent().intensity = x / 90; } }