Ejemplo n.º 1
0
        void Update()
        {
            if (Camera.main == null)
            {
                return;
            }
            CameraCompositor compositor = Camera.main.GetComponent <CameraCompositor>();

            if (compositor == null || compositor.material == null)
            {
                return;
            }

            var now       = System.DateTime.Now;
            int timeClock = now.Hour * 3600 + now.Minute * 60 + now.Second;
            int timeFrags = this.timeCircle / (this.timeColors.Length - 1);
            int timeIndex = timeClock / timeFrags % (this.timeColors.Length - 1);
            int timePoint = timeClock % timeFrags;

            if (timeIndex == this.mLastTimeIndex && timePoint == this.mLastTimePoint)
            {
                return;
            }
            this.mLastTimeIndex = timeIndex;
            this.mLastTimePoint = timePoint;
            Color color = Color.Lerp(this.timeColors[timeIndex], this.timeColors[timeIndex + 1], (timePoint + 0.0f) / timeFrags);

            compositor.color = color;
        }
 void Start()
 {
     if (this.compositor == null && Camera.main != null)
     {
         this.compositor = Camera.main.GetComponent <CameraCompositor>();
     }
     if (this.compositor != null)
     {
         this.material = this.compositor.material;
         this.color    = this.compositor.color;
     }
 }