异步加载的方法很多,这里我介绍一下我前段时间学到的一个异步加载方法,感觉挺好用,有兴趣的可以看看,下面就直接贴代码:
/// <summary>
/// Async to load.
/// Created By Hong Youwei
/// 2015.3.25
/// </summary>
using UnityEngine;
using System.Collections;
public class AsyncToLoad : MonoBehaviour {
public GameObject background; // 获取游戏背景
public GameObject loadingBar; // 进度条对象
UISlider slider; // 进度条脚本
UILabel lable_Percentage; // 显示进度的百分比的标签
// Use this for initialization
void Start () {
UISprite sprite = background.GetComponent<UISprite> ();
sprite.spriteName = GameInfo.loadSceneName;
LoadScene();
}
// 调用加载界面的加载协程
public void LoadScene() {
slider = loadingBar.GetComponent<UISlider>();
lable_Percentage = loadingBar.GetComponentInChildren<UILabel&g