bearhb

在游戏中,经常可以看到从一个关卡跳到另一个关卡时,有一个显眼的进度条,研究了下,其时也很简单:

public void LoadAScene()
{
    StartCoroutine(LoadSceneAsync("SampleScene"));
}

 

IEnumerator LoadSceneAsync(string sceneName)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName);
operation.allowSceneActivation = false;
while (!operation.isDone)
{
#if UNITY_EDITOR
Debug.Log("Progress is :" + operation.progress);
#endif
float progress = Mathf.Clamp01(operation.progress / 0.9f);
ProgressSlider.value = progress;
ProgressText.text = ((int)progress * 100).ToString() + "%";
yield return null;
}
operation.allowSceneActivation = true;

}

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-12-10
  • 2021-10-30
  • 2021-12-10
  • 2022-01-06
  • 2021-09-01
  • 2021-09-29
  • 2021-09-29
猜你喜欢
  • 2021-04-03
  • 2021-09-15
  • 2021-11-01
  • 2021-12-12
  • 2021-07-17
  • 2021-08-29
  • 2021-07-30
  • 2021-09-01
相关资源
相似解决方案