- Home /
How to Load all textures with WWW class? But not with Assets Bundles
Hello Everyone ,
My question is how to download all textures from the web using WWW class. The reason for not using asset bundles is that, I don't want to recreate asset bundle again and again and upload it to the server after including something(Please correct me about the asset bundles if my concept is not clear about it). I can download one texture using
WWW.texture;
But what if I've to download all the textures from the web and load it once in the game. And after that I can use them. Here is a code snippet ,
IEnumerator Start ()
{
BundleURL = "file://" + Application.dataPath + "/Mydata/tracker-2.jpg";
WWW www = new WWW(BundleURL);
yield return www;
Debug.Log(www.texture.name);
gameObject.renderer.material.mainTexture = www.texture;
}
Now Currently, for the sake of testing I'm getting texture from the disk. Later on I'd be accessing it from the server on the web. Just to clarify the purpose my goal is to create a small engine in which I only have to upload texture to the web and update the information xml file retrieving that from web too (I'll be using WWW class to download xml file too). Later on, I can use these textures in my game.
I'll appreciate any help regarding this. Thank you so much guys in advance
I'm not really sure what you're asking, as you seem to be on the right track. You just download the xml, and then in a loop of sorts download each texture one by one as you've been doing. I don't think there's a way to do this in bulk.
If the question is about storing them afterwards, you could just make a Texture$$anonymous$$anager class or something, where you store all textures in an array after you download them and use them later on as many times as needed.
Thank you so much Oana for replying. I guess I'm not sure how to retrieve all the textures in an array. I don't see any method in WWW class that does the job of returning an array. I'm sorry but I'm noob in program$$anonymous$$g.
Answer by gjf · Jun 28, 2014 at 11:05 AM
look at this to read the texture.
Actually this line written gameObject.renderer.material.mainTexture = www.texture; is just for testing purpose. $$anonymous$$y real concern is how to download all the textures at once. Is there any method in WWW class or any algorithm by which I can get all the textures in an array or something. Thank you any way
there is no 'at once'.
if you've got a list/array of the filenames then iterating thru to load/assign textures is easy.
where do you plan on getting the list of files?
i suspect that your answer is from a web page. if so, you'll need to parse the page source... read it into a string and apply some regex to extract the filenames, fix the path names, then load away...
Your answer
Follow this Question
Related Questions
AssetBundle.mainAsset 2 Answers
How to use same material? 0 Answers
AssetBundle.Unload(false) 2 Answers
what is the faile reason? the model's or my codes'? 0 Answers
how to delete specific files from cache? 3 Answers