void LateUpdate()
        {
            timer = GetComponent<Timer>();

            bool state = HeadlightsStateByTimeOfDay(timer.TimeOfDay);
            if (state != headlightsState)
            {
                if (state)
                {
                    FadeInHeadlights();
                }
                else
                {
                    FadeOutHeadlights();
                }

                headlightsState = state;
            }

            if (fadingInHeadlights)
            {
                fadingHeadlightsFactor += Time.deltaTime;
                if (fadingHeadlightsFactor >= 1.0f)
                {
                    fadingHeadlightsFactor = 1.0f;
                    fadingInHeadlights = false;
                }
            }
            else if (fadingOutHeadlights)
            {
                fadingHeadlightsFactor -= Time.deltaTime;
                if (fadingHeadlightsFactor <= 0.0f)
                {
                    fadingHeadlightsFactor = 0.0f;
                    fadingOutHeadlights = false;
                    RemoveAllHeadlights();
                }
            }

            if (fadingInHeadlights || fadingOutHeadlights || headlightsState)
            {
                try
                {
                    UpdateAllHeadlights();
                }
                catch (Exception ex)
                {
                    Log.Error("Exception: " + ex.Message);
                }
            }
        }
 void Awake()
 {
     name = "debug:ToggleUI:Daybreak debug";
     timer = GetComponent<Timer>();
 }
        void Update()
        {
            if (timer == null)
            {
                timer = GetComponent<Timer>();
            }

            if (light == null)
            {
                var lights = FindObjectsOfType<Light>();
                foreach (var _light in lights)
                {
                    if (_light.type == LightType.Directional)
                    {
                        light = _light;
                        break;
                    }
                }
            }

            if (renderProperties == null)
            {
                renderProperties = FindObjectOfType<RenderProperties>();
            }

            RenderSettings.ambientMode = AmbientMode.Flat;
            RenderSettings.ambientIntensity = GlobalAmbientIntensity;
            RenderSettings.ambientGroundColor = GetAmbientColorByTimeOfDay(timer.TimeOfDay, timer.T);
            RenderSettings.ambientLight = Color.black;
            RenderSettings.ambientSkyColor = GetAmbientColorByTimeOfDay(timer.TimeOfDay, timer.T);
            RenderSettings.customReflection = null;

            renderProperties.m_ambientLight = RenderSettings.ambientSkyColor;
            renderProperties.m_fogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T);
            renderProperties.m_volumeFogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T);
              //  renderProperties.m_pollutionFogColor = GetFogColorByTimeOfDay(timer.TimeOfDay, timer.T);
            light.color = GetSunColorByTimeOfDay(timer.TimeOfDay, timer.T);
            renderProperties.m_inscatteringColor = light.color;

            light.intensity = GlobalSunIntensity;

            var sunDirection = GetSunDirectionByTimeOfDay(timer.TimeOfDay, timer.T);
            light.transform.rotation = Quaternion.LookRotation(sunDirection, Vector3.up);
        }
        void LateUpdate()
        {
            timer = timer ?? FindObjectOfType<Timer>();

            if (timer == null)
            {
                return;
            }

            bool state = BuildingLightsStateByTimeOfDay(timer.TimeOfDay);
            if (state != buildingLightsState)
            {
                if (state)
                {
                    FadeInBuildingLights();
                }
                else
                {
                    FadeOutBuildingLights();
                }

                buildingLightsState = state;
            }

            if (fadingInBuildingLights)
            {
                fadingBuildingLightsFactor += Time.deltaTime;
                if (fadingBuildingLightsFactor >= 1.0f)
                {
                    fadingBuildingLightsFactor = 1.0f;
                    fadingInBuildingLights = false;
                }
            }
            else if (fadingOutBuildingLights)
            {
                fadingBuildingLightsFactor -= Time.deltaTime;
                if (fadingBuildingLightsFactor <= 0.0f)
                {
                    fadingBuildingLightsFactor = 0.0f;
                    fadingOutBuildingLights = false;
                }
            }

            if (!buildingLightsState && !fadingInBuildingLights && !fadingOutBuildingLights)
            {
                return;
            }

            RenderBuildingsToTexture(rt, buildingWindowsReplacement);
        }