I tried to compare scene name but I am getting the error below:
error CS0019: Operatormethod group' and `string'==' cannot be applied to operands of type
void CheckCurrentLevel()
{
for(int i = 1; i < LevelAmount; i++)
{
---> if (SceneManager.LoadScene == "Level" + i) {
CurrentLevel = i;
SaveMyGame ();
}
}
}
SceneManager.LoadScene
is a void
function used to load a scene. It does not return anything so you can't compare it with a string.
It looks like you want to compare the current scene name
with "Level" + i
. If that's true then you are looking for SceneManager.GetActiveScene().name
void CheckCurrentLevel()
{
for (int i = 1; i < LevelAmount; i++)
{
if (SceneManager.GetActiveScene().name == "Level" + i)
{
CurrentLevel = i;
SaveMyGame();
}
}
}