Je suis entrain de réaliser une scène de transition qui permet de avant de passer au menu d'avoir une scène qui montrer le chargement du menu. Tout marche bien, cependant, la méthode qui permet de récupérer le pourcentage de chargement me retourne tout le temps 0, alors que cette methode devait s'incrémenter de 0 jusqu'à 1. Quelqu'un sait comment je pourrais corriger cela ?
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour {
public GameObject LoadingScene;
public Image LoadingBar;
public Text textPourcentage; //The text with the percentage increasing
public void LoadLevel (string nomScene) //The name of the scene
{
StartCoroutine (LevelCoroutine (nomScene));
}
IEnumerator LevelCoroutine (System.String nomScene)
{
LoadingScene.SetActive (true);
AsyncOperation async = SceneManager.LoadSceneAsync(nomScene);
while (!async.isDone) {
LoadingBar.fillAmount = async.progress ; //j'ai tout le temps 0 ici
Debug.Log(async.progress);
textPourcentage.text = LoadingBar.fillAmount + "%"; //I have always 0% because he fillAmount is always 0
yield return null;
}
}
}