1
\$\begingroup\$

I use spritepacker with assetbundle. It's working great. Its memory assumption is about just 8 MB. However, when I looked at the disk space that asset took on android phone, it took about 25MB. Which is 4 times from 8 MB. If I sum up all original sprites that have been used to create the atlas in spritepacker, they will be about 25MB as they are. Is there a way to exclude original sprites out of the bundle? It waste too much space in the device. I think only output atlas that generate from sprite would be enough to pack within the bundle.

I'm sure of it. I tested with 18 sprites and use the packer to generate 1024x2048 atlas. If I choose 2 sprites to make asset bundle, it used 5.76 MB disk space. If I choose 3 sprites to make asset bundle, it used 6.62MB. Its different is about 0.9MB which is the size of each sprite.

\$\endgroup\$
  • 1
    \$\begingroup\$ Are you sure that's the problem? I mean, when loading textures, they'll be stored as uncompressed RGB data in memory, maybe that 25MB you are seeing the size of your package uncompressed? to verify this, just multiply width by height by Bytes_Per_Pixel of the texture \$\endgroup\$ – Ali1S232 Jan 10 '15 at 9:12
  • \$\begingroup\$ the asset bundle is most likely LZMA compressed, when you load and unpack them, they will be bigger then the assetbundle \$\endgroup\$ – JeanLuc Jan 10 '15 at 11:39
  • \$\begingroup\$ I'm sure of it. I tested with 18 sprites and use the packer to generate 1024x2048 atlas. If I choose 2 sprites to make asset bundle, it used 5.76 MB space. If I choose 3 sprites to make asset bundle, it used 6.62MB. Its different is about 0.9MB which is the size of each sprite. \$\endgroup\$ – Paiboon Panusbordee Jan 13 '15 at 17:08
  • \$\begingroup\$ It's really unclear what kind of memory consumption you're talking about. GPU-Memory at runtime? Or size of the resulting APK file? You need to be more specific here. Also, you can't compare file-size with GPU-Memory consumption, because files will be unpacked into uncompressed RGB or RGBA. \$\endgroup\$ – bummzack Jan 15 '15 at 8:47
  • \$\begingroup\$ The runtime memory always 8MB even I use all 18 sprites from the atlas at this same time which is normal for atlas size 1024x2048 and I'm ok with that. However, for disk space on the phone, it lots more than that (the number I mentioned in second paragraph are all disk space.). If the concept of sprite packer is to build atlas and only \$\endgroup\$ – Paiboon Panusbordee Jan 16 '15 at 1:22
1
+50
\$\begingroup\$

You can use some sort of a hack:

  • Use AssetDatabase.LoadAllAssetsAtPath to load your resources
  • For sprites it will return an array with Texture2D and Sprite
  • Add only the Sprite to the list of resources you want to bundle
  • Do not use the CompleteAssets flag while building bundle with sprites

In this case only the generated atlas will be added to the bundle along with the sprites information required

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.