Hi, I’m goint totally insane about one of my scenes in my game.
I have 3 scenes: Menu, RpgScene and Battle. My problem is: when i load RpgScene from Menu, it is blazing fast, like 0,1 seconds on Windows and android platforms too. When i try to load it from Battle scene, it is absolutely fast in the editor and on Windows build too, but it takes random amount of time from android (usually from 10 seconds to 2minutes). The way i call the next scene is via a button, code is shown below. It looks to me (based on profiler and the manually created loading slider) that it absolutely does nothing for a random amount of time (cpu, memory kinda idles, slider is stuck at 0%) then it just loads it instantly. I tried to replace this problematic scene with an empty scene, same slow result. I got problem only if i try to load a scene from this scene. If i try the normal LoadScene instead of async version, it just freezes for a lot of time, then loads it.
What exactly happens when i call scenemanager’s loadscene? Is there any event that must finish before it actually starts loading? Its just a guess, i can’t imagine anything else, i got stuck by this problem for 2 days ![]()
Unity version 5.6.1f1 / android target 4.4
Any suggestions is really appreciated!
public void battleWonButton()
{
StopAllCoroutines();
StartCoroutine(AsynchronousLoad(“RpgScene”));
}
IEnumerator AsynchronousLoad(string scene)
{
yield return null;
loadingSlider.gameObject.SetActive(true);
AsyncOperation ao = SceneManager.LoadSceneAsync(scene);
ao.allowSceneActivation = false;
while (!ao.isDone)
{
float progress = Mathf.Clamp01(ao.progress / 0.9f);
loadingSlider.value = progress;
if (ao.progress == 0.9f)
{
if (Input.anyKey)
ao.allowSceneActivation = true;
}
yield return null;
}
}