Hi everyone,I use LoadAsset Functions to load my asset “sysm.jpg”,in unity editor work find,but it can’t work in android.this is my building AssetBundle code.
BuildPipeline.BuildAssetBundles ("Assets/AssetBundles", BuildAssetBundleOptions.None,BuildTarget.Android);
and this is my C# code.
IEnumerator DownloadANdCache (){
while (!Caching.ready)
yield return null;
Debug.Log (BundleURL);
using (www = WWW.LoadFromCacheOrDownload (BundleURL, version)) {
while (!www.isDone) {
Debug.Log(www.progress);
float jdt = www.progress*100;
loading_Text.GetComponent<UnityEngine.UI.Text> ().text = (jdt.ToString("f1") + "%");
loading_Jdt.GetComponent<UnityEngine.UI.Image>().fillAmount = www.progress;
yield return null;
}
//yield return www;
if (www.error != null) { //some error
throw new Exception ("error:" + www.error);
Application.Quit ();
}
AssetBundle bundle = www.assetBundle;
UnityEngine.Texture2D temp_cx = (bundle.LoadAsset ("sysm.jpg")) as UnityEngine.Texture2D;
L_Obj [0].GetComponent<UnityEngine.UI.Image> ().sprite = Sprite.Create(temp_cx,new Rect(0,0,temp_cx.width,temp_cx.height),new Vector2(0.5f,0.5f));
}
}
My English is not so good,i hope say it clearly. Thank you very much.