Embedding PNGs in an app to create a Texture2D on runtime in iOS

Hi,

I work on an app for kids that will require lots (500+) of high res (512x512 and above) sprites. The images are mostly lineart or clipart kind of images and they compress great to PNG (<25kb each in most cases) . All works like charm on Android but the iOS binary is a giant one. This is the result of my PNGs being converted. None of the compressed formats works for me.

What I look for is an option to create a Texture2D on the fly - I will only need to create a couple of them each time so the performance impact should be neglible.

Any ideas how to proceed?

Thanks in advance.

I think I have solved this with https://docs.unity3d.com/ScriptReference/Texture2D.LoadImage.html

Here is a short summary

  1. Save your PNGs as *.bytes (in Resources folder)
  2. Use TextAsset bytes Resources.Load("filename_without_bytes_extension) as TextAsset
  3. Create a dummy texture (e.g. Texture2d(1,1))
  4. Call this texture LoadImage method