Hi,
I have two scenes:
- A small loading scene with a background image and a progress slider
- A large game scene with many textures and gameobjects.
The loading scene has this script:
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LoadSceneAsync : MonoBehaviour
{
public Slider slider;
public int sceneIndex;
void Start()
{
// Use a coroutine to load the Scene in the background
StartCoroutine(LoadSceneAsyncMethod());
}
IEnumerator LoadSceneAsyncMethod()
{
// The Application loads the Scene in the background as the current Scene runs.
// This is particularly good for creating loading screens.
// You could also load the Scene by using sceneBuildIndex.
AsyncOperation AO = SceneManager.LoadSceneAsync(sceneIndex,LoadSceneMode.Additive);
AO.allowSceneActivation = false;
while(AO.progress < 0.9f)
{
slider.value = AO.progress;
yield return null;
}
AO.allowSceneActivation = true;
}
}
The problem is that the loading scene does not show until the 2nd scene is fully loaded.
I get a black screen for a long time, then the loading scene appears for a very short while and then the game starts.
Thanks.