![](https://img.haomeiwen.com/i1889272/e41758be356f456f.png)
![](https://img.haomeiwen.com/i1889272/b63643547d374440.png)
![](file://C:%5CUsers%5Cyang%E3%80%81%5CDesktop%5CQQ%E5%9B%BE%E7%89%8720171007112643.png?lastModify=1507347401)
大圆1作为背景,就是灰色的那一部分
大圆2作为填充背景,蓝色的那一部分。为了实现填充效果,应该把其Type设置为fill,可以拖动FilledAmount观察填充再创建两个Text,一个作为进度数,一个作为说明(Loading Or Done)。
用代码实现控制
对BG附加脚本,这里用public只是方便在面板上调节
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MyprogressBar : MonoBehaviour
{
public Transform myProgress;
public Transform setText;
public Transform loadingText;
private float currentAmount = 0;
public float moveSpeed = 15;
// Update is called once per frame
void Update () {
if (currentAmount < 100)
{
currentAmount += moveSpeed*Time.deltaTime;
setText.GetComponent<Text>().text = ((int) currentAmount).ToString() + "%";
setText.gameObject.SetActive(true);
}
else
{
loadingText.GetComponent<Text>().text = "DONE!";
setText.gameObject.SetActive(false);
}
myProgress.GetComponent<Image>().fillAmount = currentAmount/100;
}
}
emm只是总结一下方便自己看
原教程来自B站:https://www.bilibili.com/video/av12036478/?t=237
网友评论