游戏一般启动时,会先加载资源,为了让玩家实时看到加载进度,需要弄个进度条显示当前加载进度。这里介绍GProgressBar组件。
带文本进度条
带动态标识物的
圆圈进度条
导出资源
代码实现
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
/*
* Author:W
* 进度条
*/
public class GProgressBarTest : MonoBehaviour {
private GComponent root;
/// <summary>
/// 带文本显示进度的
/// </summary>
private GProgressBar textProgressBar;
/// <summary>
/// 进度末尾带动态标识物的
/// </summary>
private GProgressBar aniProgressBar;
/// <summary>
/// 星星进度型
/// </summary>
private GProgressBar starProgressBar;
/// <summary>
/// 圆圈进度型
/// </summary>
private GProgressBar circleProgressBar;
void Awake()
{
UIPackage.AddPackage("UI/Basics");
}
// Use this for initialization
void Start () {
root = this.GetComponent<UIPanel>().ui;
textProgressBar = root.GetChild("n2").asProgress;
textProgressBar.value = 55;
Debug.Log("textProgressBar.value="+textProgressBar.value);
aniProgressBar = root.GetChild("n4").asProgress;
aniProgressBar.value = 65;
Debug.Log("aniProgressBar.value=" + aniProgressBar.value);
starProgressBar = root.GetChild("n7").asProgress;
starProgressBar.value = 75;
Debug.Log("starProgressBar.value=" + starProgressBar.value);
circleProgressBar = root.GetChild("n9").asProgress;
circleProgressBar.value = 95;
Debug.Log("circleProgressBar.value=" + circleProgressBar.value);
}
// Update is called once per frame
void Update () {
}
}
运行结果如下