Asynchronous loading
Think of some of the games we played, there will be a basic interface to load - because of the larger game scene data, so you need to load a short time. Why do some of the 2D game interface will have to load it? It stands to reason 2D game scene will be very small, this is the time to make the game run on low-end devices have a better experience.
When we develop some 3D games, under normal circumstances when jumping scene to be loaded scene resources in advance. I say the following by way of example asynchronous loading.
1. First, create two scenarios. Create a progress bar (the Slider) In the first scenario, create a three-dimensional object in the second scenario.
2. Then create a script, mounted on the progress bar (Slider) newly created.
3. Next, then look at the code.
// other header files leaving the using UnityEngine.UI; // include headers public class Loading_scene : MonoBehaviour { Private Slider Slider; // progress bar Private AsyncOperation asyncOperation; public Text Pecentage_Text; // display the progress of the text void Awake() { // The slider assembly itself object attributes to Slider slider = gameObject.GetComponent <Slider> (); } private void Start() { StartCoroutine ( " loadScene " , scene_name); // open coroutine } LoadScene the IEnumerator ( String scene_name) // load the scene by coroutine { asyncOperation = SceneManager.LoadSceneAsync (scene_name); // asynchronous scene jump to scene_name asyncOperation.allowSceneActivation = to false ; // When the game scene can be loaded to 90%, it does not jump directly to the game scene. yield return asyncOperation; } void Update() { if (asyncOperation == null) { return; } int progressVaule = 0; if (asyncOperation.progress < 0.9f) { progressVaule = (int)asyncOperation.progress * 100; } else { progressVaule = 1000; } if (curProgressVaule < progressVaule) { curProgressVaule+=2; } Pecentage_Text.text = curProgressVaule /10+ "%"; Slider .value = curProgressVaule / 1000f; if (curProgressVaule == 1000) { asyncOperation.allowSceneActivation = true; } } }