CircleFill.cs 477 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class CircleFill : MonoBehaviour
  6. {
  7. [SerializeField] Image image;
  8. [SerializeField] float fillTime = 3f;
  9. private void OnEnable()
  10. {
  11. image.fillAmount = 0;
  12. }
  13. private void Update()
  14. {
  15. if(fillTime != 0f)
  16. {
  17. float speed = 1f / fillTime;
  18. image.fillAmount += speed * Time.deltaTime;
  19. }
  20. }
  21. }