using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class ChangeScene : MonoBehaviour { [Scene] public string scene; public SceneActionType sceneAction; public LoadSceneMode loadSceneMode; public enum SceneActionType { Load, Unload } public void LoadScene() { if (sceneAction == SceneActionType.Load) { SceneManager.LoadScene(scene, loadSceneMode); } else if (sceneAction == SceneActionType.Unload) { for (int i = 0; i < SceneManager.sceneCount; i++) { var scene = SceneManager.GetSceneAt(i); if (scene.name == this.scene) { SceneManager.UnloadSceneAsync(scene); } } } } }