csLightIntancityControl.cs 408 B

123456789101112131415161718192021222324
  1. using UnityEngine;
  2. using System.Collections;
  3. public class csLightIntancityControl : MonoBehaviour {
  4. public Light _light;
  5. float _time = 0;
  6. public float Delay = 0.5f;
  7. public float Down = 1;
  8. void Update ()
  9. {
  10. _time += Time.deltaTime;
  11. if(_time > Delay)
  12. {
  13. if(_light.intensity > 0)
  14. _light.intensity -= Time.deltaTime*Down;
  15. if(_light.intensity <= 0)
  16. _light.intensity = 0;
  17. }
  18. }
  19. }