private void Awake() { multiobject = gameObject.GetComponent <MultiObjectImporter>(); if (progressSlider != null) { progressSlider.maxValue = 100f; progressSlider.gameObject.SetActive(false); } if (progressImage != null) { progressImage.gameObject.SetActive(false); } if (progressText != null) { progressText.gameObject.SetActive(false); } objImporter = GetComponent <ObjectImporter>(); // TODO: check and warn }
private void Update() { multiobject = gameObject.GetComponent <MultiObjectImporter>(); bool loading = Loader.totalProgress.singleProgress.Count > 0; if (!loading) { return; } //int numTotalImports = objImporter.NumImportRequests; parou de funcionar int numTotalImports = multiobject.cont; int numImportCompleted = numTotalImports - Loader.totalProgress.singleProgress.Count; if (loading) { //Debug.Log("numTotalImports = " + numTotalImports + "\n numImportCompleted = " + numImportCompleted); float progress; if (numTotalImports != 0) { progress = 100.0f * numImportCompleted / numTotalImports; } else { progress = 0; } float maxSubProgress = 0.0f; foreach (SingleLoadingProgress progr in Loader.totalProgress.singleProgress) { if (maxSubProgress < progr.percentage) { maxSubProgress = progr.percentage; } } progress += maxSubProgress / numTotalImports; if (progressSlider != null) { progressSlider.value = progress; progressSlider.gameObject.SetActive(loading); } if (progressImage != null) { progressImage.fillAmount = progress / 100f; progressImage.gameObject.SetActive(loading); } if (progressText != null) { if (loading) { progressText.gameObject.SetActive(loading); progressText.text = "Loading " + Loader.totalProgress.singleProgress.Count + " objects..."; string loadersText = ""; int count = 0; foreach (SingleLoadingProgress i in Loader.totalProgress.singleProgress) { if (count > 4) // maximum 4 messages { loadersText += "..."; break; } if (!string.IsNullOrEmpty(i.message)) { if (count > 0) { loadersText += "; "; } loadersText += i.message; count++; } } if (loadersText != "") { progressText.text += "\n" + loadersText; } } else { progressText.gameObject.SetActive(false); progressText.text = ""; } } } else { OnImportComplete(); } }