CoilPolarWipeController.cs 589 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CoilPolarWipeController : MonoBehaviour
  5. {
  6. public Material material;
  7. [Range(0f, 1f)]
  8. public float cutoff = 0f;
  9. public float speed = 0.5f;
  10. public bool loop = true;
  11. void Update()
  12. {
  13. if (material == null) return;
  14. cutoff += speed * Time.deltaTime;
  15. if (loop)
  16. cutoff = cutoff > 1f ? 0f : cutoff;
  17. else
  18. cutoff = Mathf.Clamp01(cutoff);
  19. material.SetFloat("_Cutoff", cutoff);
  20. }
  21. }