Hello. Im new to Unity and have spent the last few days getting to know it a bit.
I have a question regarding downloading and storing textures.
Basically, what i need is this:
I am making a game who uses alot of textures and i would like to NOT have to add all the textures to the game from the start (i.e. compile them along with the rest of the game).
Rather, i want the textures to be downloaded from a server when they are needed. This was easily achieved by using the following code:
void createObj(string texture)
{
Transform obj = (Transform)Instantiate(cardPrefab, new Vector3(0,0,0), Quaternion.identity);
WWW www = new WWW(texture);
StartCoroutine(WaitForRequest(www, card));
}
IEnumerator WaitForRequest(WWW www, Transform obj)
{
yield return www;
if (www.error == null)
{
Texture2D planeTexture = www.texture;
obj.renderer.material.mainTexture = planeTexture;
}
else
{
Debug.Log("ERROR LOADING EXTERNAL IMAGE");
}
}
My problem is that i would like these textures to be stored on the computer/telephone once they have been downloaded once so that the user do not have to download them again the next time he plays the game. So is there a way to make sure the images are forever cached once they are downloaded? Or can i manually download them to a specific folder on the users computer/iphone/android before using them?
I would like the game to run on iPhones/Android/PC/Mac.
I appriciate all input and help.
//Unit