Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C# by StigC ( 6 years ago )
using UnityEngine.UI;
using TMPro;
using UnityEngine.SceneManagement;
public class LoadScreen : MonoBehaviour
{
public GameObject loadingCanvas;
public Slider loadingBar;
public Animator canvasAnim;
private void Awake()
{
//"Subscribe" To OnSceneLoaded, whatever that means
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (loadingCanvas.activeInHierarchy)
{
canvasAnim.SetTrigger("LoadingComplete");
}
}
public IEnumerator LoadLevelAsync(string levelToLoad)
{
loadingCanvas.SetActive(true);
loadingBar.value = 0;
canvasAnim.SetTrigger("LoadingStarted");
yield return new WaitForSeconds(1.5f);
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(levelToLoad);
while (!asyncLoad.isDone)
{
loadingBar.value = asyncLoad.progress;
yield return null;
}
}
}
Revise this Paste