A dynamic atlas solution for Unity.
The rectangle packing algorithm is based on GitHub - villekoskelaorg/RectanglePacking: Super fast AS3 implementation of rectangle packing algorithm with some extensions. Special thanks to @villekoskelaorg (Ville Koskela) · GitHub.
- Atlas texture compression
- Asynchronous resource loading
- Internal reference counting for atlas, automatically releases regions with zero references
- Large images automatically fallback to loose texture reference, with customizable threshold
- Supports custom resource loading methods
- OpenGL ES2.0 is not supported
- The texture compression format of loose textures and atlases must be consistent
- Loose textures cannot be static atlas members
You can quickly get a reference from the Init.cs script in the Demo scene.
-
Call the initialization method DynamicAtlasManager.Init in your external code to initialize various parameters required for the dynamic atlas. It is recommended to call it in your initialization logic, such as Awake().
-
Use the
DynamicImagecomponent instead of theUnityEngine.UI.Imagecomponent. You can directly mount images statically, or dynamically load images through theDynamicImage.SetDynamicSprite(string spriteName)method. -
Enjoy!