HeatWaveAnimation.cs 946 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using UnityEngine;
  3. namespace Distort
  4. {
  5. public class HeatWaveAnimation : MonoBehaviour
  6. {
  7. private void Awake()
  8. {
  9. this.renderer = base.GetComponent<Renderer>();
  10. }
  11. private void OnEnable()
  12. {
  13. this.time = Time.time;
  14. }
  15. private void Update()
  16. {
  17. float num;
  18. if (this.loop)
  19. {
  20. num = Mathf.PingPong((Time.time - this.time) / this.animTime, 1f);
  21. }
  22. else
  23. {
  24. num = Mathf.Clamp((Time.time - this.time) / this.animTime, 0f, 1f);
  25. }
  26. float num2 = this.curve.Evaluate(num);
  27. base.transform.localScale = Vector3.one * this.maxsize * num2;
  28. this.renderer.material.SetFloat("_StrengthX", (1f - num2) * 0.4f);
  29. this.renderer.material.SetFloat("_StrengthY", (1f - num2) * 0.4f);
  30. }
  31. public float maxsize = 10f;
  32. public AnimationCurve curve;
  33. public float animTime;
  34. private float time;
  35. public bool loop;
  36. private Renderer renderer;
  37. }
  38. }