Im having a little difficulty here with OnSceneLoad. it appears to be way harder to use than is necessary, unless i’m missing something, in the way i need to use it.
i’m trying something fairly simple here, that way i can make sure things fire properly, but the onsceneload method seems to take an argument that i can’t provide how i need it to, and that’s the scene name.
apparently, you can’t get the name of a scene unless it’s loaded, but i need the scene name of the upcoming scene, so i know when it loads lol.
let me give the simple example.
void Awake()
{
//do things like creating a prefab, assigning it's references, etc.
}
void Start()
{
DontDestroyOnLoad(this);
}
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//pretty sure i actually want all the stuff in Awake here, possibly the
//dont destroy part too
}
public void SceneForward()
{
sceneToLoad++;
if (sceneToLoad > 5) { sceneToLoad = 5; }
text.text = sceneToLoad.ToString();
SceneManager.LoadScene(sceneToLoad);
OnSceneLoaded(sceneToLoad, LoadSceneMode.Single);
}
public void SceneBack()
{
sceneToLoad--;
if (sceneToLoad < 0) { sceneToLoad = 0; }
text.text = sceneToLoad.ToString();
SceneManager.LoadScene(sceneToLoad);
OnSceneLoaded(sceneToLoad, LoadSceneMode.Single);
}
very simple way of moving back and forth in the build index. problem is, awake doesn’t fire on a new scene loading, even though the AI generated first answer in google says it does, which is interesting, considering everything else says it doesn’t. that means i need the onsceneload thing, but it takes a name instead of an index. can’t get the name until the scene is loaded, and i’m unsure if it will either fire where it is in those two methods or not, and can’t ge tthe name, so…
is there a way to use the index instead of the name that nothing has mentioned, or is there a simple way to get the name? or if i want to do it like this, do i have to rename all of my scenes to 0, 1, 2, 3, etc?