failed to save and load scene with build index (int)

Discussion and help for Easy Save 3
Post Reply
tori
Posts: 1
Joined: Tue Apr 26, 2022 9:19 pm

failed to save and load scene with build index (int)

Post by tori »

hi i trier use ES3.save
and ES3.Load
I just want my game remember the current scene
so using build index I tried to save an Int "mycurrentLVL"
and load it in start like this

public void Start()
{
MyCurrentLvl = ES3.Load("myInt", defaultValue);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + MyCurrentLvl);
}

and my game try to load the last scene each time (regardless of the number of scene ) and try to load one more scene that dont exist (if I have 6 it will load 6 and try load 7 )

I hope be helped :/
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: failed to save and load scene with build index (int)

Post by Joel »

Hi there,

There is an error in your code unrelated to Easy Save.

You seem to be trying to append the loaded build index onto the current build index when you should only be providing the loaded build index as a parameter to the SceneManager.LoadScene method.

I also strongly recommend against using the scene index and use the scene name instead, as the scene index can change if you remove or move scenes in your build settings.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply