Search Unity

buffer scene with LoadSceneAsync

Discussion in 'Scripting' started by PixelFireXY, Mar 3, 2012.

  1. PixelFireXY

    PixelFireXY

    Joined:
    Nov 2, 2011
    Posts:
    56
    Hi, i post this message cos i have a problem in LoadSceneAsync, in script reference write this:

    Description
    Loads the level asynchronously in the background

    i search a lot on internet how to load scene and 'wait to load' but i don't find anithing... this is my code:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class MainMenu : MonoBehaviour {
    5.     private AsyncOperation ao;
    6.    
    7.     void OnGUI() {
    8.         if(GUI.Button(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 15, 200, 30), "Load Level 1")) {
    9.             ao = Application.LoadLevelAsync(1);
    10.            
    11.         }
    12.         if(ao != null) {
    13.             GUI.Box(new Rect(0, Screen.height - 40, ao.progress * Screen.width, 40), "");
    14.            
    15.             Debug.Log(ao.progress);
    16.         }
    17.     }
    18. }
    what i want is, load scene and wait my commant to show, it's possible? Thank's a lot :D
    Or, Load in background, and call method when you press the button
     
  2. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    Is there a checkbox in the Unity editor to make scenes load asynchronously by default instead of having to do it programmatically?