HI.
I would like to know whether it’s possible to save textures loaded from paths.
My app have a function that load thousands of textures from paths than it takes a lot like few minutes.
Even I want to use textures again that totally the same as one previously loaded, I have to load them and wait till this process completes in every launching if I close my app and open it later.
Hopefully there’s a way to save these textures after it’s loaded once, than from the 2nd time just reuse them in runtime without that loading phase.
Thank you.
IEnumerator LoadTexturesFromPath( string[] _decodedImageFiles )
{
// _decodedImageFiles.Length is about 3000+
Texture2D[] texs = new Texture2D[ _decodedImageFiles.Length ];
// this loop costs about a few minutes
for (int i = 0; i < _decodedImageFiles.Length; ++i)
{
var path = _decodedImageFiles*;*
Texture2D tex = null;
using (var request = UnityWebRequestTexture.GetTexture(path, true))
{
yield return request.SendWebRequest();
tex = DownloadHandlerTexture.GetContent(request);
}
texs = tex;
}
// love to save this loadResult.
loadResult= texs ;
}
/////// want to do like this
Texture2D[] loadedTextures, loadResult;
bool loaded;
IEnumerator Start()
{
if(loaded)
{
// from the 2nd time
loadedTextures = GetLoadedTexture();
}
else
{
// only at the 1st time
yield return LoadTexturesFromPath();
loadedTextures = loadResult;
}
// use loadedTextures
// …
}