unity load scene
using UnityEngine.SceneManagement;
int buildIndex = 0;
//Load the scene with a build index
SceneManager.LoadScene(buildIndex);
unity load scene
using UnityEngine.SceneManagement;
int buildIndex = 0;
//Load the scene with a build index
SceneManager.LoadScene(buildIndex);
unity loadsceneasync callback
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Example : MonoBehaviour
{
void Update()
{
// Press the space key to start coroutine
if (Input.GetKeyDown(KeyCode.Space))
{
// Use a coroutine to load the Scene in the background
StartCoroutine(LoadYourAsyncScene());
}
}
IEnumerator LoadYourAsyncScene()
{
// The Application loads the Scene in the background as the current Scene runs.
// This is particularly good for creating loading screens.
// You could also load the Scene by using sceneBuildIndex. In this case Scene2 has
// a sceneBuildIndex of 1 as shown in Build Settings.
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("Scene2");
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us