Forum begins after the advertisement:
[Part 7] SceneManager doesn’t exist error
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 7] SceneManager doesn’t exist error
- This topic has 2 replies, 2 voices, and was last updated 1 week, 3 days ago by
Terence.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
November 6, 2025 at 5:44 pm #19012::
Trying to do the save system and i keep getting an error that says “The name ‘SceneManager’ does not exist in the current context” for both the GameManager and bench scripts.
GameManager:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public string transitionedFromScene; public Vector2 platformingRespawnPoint; public Vector2 respawnPoint; [SerializeField] Bench bench; public GameObject faithstealer; public static GameManager Instance { get; private set; } private void Awake() { SaveData.Instance.Initialize(); if (Instance != null && Instance != this) { Destroy(gameObject); } else { Instance = this; } SaveScene(); DontDestroyOnLoad(gameObject); bench = FindObjectOfType<Bench>(); } public void SaveScene() { string currentSceneName = SceneManager.GetActiveScene().name; SaveData.Instance.sceneNames.Add(currentSceneName); } public void RespawnPlayer() { SaveData.Instance.LoadBench(); if (SaveData.Instance.benchSceneName != null) //load the bench's scene if it exists. { SceneManager.LoadScene(SaveData.Instance.benchSceneName); } if (SaveData.Instance.benchPos != null) //set the respawn point to the bench's position. { respawnPoint = SaveData.Instance.benchPos; } else { respawnPoint = platformingRespawnPoint; } PlayerController.Instance.transform.position = respawnPoint; StartCoroutine(UIManager.Instance.DeactivateDeathScreen()); PlayerController.Instance.Respawned(); } }bench:
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bench : MonoBehaviour { public bool interacted; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void OnTriggerStay2D(Collider2D _collision) { if (_collision.CompareTag("Player") && Input.GetButtonDown("Interact")) { interacted = true; SaveData.Instance.benchSceneName = SceneManager.GetActiveScene().name; SaveData.Instance.benchPos = new Vector2(gameObject.transform.position.x, gameObject.transform.position.y); SaveData.Instance.SaveBench(); } } private void OnTriggerExit2D(Collider2D _collision) { if (_collision.CompareTag("Player")) { interacted = false; } } }November 7, 2025 at 1:36 pm #19018November 7, 2025 at 2:05 pm #19019 -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Advertisement below: