Content Pipeline . Import Texture Atlas


Introduction

Currently, supported texture atlas formats are .json and .xml.

Json format sample

{
    "SubTexture": [
        {
            "y": 60,
            "height": 53,
            "x": 135,
            "name": "lowerbody",
            "width": 44
        },
        {
            "y": 0,
            "height": 99,
            "x": 0,
            "name": "upperbody",
            "width": 60
        }
    ],
    "imagePath": "Robot.png",
    "name": "Robot"
}

Xml format sample

<TextureAtlas name="Warrior" imagePath="Warrior.png">
  <SubTexture name="outerarm_upper" x="312" y="130" width="71" height="110"/>
  <SubTexture name="outerarm_lower" x="385" y="227" width="61" height="81"/>
</TextureAtlas>

Add texture atlas content to project

Just set Importer name to TextureAtlasImporter and Processor name to SpriteSheetProcessor, like below.

<Item Include="\Atlases\Warrior\Warrior.xml">
  <Name>Warrior</Name>
  <BuildAction>Compile</BuildAction>
  <Importer Name="TextureAtlasImporter" />
  <Processor Name="SpriteSheetProcessor">
    <TextureFormat>Compressed</TextureFormat>
  </Processor>
</Item>

Defaultly, TextureFormat is Color and to get best performance when rendering should be set to Compressed. You can create custom Importer library .dll to support other texture atlas format.