Sprite Groups
A Sprite Group is a group of Master Sprites that share atlases thereby saving memory and draw calls.
- Sprite Groups share atlases and materials reducing memory usage and draw calls.
- Sprite Groups are particularly useful for grouping static sprites. Static sprites have no animation and consist of a single frame. You can use static sprites for non-animated background elements, for example. You will almost always want to assign static sprites to groups as a static sprite outside a group would generate an atlas with only one frame wasting memory.
- Animated sprites also work well in groups, but some guidelines should be followed for best results (see note below).
- Master Sprites can be moved in, out, and into different groups at any time.
Creating Sprite Groups
See Using the Editor - Sprite Groups for information.
Moving Sprites In and Out of Sprite Groups
Master Sprites can be moved in and out of groups at will from Sprite Properties -> Sprite Group. Note that when moving a sprite to or from a group, atlases and materials will be rebuilt for both groups which can take some time depending on the number of sprites in each group.
Shared Group Properties
Sprite Groups have certain properties which are shared by all sprites within the group: Atlas Properties and Material Sets. When a sprite is in a group, these properties can no longer be set in the sprite, but must be set in the group instead. When a Sprite Group is first selected in the editor, the Sprite Group properties will be displayed. Using the Editor - Sprite Groups for usage information.
Note about draw calls:
If the frames in all the sprites in a group exceeds the atlas size, multiple atlases will be created to fit all the frames. This is the same way atlasing works in non-grouped sprites. But in a group, for maximum draw call efficiency, you should follow a couple of guidelines:
- Group static sprites with static sprites, and animated sprites with animated sprites. Grouping static sprites with animated sprites works, but if the animation has many frames, it may push some static sprites onto other atlas sheets causing the static sprites to not be able to batch their draw calls. For this reason, if you do mix static and animated sprites in a group, its best that you move the animated sprites to the bottom of the group so they will be atlased last after all the static sprites have been atlased onto as few sheets as possible.
- Group animated sprites with fewer frames together. Sprites with many frames, like a main character, should probably be standalone sprites (not grouped). This is a very loose suggestion because there may be some cases where you would want to group sprites with many frames, but it all depends on your max atlas size, sprite frame size, and number of frames.