- Home /
What is the best way to persist www downloaded graphics?
While this question is probably not Unity specific ...
In my game I would like use www class to import texture2D. After they are downloaded and in use what is the suggested method to cache/persist these graphics for future use.
Is sqlite overkill?
iByte
Based on SpikeX question below I have added the following information:
My game will ship with a specific set of graphics. I want these graphics to be updateble over the web (the amount of space required would not change). When the player closes the game I don't want the new graphics to turn into dispersed electrons. I want the graphics to be reloaded into the game (locally) when it starts up again. It would be okay if the original graphics were overwritten if there was a way to do that. If not then I am assuming I need some kind of file storage file or simple blob like database to keep them in. I would hope to support any type of Unity deployment target with whatever solution was used.
"In my game I would like use www class to import texture2D."
Could you be a little more specific? Typically with games you just have an asset database that everything grabs from, and is packaged with your game. Unity also handles automatic strea$$anonymous$$g of web content using the web player if that's what you're trying to do.
Answer by Eric5h5 · Mar 18, 2010 at 12:01 AM
You can save downloaded textures with the usual System.IO functions, such as WriteAllBytes, plus the use of Application.DataPath. Note that this only works with standalones; you can't cache anything locally with webplayers, aside from 1MB of PlayerPrefs data. (Unless you get a special license from UT that allows caching in webplayers.)
Note that from Unity3.3 you can use Application.persistentDatapath. This works on all devices (except web); see http://www.previewlabs.com/file-io-in-unity3d/
Does this also work for mobile? Or do you just save that in PlayerPrefs