Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // From http://blogs.floriancavallo.fr/post/2012/07/28/Unity-Ajout-dynamique-delements-Partie-II-Telechargement-et-affichage.aspx
- void Start()
- {
- string url = "http://server.com/scene.unity3d";
- StartCoroutine(StartDownloadScene(url));
- }
- void OnGUI()
- {
- if (progress != 100)
- {
- GUILayout.Label(progress + "%");
- GUI.BeginGroup(new Rect(pos.x, pos.y, progress, size.y));
- // Define progress bar texture within customStyle under Normal > Background
- GUI.Box(new Rect(0, 0, size.x, size.y), "", customStyle);
- // Always match BeginGroup calls with an EndGroup call
- GUI.EndGroup();
- }
- }
- IEnumerator StartDownloadScene(string url)
- {
- WWW download = new WWW(url);
- while (!download.isDone)
- {
- //Ici on gère la barre de progression
- progress = System.Convert.ToInt32(download.progress * 100);
- //On attend sagement la fin du téléchargement
- yield return null;
- }
- //On charge la scène ainsi téléchargée.
- Application.LoadLevelAdditive("Ma scene");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement