- Home /
Question by
raj231 · Feb 09, 2015 at 08:14 AM ·
gameobjectassetbundleloadingprogress-bar
How to use loading text
I'm loading AssetBundle from server and the bundle size is large. So, i tried to use loading text for this. But the loading text is not working.
public GUIText loadingText;
IEnumerator GetAssetBundle(ImageTargetBehaviour itbModel ) {
while(!Caching.ready)
yield return null;
string bundleURL = AssetModelString;
Debug.Log (bundleURL);
using (WWW www = WWW .LoadFromCacheOrDownload(bundleURL, Version)) {
yield return www;
Debug.Log (Version);
if (www .error != null)
throw new UnityException("WWW Download had an error: " + www .error);
AssetBundle bundle = www .assetBundle;
if (AssetName == "") {
Debug.Log ("null");
mBundleInstance = Instantiate (bundle.mainAsset) as GameObject;
while (!mBundleInstance .isDone) {
loadingText.text = "Loading... " + (mBundleInstance .progress*100).ToString("f0") + "%";
yield return loadingText.text;
}
loadingText.enabled = false;
mBundleInstance.transform.localPosition = new Vector3(0.0f, 0.15f, 0.0f);
mBundleInstance.transform.gameObject.SetActive(true);
assetbundle_load_hide=true;
bundle.Unload(false);
}
else {
Debug.Log ("not null");
mBundleInstance = Instantiate(bundle.Load (AssetName)) as GameObject;
}
}
}
Comment
Where is the Loading text part in your script? Couldn't find it there, it's just the script for loading the assetbundle and instantiating.
You have set your loading text to show while your assetbundle is being instantiated not while it is downloaded.
You have set your loading text to show while your assetbundle is being instantiated not while it is downloaded.
Where should i rewrite the code? Can you please help me on this