Answer the question
In order to leave comments, you need to log in
Why doesn't the scene change after the build?
In the editor, everything works as it should, but in the build, even under Windows, even under Android, the scene does not change, but does not freeze, but continues to play
. The function code that changes the scene
[SerializeField] private Object[] _nextScenes;
private void OnOutOfProjectile()
{
PlayerPrefs.SetInt(ScorePref, _scoreView.Score);
int rand = Random.Range(0, _nextScenes.Length);
SceneManager.LoadScene(_nextScenes[rand].name);
}
Answer the question
In order to leave comments, you need to log in
Most likely, the scene objects are reset in the build (look at the logs or set Debug.Log(_nextScenes[rand]))
I didn't find how to attach the scene to the script.
Here are other options:
1) Load sequentially as you chose in BuildSettings:
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
[SerializeField] private string[] _nextScenes;
SceneManager.LoadScene(_nextScenes[rand]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question