A recreated Sprite Atlas packing view comparing individual texture draw calls with single-batch atlas rendering.
A recreated Sprite Atlas packing view comparing individual texture draw calls with single-batch atlas rendering.

Texture swapping breaks sprite dynamic batching

Assigning separate PNG textures for character expressions (smile, shocked, tired) forces texture context switches on the GPU, breaking 2D draw call batching. Grouping textures into a single Sprite Atlas keeps batching intact across expression changes.

using UnityEngine;
using UnityEngine.U2D;

public class CharacterExpressionBinder : MonoBehaviour
{
    [SerializeField] private SpriteRenderer spriteRenderer;
    [SerializeField] private SpriteAtlas characterAtlas;

    public void ApplyExpression(string expressionName)
    {
        Sprite target = characterAtlas.GetSprite(expressionName);
        if (target != null)
            spriteRenderer.sprite = target;
    }
}

Sprite Atlas packing considerations

Create a Sprite Atlas via Assets > Create > 2D > Sprite Atlas and add your character art directory to Objects for Packing. Disable Tight Packing for character portrait sequences to prevent subtle polygon vertex jitter during rapid emotion changes.

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine.U2D;

public static class AtlasPackUtility
{
    [MenuItem("Tools/Atlas/Force Pack All")]
    public static void PackAll()
    {
        SpriteAtlasUtility.PackAllAtlases(EditorUserBuildSettings.activeBuildTarget);
    }
}
#endif

Cache GetSprite instances

SpriteAtlas.GetSprite() instantiates a clone of the sprite object each time it is called. Cache sprites in a dictionary during initialization rather than calling GetSprite inside continuous update loops.

Verification scope

Official documentation review

Verified

Reviewed the article's code and procedure against official Unity documentation and marked it ready for publication. This is not a claim of an independent Unity project or device reproduction; version- or device-specific reports will be checked in that environment as follow-up.

Official documentation checkedUnity Sprite Atlas manual ↗