unity using scenemanager code example
Example 1: scene manager unity
using UnityEngine;
using UnityEngine.SceneManagement;
public class ExampleScript: MonoBehaviour
{
public string Scene;
void Start()
{
SceneManager.LoadScene(Scene);
}
}
Example 2: unity scenemanager loadscene
using UnityEngine;
using UnityEngine.SceneManagement;
public class ExampleClass : MonoBehaviour
{
void Start()
{
SceneManager.LoadScene("OtherSceneName", LoadSceneMode.Additive);
}
}
Example 3: c# scene manager
using UnityEngine;
using UnityEngine.SceneManagement;public class GetActiveSceneExample : MonoBehaviour
{
void Start()
{
Scene scene = SceneManager.GetActiveScene();
Debug.Log("Active Scene is '" + scene.name + "'.");
}
}