So I\'ve decided to split my game into separate scenes(main menu, gameover, etc.) And I\'m trying to use an if statement in my code to check if the current scene is \"gameov
You're getting an error here because SceneManager.GetActiveScene() returns an object of type SceneManager.Scene
, not a string. However, according to the documentation, this gives you access to the public Scene.name
, which is a string.
So the non-deprecated equivalent of:
if (Application.loadedLevelName == "gameover") {
// ...
}
Would be:
if (SceneManager.GetActiveScene().name == "gameover") {
// ...
}