I'm having trouble saving and loading a scene. I have this code:
public void LoadData(Data data)
{
this.sceneName = data.sceneName;
SceneManager.LoadScene(sceneName);
this.level = data.level;
}
public void SaveData(ref Data data)
{
data.sceneName = SceneManager.GetActiveScene().name;
data.level = this.level;
}
and when I have a line in my code that contains "SceneManager.LoadScene(sceneName);" is the player's level, which he writes at the beginning of the code as follows `public int level = 1; public int health = 100; I'm signing up incorrectly. The Player level object changes, but when I want to get it using player.level; it shows me level "1" even though it is equal to 2
All I know is that the problem occurs by loading the scene. When I remove the line
SceneManager.LoadScene(sceneName);
level updates normally