增长模式有两种,根据需要使用其中一种模式就行了。
public Slider[] progressBar;//所有的进度条
private float totalValue;//进度条Value总和
public float timeval;//时间间隔
private void Update()
{
UpdateProgressBar();
}
/// <summary>
/// 更新进度条
/// </summary>
private void UpdateProgressBar()
{
//按时间间隔来增长
//totalValue = totalValue >= progressBar.Length ? progressBar.Length : totalValue +=
// Time.deltaTime / timeval;
//平均增长
//float perSliderValue = progressBar.Length / 10f;
//totalValue += Time.deltaTime * perSliderValue;
//计算求得每个进度条的Value数值
int len = progressBar.Length;
for (int i = 0; i < len; i++)
{
progressBar[i].value = totalValue - i;
}
}
时间间隔增长效果图

平均增长效果图
