SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
864 B

4 years ago
  1. using UnityEngine;
  2. using System.Collections;
  3. // Cartoon FX - (c) 2015 Jean Moreno
  4. // Randomly changes a light's intensity over time.
  5. [RequireComponent(typeof(Light))]
  6. public class CFX_LightFlicker : MonoBehaviour
  7. {
  8. // Loop flicker effect
  9. public bool loop;
  10. // Perlin scale: makes the flicker more or less smooth
  11. public float smoothFactor = 1f;
  12. /// Max intensity will be: baseIntensity + addIntensity
  13. public float addIntensity = 1.0f;
  14. private float minIntensity;
  15. private float maxIntensity;
  16. private float baseIntensity;
  17. void Awake()
  18. {
  19. baseIntensity = GetComponent<Light>().intensity;
  20. }
  21. void OnEnable()
  22. {
  23. minIntensity = baseIntensity;
  24. maxIntensity = minIntensity + addIntensity;
  25. }
  26. void Update ()
  27. {
  28. GetComponent<Light>().intensity = Mathf.Lerp(minIntensity, maxIntensity, Mathf.PerlinNoise(Time.time * smoothFactor, 0f));
  29. }
  30. }