Unity 异步加载场景的代码

 

public string _strSceneName;       //异步加载场景的名称

private AsyncOperation _async;    //异步操作的对象

private UISlider _uislider;               //进度条

 

void Awake( )

{

//uislider = GameObject.Find("Progress Bar").GetComponent<UISlider>();

}

 

void Start( )

{

    StartCoroutine(LoadSceneAsync(_strSceneName));//开启协同程序

}

 

void Update( )

{

    if ( !_async.isDone ) {

        //_uislider.sliderValue = _async.progress;

    }

}

//异步加载场景的方法

IEnumerator LoadSceneAsync( string>Application.LoadLevelAsync(scene);

 

    yield return _async;

}

 

你可能感兴趣的:(【Unity3D引擎】)