samedi 29 mai 2021

Adding a level counter that isn't linked to buildindex unity and randomising levels

I'm trying to add a Level counter to my game that isn't based on buildindex but haven't been able to find a way to do it so far. That leads to my next question, I need the counter to work inpendantly of buildindex because I want the levels to be played in a random order (with replaying the same level possible). So far to randomise levels I've come up with this:

private void NextLevel()
{
  SceneManager.LoadScene(SceneManger.buildIndex + range(0,x)); //x would be the number of scenes
}

I haven't finished enough scenes to be able to test this yet to know if it works, if anyone knows a better way or would be able to confirm is this works or I should try come up with something else I would love to know!

Thank you for your time and any advice




Aucun commentaire:

Enregistrer un commentaire