- Home /
Unity 5 Asset Bundles with uGUI
Hi all,
Our team works on complex mobile game with a lot of UI. We decided to use Asset Bundles system to divide SD (for small resolution) and HD version (for high resolution). Our main goal is huge memory optization on low-end devices like iPad mini 1/2, iPad 2 etc.
As you know uGUI system works with sprites. We pack all sprites in atlases with sprite packer. We store our UI screens as prefabs and pack them with asset bundles.
We have three main bundles for UI:
Main Menu UI - UI prefabs (screens, popups), sprite atlases - used only in main menu;
In-game UI - UI prefabs (screens, popups), sprite atlases - used only in gameplay;
Common UI - UI prefabs (screens, popups, panels), sprite atlases (fonts, buttons, backs) - used in whole game;
Each bundle stores their own atlases and prefabs. But we also have many prefabs from 1st bundle which uses atlases (sprites) from 3rd bundle. When we instantiated this kind of prefabs, atlases from 3rd bundle duplicate in memory again and again without reusing. I think it's very strange behaviour. And it's not documentated anywhere.
The main question is how to use bundles with cross-dependecies without memory leak? How to enable reusing of already loaded resources (in our case - atlases) from specific bundles?
Answer by jbooth · Aug 04, 2015 at 04:52 AM
You need to have all dependent (shared) assets in their own asset bundles, such that a dependency is created between your top level bundles and the assets they share.
Your answer
![](https://koobas.hobune.stream/wayback/20220613195605im_/https://answers.unity.com/themes/thub/images/avi.jpg)