【Unity】Get started quickly with Sprite Atlas

Sprite Atlas is a technology that packages multiple small images (sprites) into one large image. Its main purpose is to optimize the performance of your game or application and reduce memory footprint and rendering overhead.

  1. create:
    • Right click to create directly;
    • Drag the folder where the sprite is stored into
  2. use:
    • Get by elf name:
private SpriteAtlas _animalAtlas;
   
    public void Init()
    {
    
    
        _animalAtlas = Resources.Load<SpriteAtlas>(SpritePath.AtlasPath + SpritePath.AnimalAtlasPath);
    }

    public Sprite GetAnimalSpriteById(int id)
    {
    
    
        return _animalAtlas.GetSprite($"{
      
      id}");
    }```

Supongo que te gusta

Origin blog.csdn.net/Xz616/article/details/135444785
Recomendado
Clasificación