A Better Way to Use SpriteAtlas

How should I use SpriteAtlas to do the following?

Create a CharacterIconPrefab and display it on the screen like a grid list

CharacterIcon.prefab
Prefab Configuration
└RarityFrame(Image Object)
└CharacterIcon(Image Object)
└Element(Image Object)

CharacterIconAtlas.spriteatlas
└Rarity1~5.png
└Element1~10.png

CharacterIconSprites
└AddressableAsset

I set the Sprite to be set in Prefab from external information (Rarity, CharacterSpriteName, CharacterElementId).

How should we handle CharacterIconAtlas in this case?
1
Should we create a CharacterIcon.cs component, prepare a SerializeField for SpriteAtlas, and use the GetSprite function?
2
Should we create a function like “AtlasSprioteLoader” in Singleton so that it can be called from anywhere? (In that case, how do we release it?)
Do you have a better way?

Translated with DeepL.com (free version)

This seems like an unusual way to use SpriteAtlas. SpriteAtlas is generally used to optimize rendering by reducing draw calls; grouping sprites for selecting in code is not what they’re mostly designed for, and using GetSprite on an atlas will actually add some overhead (due to cloning the sprites and possibly creating extra garbage in memory).

I would recommend instead using SerializeField on a few arrays of Sprite. Insert the Sprites into the arrays in order of rarity/element index, so that you can use the number in code to get the right sprite.

Thank you for your reply!

I would recommend instead using SerializeField on a few arrays of Sprite. Insert the Sprites into the arrays in order of rarity/element index, so that you can use the number in code to get the right sprite.

I thought of such a method, but I wonder if I can’t take advantage of the functionality of SpriteAtlas.

The number of images is about 10, but does that mean I don’t need to be particular about SpriteAtlas?