3

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..

Kalip
  • 151
  • 1
  • 11

2 Answers2

2

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

Andrea
  • 6,032
  • 2
  • 28
  • 55
2

Your need to use SceneManager.GetActiveScene() then get the name of the scene from it.

if (SceneManager.GetActiveScene().name == "gamescene") {  }
Programmer
  • 121,791
  • 22
  • 236
  • 328