hi everyone,
I'm trying to load images from an assetbundles but when I load the texture in the scene the image appear broken, I post the link at the file that I used to see if the problem is caused from some picture settings:
http://dev.x-project.it/bundles/AssetsTest.zip
In the file in the resources folder you can find the original image that i use for create the bundles.
I'd like to know if the script that I use for export the bundles for the different device is correct, i post it below.
I cant load the bundle in the editor mode and i don't understand where is the mistake, you can find the script in the "app" gameobject, maybe is only a wrong path setting but i've tried all the possibilities and it doesn't works.
Another big problem is when i execute the "build and run" on Android device (Galaxy Tab 2) the application crashes immediately.
in most cases the application when start, immediately minimize in the task bar so i have to reopen it again, sometimes more than one time before it works.
On WebPlayer everything works fine.
Any suggestion?
Thanks in advance
using UnityEngine;
using System.Collections;
public class ExampleLoadingBundle : MonoBehaviour {
public GUIText label;
public GUIText urlLabel;
public GUITexture pic;
public string url; // URL AssetBundle
public int version = 1; // AssetBundle version
public string assetName; // Name of the Asset to be loaded from the AssetBundle
public string assetPath; // Path to the Asset in the Project folder
Object ObjInstance; // Instance of the object
string deviceFolder;
GameObject obj;
Texture2D texture;
GameObject objects;
void Awake(){
#if UNITY_WEBPLAYER
deviceFolder = "webplayer";
#endif
#if UNITY_ANDROID
deviceFolder = "android";
#endif
url = "http://dev.x-project.it/bundles/" + deviceFolder + "/compositions2.unity3d";
urlLabel.text = url;
assetPath = "Assets/Resources/" + deviceFolder + "/compositions.unity3d";
}
void Start(){
StartCoroutine(Download());
}
IEnumerator Download () {
AssetBundleLoader assetBundleLoader = new AssetBundleLoader ();
yield return StartCoroutine(assetBundleLoader.LoadBundle (url, version, assetName, assetPath));
if (assetBundleLoader.Obj != null) {
texture = Instantiate (assetBundleLoader.Obj) as Texture2D;
pic.texture = texture;
//pic.pixelInset.x
label.text = pic.name + " -- " + pic.pixelInset;
Debug.Log (label.text);
} else {
label.text = " Load failed!";
Debug.Log (label.text);
}
}
}
↧