UP-Viagg-io/Viagg-io/Assets/Scripts/LoadScene.cs

26 lines
639 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadScene : MonoBehaviour
{
public LoadSceneMode loadSceneMode = LoadSceneMode.Single;
public void OnClickLoadScene(string sceneName)
{
StartCoroutine(LoadYourAsyncScene(sceneName));
}
IEnumerator LoadYourAsyncScene(string sceneName)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
}
}