【发布时间】:2021-08-27 11:51:27
【问题描述】:
下面是我在 Unity (Asyn) 中加载下一个场景的代码。它工作正常。但是我需要它在加载后等待一秒钟才能显示场景。怎么做
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LoadingScreenScript : MonoBehaviour
{
[SerializeField]
private Image _progressBar;
// Start is called before the first frame update
void Start()
{
StartCoroutine(LoadAsyncOperatiom());
}
IEnumerator LoadAsyncOperatiom()
{
AsyncOperation gameLevel = SceneManager.LoadSceneAsync(2);
while (gameLevel.progress < 1)
{
_progressBar.fillAmount = gameLevel.progress;
yield return new WaitForEndOfFrame();
}
transition.SetTrigger("Start");
//yield return new WaitForSeconds(transitionTime);
}
}
【问题讨论】:
-
将
yield return new WaitForSeconds(transitionTime);移动上方transition.SetTrigger("Start");?
标签: unity3d asynchronous loading wait scene