Search Unity

Generating SpriteAtlas through editor scripting

Discussion in '2D' started by DigitalGlass, Mar 16, 2018.

  1. DigitalGlass

    DigitalGlass

    Joined:
    May 12, 2009
    Posts:
    88
    I'm having trouble figuring out how I can generate a spriteatlas through editor scripting. I have a set of images that I'm fetching through www, and I want to pack them into a sprite atlas automatically.

    The Sprite Atlas api doesn't have any way of adding sprites exposed. I tried using reflection and grabbed from SpriteAtlasExtension and trigger the add method from there. That just ends up crashing Unity. Am I missing something obvious? This is very important to automating our pipeline, we have external tools that our content creators use to upload images/configure them.
     
  2. furroy

    furroy

    Joined:
    Feb 24, 2017
    Posts:
    93
    I don't believe there is a run time API, it's been requested before. However, there is an API for when importing assets in that you can hook into. Texture Packer uses such a thing to import sprite atlas into Unity. This plugin is free in Asset Store (but not tool itself) you can poke through their code to see how they do it.
     
  3. DigitalGlass

    DigitalGlass

    Joined:
    May 12, 2009
    Posts:
    88
    thanks. I'll look into it. I won't be needing a runtime api for this, if I can do it through the importing phase, that would be great