脚本如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class CircleExpandImage : MonoBehaviour {
    public float timeSeconds = 5f;
    public float timeInterval = 0.05f;

    private Image image;
    private float duration;

    void Start()
    {
        gameObject.SetActive(false);
        image = GetComponent<Image>();
        image.type = Image.Type.Filled;
        image.fillAmount = 0f;
        image.fillOrigin = (int)Image.Origin90.TopRight;
        duration = 0;
    }

    public void begin()
    {
        gameObject.SetActive(true);
        StartCoroutine(DrawCircleImage());
    }

    IEnumerator DrawCircleImage()
    {
        Debug.Log(System.DateTime.Now);
        yield return new WaitForSeconds(timeInterval);
        while (duration < 1f)
        {
            duration += 1f / ((timeSeconds - 0.1f) / timeInterval) * 2;
            image.fillAmount = duration;
            yield return new WaitForSeconds(timeInterval);
        }
        Debug.Log(System.DateTime.Now);
    }
}

挂到image上,调用begin方法即可。

相关文章:

  • 2021-04-24
  • 2021-07-25
  • 2022-01-10
  • 2022-01-16
  • 2021-12-19
  • 2021-07-31
  • 2022-12-23
  • 2021-11-14
猜你喜欢
  • 2021-11-16
  • 2022-01-29
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案