unity-game-enginesavescene

Unity check if scene == gamescene?


I'm a bit new to Unity, so im asking for you guys help.

How can i check if the Scene == "gamescene"?

I tried something like this:

if(SceneManager.loadedScene == "gamescene") { do something }

I want to do an auto save only if the opened scene is the "gamescene".

But i haven't seen it working..


Solution

  • Your logic is right, but you should use SceneManager.GetActiveScene().name.