There is 1 scene on it, a button that takes me to another scene, how to make a check on this button, so that if I already clicked on this button, then this scene did not load anymore, but the one on which I switched for the first time was loaded.
1 answer
You make a dummy scene on which you make a script in which you check:
string firstScene = "firstScene"; string nameScene = PlayerPrefs.GetString("SelectedSceneWhenFirstEnterInGame",string.Empty); SceneManager.LoadScene( nameScene == string.Empty?firstScene: nameScene, LoadSceneMode.Single); It is best to save the name of the scene, because it is easier to keep track of the name than the index (added the scene and the order of the indexes has shifted).
On the firstscene when you press the button you do:
PlayerPrefs.SetString("SelectedSceneWhenFirstEnterInGame", selectedScene); SceneManager.LoadScene( selectedScene, LoadSceneMode.Single); where selectedScene is the name of the selected scene.
|
short sceneIdxin which, when clicked, change the index of the scene.sceneIdx = sceneIdx == 1 ? 0 : 1sceneIdx = sceneIdx == 1 ? 0 : 1.... and then load the scene with theLoadScene(sceneIdx)index ...... actually, if there are more than two scenes, then the condition of the problem is not to be fulfilled in principle - Alexey Shimansky