Hello.
The project I am working on would use a web server to download all the textures, so I used the WWW class to download the textures and then compress them using the following piece of codes
public override IEnumerator InitFromWeb (GamePrefs gamePrefs, WWW www, byte[] rawData, Dictionary headers)
{
var filepath = gamePrefs.TexturesWebDirectoryUrl + Name + Extension;
Debug.Log("Loaded Resource: " + Name + ": " + filepath);
www = new WWW(filepath, rawData, headers);
yield return www;
Texture = www.texture;
Texture.Compress(false);
}
To save loading time, I want to be able to download the textures ONLY once when the player runs the game for the very first time, and then save them to a place in memory, preferably Application.persistentDataPath since the game would run on Android and iOS.
How would I go about doing that ?? The solution that I have is to use the proposed solution [here][1] to serialize the textures to a binary file and store it in Application.persistentDataPath, and then simply deserialize it every time the player enters the game, but wouldn't that store all the texture as PNG files ?? and how would I load it back ??
Appreciated.
[1]: http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html
↧