using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class PrettyLoadingScreen : MonoBehaviour { //Connections public GameObject loadingScreen; public Slider slider; public Text progressText; //Resources //[Header("Resources")] //Attributes //[Header("Attributes")] //Stats //[Header("Stats")] public void LoadingImages(int imagesIndex) { StartCoroutine(LoadAsynchronously(imagesIndex)); } IEnumerator LoadAsynchronously(int imagesIndex) { AsyncOperation operation = SceneManager.LoadSceneAsync(imagesIndex); loadingScreen.SetActive(true); while (!operation.isDone) { float progress = Mathf.Clamp01(operation.progress / 0.9f); slider.value = progress; progressText.text = "processing images . . ." + progress * 100f + "%"; yield return null; } } //Getter //Delegates //------------------------------------------------------------------------------------------------------------------ //awake protected void Awake() { } //------------------------------------------------------------------------------------------------------------------ //start protected void Start() { } //------------------------------------------------------------------------------------------------------------------ //setup public void SetUp() { } //------------------------------------------------------------------------------------------------------------------ //destroy //*********************************************************************************************************************** //update //*********************************************************************************************************************** //refresh //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //events //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //private, protected //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //internal //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public static //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //public //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ //*********************************************************************************************************************** //getter, setter //------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------ }