Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

TexturePacker + Importer - Spritesheet generator & Sprite mesh optimizer

Discussion in 'Assets and Asset Store' started by CodeAndWeb, Nov 13, 2015.

  1. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    TexturePacker helps you accomplish things that are hard to do with Unity alone:
    • Increase the performance of your game with optimized sprite meshes (Unity 5)
    • Easily manage & pack sprite sheets for you Unity project
    • Pack normal maps for 2d dynamic light effects
    Use the free TexturePacker Importer from Unity asset store to easily import the sprite sheets into Unity.

    Increasing the performance

    Unity creates triangle meshes for all sprites - but the generated meshes often have too many vertices and high overdraw.

    post-vertexcount.png

    Vertices are expensive - because the CPU is required to transform them. So reducing the number of vertices is important. A too low vertex count, on the other hand, is also bad because this hands much work over to the GPU.

    TexturePacker's high-quality polygon tracer creates meshes with a low vertex count and overdraw. The tracer tolerance slider gives you control over the optimization.

    post-optimizer.png

    Packing and managing Sprites

    TexturePacker comes with an easy to use UI that allows you to manage the sprite sheets. You see all changes applied to the sprite sheet in real time.

    The polygon packing mode generates tightly packed sprite sheets, reducing the memory amount compared to rectangular packing algorithms.

    screenshot.png

    The free TexturePacker Importer plugin for Unity automatically re-imports the data as soon as you re-enter Unity's editor.

    You can even hand off the sprite sheet creation to your artist. Just add the generated .png and .tpsheet file to your project.


    Packing normal maps

    If you want to use normal mapped sprites for dynamic light effects in your game, you have to create sprite sheets with the same layout for normal maps and diffuse maps. TexturePacker does this for you - with a single click.
     
    Last edited: Nov 13, 2015
  2. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    Hi, I recently tried your extension and it looks great! Thanks for your work. But I can't use the atlas in Unity.

    I'm trying to create an atlas for mesh objects to reduce draw calls. I followed the steps included in your extension(the free version's documentation pdf seems out of date, though) What should I choose, the json(.txt) or texture2d(.tpsheet)? Because the example contains .txt with json format but the tutorial says I should choose Unity3D(which one?)

    Also, I tried to import the atlas with Texture Packer Importer, but the extension seems not working. I tried the 'right click' on the project panel as you posted on the youtube tutorial, but there wasn't any drop down menu for texture packer. That means I can't add newly created atlases.
    I tried replacing the 'example.png' and 'example_data.txt' with my generated ones and it did work, but the texture UVs were not correct. So I couldn't use them either.

    I'm using the latest Mac OS X on iMac 5k. Can you check the compatibility, please?
     
  3. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
  4. craighinrichs

    craighinrichs

    Joined:
    Dec 15, 2014
    Posts:
    4
    Worked fantastically. I am also on a iMac 5k with the latest Mac OS X
     
  5. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    213
    That's kinda weird... because I downloaded the texture packer importer written by CodeAndWeb. Maybe my mistake?
    After several trials and fails, I ended up writing my own texture packing script. Because I wanted to do texture packing for mesh objects and skinned mesh objects, while CodeAndWeb's Texture Packer does not support mesh UV remapping.
    Anyway, thanks for your reply. Cheers!
     
  6. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    This is a great addition! Saves a lot of space in our atlas. It's a shame it doesn't work with NGUI, perhaps I should go and bug the NGUI dev about supporting it ha!
     
  7. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,058
    After updating to the latest version (which supports polygon definition), when I publish a new sprite sheet, Unity won't properly load the new texture. Rectangular textures appear squared in the inspector with misaligned sprites and with "Not yet compressed" format written in the preview. It's fixed by right-clicking the texture and selecting "Reimport".
     
  8. ehudro

    ehudro

    Joined:
    Nov 17, 2015
    Posts:
    3
    I'm a Long time user of TexturePacker on other platforms, but is there a best practice to have multiple resolutions atlases (HD/SD) with Unity + TexturePacker?
    We currently use tk2d for that, but would love to move away if possible.
     
    chopps likes this.
  9. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    @Devil_Inside We've just created an updated version of the Importer that should fix the issues. It also works with CloudBuild. I can send you an update of the dll if you want. Just contact me at support at codeandweb.com
    We'll push the update to the asset store soon. It just takes some time until the new version appears.
     
  10. Lex_Dudya

    Lex_Dudya

    Joined:
    Feb 28, 2013
    Posts:
    28
    Is there a possibility to set different pixels per units property for separate sprites in spritesheets?
    Unity Sprite Packer allow this option, but i can't find the way to recreate this effect with you sprite packer....
     
  11. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    Not yet sorry. TexturePacker assumes that all sprites in one sheet have the same pixels per unit. What exactly would you use this for?
     
  12. joe_shields

    joe_shields

    Joined:
    Jan 6, 2016
    Posts:
    5
    Hi, I have installed the installer from the links on this forum post and the right click context menu is not appearing for me in Unity 5.0.2f1 - any ideas?
     
  13. fmor

    fmor

    Joined:
    Sep 4, 2014
    Posts:
    1
    Hi,

    I've found a bug on Texture Importer.
    Everything works fine except when we override the texture max size for other platforms on Unity, then we get a bunch of errors: Invalid vertex array. Some vertices are outside of the Sprite rectangle...
    The tpsheet file has the texture size and you force the texture to have the same size, but if we want to change it for other platforms you must convert the vertices coordinates to match the new override size.
     
  14. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    just updated to the latest version 4.0.4, it cannot change the imported folder name or move under other folder. Also, is it possible to provide the source code of the TexturePackerImporter.dll
     
  15. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
    You're right, I'll fix this. An update will be available within the next few days.

    You want to move the TexturePackerImporter.dll to another folder, right? That should be possible as long as it is placed in an "Editor" directory (otherwise Unity won't load it) somewhere in your Assets folder. What problem do you observe?
     
  16. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    When I rename codeandweb.com folder to "XXX" and select SettingsTexturePackerImporter.asset in Project folder, it will generate a dummy file in XXX/Editor/SettingsTexturePackerImporter.asset
     
  17. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    Is it possible to having editor setting to turn on debug mode (i.e. print something on the console log ) ?
     
  18. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
    @yuewahchan: The importer always stores its settings (SettingsTexturePackerImporter.asset + SettingsTexturePackerImporter.txt) in the same directory as the DLL. If you move only the DLL to a new folder, the asset+txt files are automatically created there.

    What debug output would you like to see in the console log? The tpsheet files detected + processed by the importer you can lookup in SettingsTexturePackerImporter.txt.
     
  19. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    No, I am renaming the whole codeandweb.com folder.
     
  20. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    I also want to to see the error log if it is failed to import.
     
  21. Mish

    Mish

    Joined:
    Apr 23, 2010
    Posts:
    96
    I sometimes experience issues with the importer. In some cases it doesnt split up the spritesheet into multiple sprites.

    Currently I have encountered two cases where this happens.

    1. When setting the size of the spritesheet really big to have space for all the animation frames. It simply refuses to enable "muliple" in Unity. The solution was to create two spritesheets instead.

    2. Inside of Unity I had a spritesheet with a size of 4096 which worked fine. However, when setting the max size to 2048, it does the thing again and refuses to enable "multiple". It seems like it cannot split up sprites which have a lower max size than the original image.

    Is there a specific size constraint which the importer wants?
     
    Last edited: Jan 18, 2016
  22. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
    With importer version 4.0.4 the size of the texture created with TexturePacker may not exceed "max size" configured in Unity (default is 2048). If you want to use a bigger texture please increase max size of the texture in unity, and trigger a reimport of the .tpsheet file.

    With TexturePacker Importer 4.0.5 you can also import textures larger than "max size", they will be scaled down automatically. This version should be available in the asset store in a few days, we've already submitted it last week.
     
    Mish likes this.
  23. yuewahchan

    yuewahchan

    Joined:
    Jul 2, 2012
    Posts:
    309
    Can we have the source code of the texture packer importer from asset store?
     
  24. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    I just updated to the latest version of Unity (already was on the latest version of TexturePacker Importer) and it has caused all references to sprites within an atlas that uses Polygon outline mode to become messed up. For example, an object that was using sprite a, is now using sprite b.

    Are there any steps we should be following when upgrading Unity/TexturePacker Importer to prevent these issues, this is gonna set us back some time.

    Edit: I've managed to fix the issue by re-exporting the atlas from TexturePacker again and resetting the unity scene file.
     
    Last edited: Jan 27, 2016
  25. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    55
    Hi, we are upgrade texture packer importer several days ago.
    Then we cause problem, conflict diff of SettingsTexturePackerImporter.txt each other.
    (I don't import new tpsheet, sort paths by automatic reimport)
    I think the problem solved when sort paths by alphabet in SettingsTexturePackerImporter.txt.
    Can you help me?
     
  26. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
    The sort order of the file names doesn't matter. But all three lists must be ordered in the same way: if a tpsheet file is the second element in the " tpsheetFileNames" list, the corresponding image / normalmap file must also be on the second position of "textureFileNames" / "normalmapFileNames".
    You can also let TexturePackerImporter rebuild SettingsTexturePackerImporter.txt by deleting it and "Reimport All" assets.
     
  27. v01pe_

    v01pe_

    Joined:
    Mar 25, 2015
    Posts:
    62
    Does that mean, that I can ignore that file in our versioning system? If it's generated automatically anyways it seems like there's no need to commit it, right?
     
  28. ianjgrant

    ianjgrant

    Joined:
    Mar 11, 2013
    Posts:
    28
    Hi, I'm interested in setting different custom pivot points for Unity 5.x sprites on a sheet in texturepacker - I've read (on older posts) this may be an upcoming feature - but can't determine if it is in the latest version! Thanks, Ian
     
  29. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    We've added the pivot point editor with real-time animation preview with TexturePacker 4.1.0.

    Click the Sprite Settings button in the top toolbar. Select your sprites to edit on the left side - the selected sprites are added to the center area.

    Use the rubber band selection (mouse press + move) to edit multiple pivot points at once.

    Activate the Anim preview - it opens a floating window which shows the animations and immediately. It updates with all changes you make in the sprite editor.

     
    andreiagmu and SimteractiveDev like this.
  30. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Are there any plans to try and support Multipack so that if a sprite changes spritesheet as a result of multipack, then Unity's reference to it will be updated upon import? Not sure if it's even possible, but would be a useful feature I feel.
     
  31. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    The problem is that we currently don't have any way to retain or update the references... the only way that would currently work is by pinning sprites to textures in TexturePacker.
     
  32. mografi_joe

    mografi_joe

    Joined:
    Aug 18, 2015
    Posts:
    14
    Hi, I feel like I'm missing something, but I'm having a problem where I'm using the polygon trim mode and algorithm for packing, but when i bring the sheet and .png file into Unity its always defaulting the sprite mode to "multiple" and not using the polygons. If I switch to polygons and hit apply, it just reverts to "multiple" again. I'm using Texture Packer v4.1.0, the latest Texture Packer Importer and Unity 5.3.4f1. Any suggestions?
     
  33. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    @mografi_jpruss2001 Multiple is actually what you want here.

    You can verify that the polygons are in use by switching the Shading Mode (In the scene's menu) to Shaded Wireframe.

    You should see something like this: (I've set the wireframe colors to yellow in the preferences to make them visible):

    shaded-wireframe.png

    TexturePacker's triangles are well balanced. The import went wrong if you see only a rectangle made of 2 triangles or strange thin triangles.
     
    Last edited: May 5, 2016
  34. mografi_joe

    mografi_joe

    Joined:
    Aug 18, 2015
    Posts:
    14
    Ah, OK, so it IS working, brilliant. THANKS!
     
  35. Todd-Wahoske

    Todd-Wahoske

    Joined:
    Oct 23, 2012
    Posts:
    4
    Use case question:
    I'm looking for a solution for a texture atlas pipeline that would allow me to create, edit, add 3D environment art for a mobile game. (not 2D transparent sprites) Is this something I can do with Texture Packer Pro and the TP Unity plugin?
    • Create 3D model, unwrap uv's, adjust mapping, paint textures in Photoshop.
    • Save PSD file for each asset individually. (ex: mostly 512x512 px or 256x256 px)
    • Then, use a solution like Texture Packer to generate a texture atlas at 2048x2048, combining textures for several environment assets.
    • The individual textures and atlas would be edited often and added to, so the UV-Maps would need to adjust to edits and additions of new textures to the atlas.
    • Also, reducing atlas sizes might be necessary from 2k to 1k for optimization. Is there a way to add an edge bleed of 4px to each texture. (ex: 256x256 texture, actually a 248x248px + 4px edge bleed, to avoid seams when reducing the atlas size for min. spec devices)
    Notes:
    • In order for this work correctly, the order of the texture atlas would need to be locked, so textures and uv mapping appear in the same position when the atlas is regenerated (edits and additions to atlas)
    • Or, the tools are 'smart' enough to readjust the uv mapping to accommodate the changes, every time the atlas is repacked due to additions or edits to individual textures.
    On our last project, I was making these texture atlas' manually, and it took a bit of effort to get them to work correctly. Looking for a more elegant 'smart' solution. Plus, I already own Texture Packer and love it. :)

    If TP is not the solution, can anyone offer a solution elsewhere?

    Thanks!
     
  36. FlamingTroll

    FlamingTroll

    Joined:
    Jul 5, 2016
    Posts:
    13
    Hi there, recently just upgraded to unity 5.5 and am now finding issues with the slicing not happening properly based on the data. Anyone else having issues after the upgrade?
     
  37. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    Please make sure to upgrade your TexturePacker importer. We've added several fixes for Unity 5.5.
     
  38. nikniknik

    nikniknik

    Joined:
    Jul 14, 2014
    Posts:
    1
    We also recently upgraded, and upgraded the importer to the latest version (4.3.0), but our atlases are not slicing properly in 5.5
     
  39. JungsangE

    JungsangE

    Joined:
    Jan 17, 2015
    Posts:
    6
    With the most recent plug-ins in Unity 5.5, texture importing process will fall into infinity indefinitely. Please fix this bug.
     
  40. ubberkid

    ubberkid

    Joined:
    Mar 11, 2014
    Posts:
    17
    Using latest unity 5.5 and latest importer doesnt generate metadata properly for the texture /:
     
  41. Patrascu

    Patrascu

    Joined:
    Jan 20, 2016
    Posts:
    59
    Hi there, just a quick question: Should the SettingsTexturePackerImporter.txt file be commited to version control?
     
  42. Emiles

    Emiles

    Joined:
    Jan 22, 2014
    Posts:
    58
    It was suggested in a post in 2016, but i too was looking for the Texture Packer unity importer to be able to set the "Pixels per Unit" setting for the variants i'm creating.

    The reason being, (and i may be doing this the wrong way) When I load a variant, this setting needs to be adjusted to keep the sprite the same unit size in world space. In the editor i'm using the 4K atlases, when i compile to mobile i load in the 2K atlases.

    If i don't change the Unit per pixel setting, then everything is smaller. Changing this setting seemed to be the way to resolve this issue.
     
  43. enchiridion

    enchiridion

    Joined:
    Oct 29, 2014
    Posts:
    57
    @CodeAndWeb I see Multipack is not supported, so what is the best workflow for an alternative solution?

    I have a folder of building sprites for example and they need quite a lot of sheets. I am beginning to think I need to create subfolders or something but that does not seem like a very good workflow. Can there not be Pages like with Unity's built in Sprite Packer?
     
  44. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    @enchiridion That's right. The problem is that multipack might decide to pack sprites on other textures - and Unity will lose the connections...

    You have 2 main options:

    1. As you've already proposed: Create separate .tps files for each texture. This is not as inconvenient as it sounds - because you can update the sprite sheets from command line or a batch file using TexturePacker *.tps . On windows you'll have to list all .tps files to update. With this you don't even have to open TexturePacker at all. Just start the script.
    2. Use TexturePackers filters - they are part of the "scaling variants" options. E.g. make a filter for each texture you want to pack like "/spritesheet1/" ...
     
  45. enchiridion

    enchiridion

    Joined:
    Oct 29, 2014
    Posts:
    57
    @CodeAndWeb Thanks for the quick reply.

    1. It is inconvenient because I don't know how many sheets are needed to fit all the sprites on, so it's quite a manual process of trial and error.
    2. This is pretty much like Multipack except as with solution 1. one doesn't know how many sheets are needed so again it's a manual process.
    The reason I want to use TexturePacker instead of Unity's Sprite Packer is because I cannot tell Unity whether to trim transparency or use MaxRects with my UI sprites that I wish to put into sheets. Because of this, it arbitrarily decides that some sprites with lots of transparency overlap with other sprites on the sheet when used at runtime and sometimes the sprites don't overlap, really strange.

    The other strange thing is that eventhough Unity trims transparency, it still remembers the sprites original dimensions, but in your tutorials you say that TP is unable to do that specifically with Unity's UI and I can see that it doesn't work when I try it myself. So howcome Unity can do it (eventhough it randomly works sometimes and other times it doesn't) but TP cannot?
     
  46. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    @enchiridion The problem is that Unity does not use their own API... There might be undocumented / hidden functions they use... whatever. At least it's nothing we want to rely on.

    This is also why we can't enable multipack. A sprite is connected to the texture. If multipack places it on another texture it's lost and you would have to reconnect it manually. I guess that's not the solution you are looking for :)
     
  47. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Is Unity Export Included in the Free version ????
     
  48. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    40
    @ad_adnan The importer is free but you need a TexturePacker license.
     
  49. maharg

    maharg

    Joined:
    Jul 2, 2012
    Posts:
    5
    Does the importer work with Unity 5.6 and 2017?
     
  50. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    28
    yes, it supports 5.6 as well as 2017.1
     
unityunity