1
\$\begingroup\$

I have a mobile game but my build size is currently 4gb. Furthermore, it crashes on open and I suspect it has something to do with the huge build size.

In my project are 10 animations made of a series of images, each one using around 250-300 images. Each one is quite large as the animation takes up most of the screen so they are high resolution. What can I do to reduce the build size?

I have tried converting it into a video file and using the raw image component to display it as a movie texture, however, it seems unity doesn't support videos with alpha channels, and the alpha channel is critical to my animation.

I thought about combining them into a single image, but lets be real, if each image is more than 1080p, then combining 250 - 300 images into a single file will be massive.

So what can I do to reduce the size of the animations?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You'll have to look at atlasing, alpha trimming, packing algorithms, etc. It's a huge complicated problem. We had to deal with this exact issue on the job. But I left the project before we had our solution. \$\endgroup\$
    – Almo
    Aug 13, 2017 at 2:30

1 Answer 1

1
\$\begingroup\$

For starters, Unity has a page regarding reducing build size that I assume you've encountered before -- to my knowledge, its suggestions for reducing texture size are the only real useful and simple ones out there. The main build size reducer I've found that it doesn't directly mention is ensuring all textures are Power-of-Twos. I assume, however, that you've done this; it appears Unity 2017 by default now automatically converts textures to PoT formats, but more importantly your file size would be even bigger with that many animations. A simple test had a 2048x2048 file take 2.7MB of space, while the same file scaled to 2049x2049 takes a whopping 16MB! If this was your problem, with ~3000 images your filesize would likely be far higher than 4GB.

From a quick google search, this thread on the unity forums seems to suggest that imported videos do, in fact, support alpha channels when in the right codec. Unity also has section in the documentation confirming this. I've never actually used video clips in Unity so I can't offer much more advice in that department, but it seems as though that strategy should work -- the file size may still end up being quite large, however.

If you can't go the video route, in terms of actually fixing this issue, unfortunately, I don't believe there's much you can do if you need to keep every frame of animation and also maintain the same texture resolution. You could try reducing resolution in-unity with the Max Size option on the imported texture, or you could try cutting out any unnecessary frames of animation, and see how much those operations impact how the animation plays. Lastly, without knowing what the animations are, this advice may be useless, but you could hypothetically split the animations up into layers, with static backgrounds and much smaller animated sprites for the moving characters/objects, with their positions (and maybe even rotations and scale) adjusted with Unity's built-in animation system.

\$\endgroup\$
2
  • \$\begingroup\$ Am I right in saying that those 3000 images also have to be stored on the RAM when the game is playing? \$\endgroup\$
    – mr-matt
    Aug 13, 2017 at 2:59
  • \$\begingroup\$ Lastly, without knowing what the animations are, this advice may be useless, but you could hypothetically... I've also seen some videos on YouTube from a user called "GameHut" where he talks about how he / his team back in the day created very high quality animation or other effects on very low resource budgets. This one might be of particular interest to @MatthewInglis \$\endgroup\$ Jan 8, 2018 at 18:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .