7.8 – Using loading indicators

Warning : Since loading levels asynchronously feature is only available at Unity Pro this feature will only work on Unity Pro and iGUI Full (Not basic).

You can show loading indicators when loading a level by using iGUIRoot’s loadLevel method instead of Application’s loadLevel method.

iGUIRoot.loadLevel("Level1");
iGUIRoot.loadLevel("Level1");

If you need more customization or want to use loading indicators for another operation than loading levels then iGUILoadingHelper is the way to go. You can easily show an indicator with iGUILoadingHelper.showLoading method and hide with hideLoading method. After a loading indicator is shown, you can modify its progress or layout with iGUILoadingHelper’s static variables progress or loadingHolder etc.

Let’s write our own scene loading method with the help of iGUILoadingHelper class.

public void button1_Click(iGUIButton caller){
    loadLevel("Level1");
}  

public void loadLevel(string name){
    iGUILoadingHelper.showLoading(iGUILoading.Both, 0.3f);         
    AsyncOperation async = Application.LoadLevelAsync(name);
    StartCoroutine(loadLevelAsync(async));
}
   
IEnumerator loadLevelAsync(AsyncOperation async){          
    while(!async.isDone){
        iGUILoadingHelper.progress = async.progress;   
        yield return null;
    }
    iGUILoadingHelper.hideLoading();
}
function button1_Click(caller : iGUIButton){
    loadLevel("Level1");
}

function loadLevel(name){
    iGUILoadingHelper.showLoading(iGUILoading.Both, 0.3f);         
    var async : AsyncOperation = Application.LoadLevelAsync(name);
    StartCoroutine(loadLevelAsync(async));
}

function loadLevelAsync(async : AsyncOperation){           
    while(!async.isDone){
        iGUILoadingHelper.progress = async.progress;   
        yield;
    }
    iGUILoadingHelper.hideLoading();
}