码迷,mamicode.com
首页 > 编程语言 > 详细

unity3d 资源进度读取

时间:2017-09-16 20:46:40      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:void   component   isl   gem   rtl   return   enum   load   UI   

using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class _03starLoad : MonoBehaviour {
    public GameObject LoadingBar;

    public string str;
    // Use this for initialization
    void Start () 
    {

        if (str != "")
        {
            StartCoroutine(StartLoading(str));
        }
    }
    //小场景载入
    IEnumerator StartLoading(string str)
    {
        float i=0;
        AsyncOperation acOp = SceneManager.LoadSceneAsync(str);
        acOp.allowSceneActivation = false;
        while(i<=100)
        {
            i++;
            LoadingBar.GetComponent<UISlider>().value = i/100;
            yield return new WaitForEndOfFrame();
        }
        acOp.allowSceneActivation = true;
    }

    /*大场景载入
     IEnumerator StartLoading(string str)
    {
      
        AsyncOperation acOp = SceneManager.LoadSceneAsync(str);
        acOp.allowSceneActivation = false;
        LoadingBar.GetComponent<UISlider>().value =acOp.progress;
        yield return acOp;
    }
     
    */
}

 

unity3d 资源进度读取

标签:void   component   isl   gem   rtl   return   enum   load   UI   

原文地址:http://www.cnblogs.com/lichuangblog/p/7532106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!