Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

TexturePacker + Importer - Spritesheet generator & Sprite mesh optimizer

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

  1. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    34
    Please restart Unity after importing the package, the error won't be displayed again and TexturePacker Importer will still work fine. An updated version with the fixed namespace/assembly name will be available in the Asset Store in the next few days.
     
    Devil_Inside likes this.
  2. hamza_unity995

    hamza_unity995

    Joined:
    Apr 19, 2022
    Posts:
    7
    hi, we're having a similar issue in our project. I think we fixed the issue with SettingsTexturePackerImporter.txt by updating since we use 2021.3.1f1. However we still have some re ordering changes popping up in meta files of spritesheet image assets, under "nameFileIdTable". Is there a solution for this? is this a known issue or a common problem?

    it could be related to this warning (not sure if it's still there after update):
    Identifier uniqueness violation: 'Name:X, Type:Sprite, FileId:0'. Multiple Objects with the same FileId are generated by this Importer. There is no guarantee that subsequent imports of this asset will properly re-link to these targets.

    Besides, there is also this error:
    Assembly 'Assets/Plugins/codeandweb.com/Editor/TexturePackerImporter.dll' will not be loaded due to errors:
    Assembly name 'TPImporter' does not match file name 'TexturePackerImporter'
     
    Last edited: May 3, 2022
  3. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    34
    This is a Unity bug we've already reported.

    The other to issues (uniqueness violation, assembly error) are fixed in the latest TexturePackerImporter release. Please update.
     
    hamza_unity995 likes this.
  4. hamza_unity995

    hamza_unity995

    Joined:
    Apr 19, 2022
    Posts:
    7
    Thanks!
    Please let us know if you have any news regarding this Unity bug, I also tried to find a bug tracker link on the thread or on the web but couldn't.
    Could you share a link please? maybe we upvote it and be informed of its status.

    We already updated to the latest TPImporter, 6.0.3 maybe we need to restart Unity.
     
  5. Kobayen

    Kobayen

    Joined:
    Apr 17, 2014
    Posts:
    6
    Evening. We have an issue where the TexturePacker Importer where we want to change the Origin point of sprites after they're packed and inside Unity, yet the option to tell the Importer to stop recentering the pivot is missing from Unity's preferences.

    For the record, Unity 2021.2.18f1 under Windows 10
     
  6. Gohloum

    Gohloum

    Joined:
    Nov 29, 2018
    Posts:
    12
    Hello, I am having an issue with Texturepacker Importer in Unity 2021.3.51f. When importing the package, I get a warning that says requires dependencies and presented with the choice of upgrade/install or skip buttons. However I already have the Sprite2D package installed. The original texture sheet I added when creating the project works fine. The new file which is a second sheet, has the same export settings from TexturePacker, so I am not sure why it is working. A comparison of both side to side show identical, except for 2 things:

    1 - in the preview pane, the new sheet's sprite rectangles are not lined up correctly, however if I open the sprite editor they are.

    2 - Under Asset PostProcessors, the working sheet has 2 extra listings:

    UnityEditor.U2D.Animation.SpriteLibrarySourceAssetPostProcessor
    UnityEditor.U2D.Animation.SpritePostProcess

    I have included a screen shot of the settings for each sheet.
     

    Attached Files:

  7. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    60
    Hi,

    it's hard to say what's happening here without access to your project. If possible, you might provide us with some more information to support at codeandweb.com ....

    What comes to mind:
    1) Do you use the newest version if our importer?
    2) Do you only have 1 TexturePacker Import DLL in your project?
    3) Did you try a reimport-all?
    4) What happens if you klick on "upgrade" when asked for installing Sprite2D?

    Best
    Andreas
     
  8. Gohloum

    Gohloum

    Joined:
    Nov 29, 2018
    Posts:
    12
    OK, I played around with some other texture sheets. We have been using your tool since 2015. Any texture sheet I bring into unity that was made in 2019 or earlier work fine. I don't have any in 2020, but all my 2021 textures have the same issue. I don't personally work with the TexturePacker tool itself. I will have to contact my business partner as he is the one who does. Are there any suggestions of things that may have changed in the settings from upgrades that we should look at? I did check out the .tpsheet format in notepad and it's indeed text and not JSON.

    UPDATE: We resolved the problem.

    I spoke with my business partner who uses the TexturePacker tool and we did some experimenting. What it turns out is he was copying existing projects to create new ones so that he would not have to edit the settings. Apparently, after the upgrade, this seems to have caused some problems with the latest version of the importer. The way I had him resolve it was he changed the data type from Unity to a different type, in his case we picked JSON Array. Saved the settings and it reset the project and refreshed the sprite sheet. After this he changed it back to Unity settings and saved. The he exported the sheet and it's .tpsheet companion and everything worked as expected.

    Not knowing exactly how the Packer and Importer work with each other, what I did notice as shown in the screen shots in my previous post, that the importer was definitely doing something, but seemed to not be completing it's tasks on import. On a whim, I thought it might be some sort of data corruption. Once he told me how he was making new projects, it raised suspicions that the upgraded TexturePacker may be formatting data differently, and thus seeding a project with old data could be the problem. Apparently that was the case as we quickly fixed several sheets suffering from the same issue using this process.
     
    Last edited: Jul 22, 2022
    CodeAndWeb likes this.
  9. senfit

    senfit

    Joined:
    Nov 21, 2019
    Posts:
    3
    Hi everyone! First of all, thanks for the great tool! I'm using it for a while now and it's my favourite solution for importing sprites.

    I switched to addressable assets and have some questions regarding the intended implementation.
    I have two TexturePacker Sprite Sheets and a prefab:
    • TPSheet-A
    • TPSheet-B
    • Prefab
    All three are addressable assets and for simplicity let's assume TPSheet-A and TPSheet-B include similar sprites but the Prefab references sprites from TPSheet-A.
    Before instantiating the Prefab I am loading TPSheet-B and reloading all sprites used in the Prefab from TPSheet-B after instantiating it. But still, the profiler shows TPSheet-A in ram (And TPSheet-B of course).

    This process is crucial for both, avoiding bloating ram usage and batch optimization and can be easily achieved by using unity atlases and unchecking "Include in Build". (Unity atlases do not pack sprites as compactly as TexturePacker, so using it isn't an option for me)
    Is there similar a similar feature or should I implement it differently?

    Of course, I could remove all sprites from prefabs in the editor but making changes afterwards without seeing any sprite in the editor is not practical.

    Here's another small question:
    Checking the box "Addressable" in Unity Editor for a sprite sheet is overridden when exporting again via TexturePacker. (This also applies to Compression settings within Unity)

    Setup:
    Unity 2019.4.40f
    TexturePacker 6.0.2

    Thanks a lot for checking my questions!
     
  10. j-o-e

    j-o-e

    Joined:
    Mar 11, 2014
    Posts:
    34
    I haven't used addressable assets so far, I don't know if there is such a feature. TexturePacker Importer is not involved in the way Unity manages dependencies.

    I can't reproduce that. Are you using the latest TexturePacker Importer 6.0.3?
    Please make sure that you don't delete the existing sprite sheet files before exporting the new ones with TexturePacker, just let the exporter overwrite the files.
     
  11. unity_dev12345

    unity_dev12345

    Joined:
    Apr 13, 2021
    Posts:
    13
    texture packer cut my sprite at a different height and width and the animation jumps and vibrates,
    what
    I would love to know how to set it up correctly
    Thank you
     
  12. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    60
  13. MichaelHeiml82

    MichaelHeiml82

    Joined:
    Nov 2, 2009
    Posts:
    27
    Hi @CodeAndWeb , about Multipack and Unity - I know this discussion has been raised in the past, but is there any new development here so to workaround broken references in Unity if a sprite changes the sheet?

    I recently upgraded from TP5 to TP7. My project heavily relies on a LOT of texture sheets => so multipack - and therefore automatic optimal distribution - would be very helpful, but this breaking references thing is a downer..
     
  14. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    60
    We still have no solution to automatically update the references. This is because unity tracks the sprites per sheet.

    We've added a new manual Multipack mode - this works around the issues in Unity.

    The idea behind this is that you create multiple sprite sheets in your project. You then assign folders or individual sprites to the sheets. With this, sprites don't switch from one sheet to another but stay on the same sheet.

    2023-04-14_14-22-12.png
     
  15. MichaelHeiml82

    MichaelHeiml82

    Joined:
    Nov 2, 2009
    Posts:
    27
  16. MichaelHeiml82

    MichaelHeiml82

    Joined:
    Nov 2, 2009
    Posts:
    27
    Hi again, I might have found a solution that at least works pretty fine for me to update references when sprites are moved from one atlas to another one in auto-layout mode.

    Basically I have a component attached to all the UI elements that use a sprite from the atlas (call it Component "ImageAtlasReference"). So what the component does is:
    1. rename the GameObject whenever the sprite.image is changed to match the name of the sprite on the sprite sheet. This basically "saves" the reference. (alternatively, if the go name should not be changed, save the name as string on the component)
    2. when the sprite atlas updates and images move from one to another, another editor script searches for all "ImageAtlasReference" components.
    3. Whenever this component is found, it checks if the sprite.image reference is null or missing. If so, it searches through the entire project database for a sprite with exactly that name and if found, re-references it to the sprite.image field.

    Voila, this updates broken references within a blink of an eye.

    This only works as long as the sprite names themselves do not change.

    It would be nice if the TP Unity importer supports a post-import event so it could trigger my component every time an atlas change is detected. Just a bit nicer then always manually triggering the checker script.

    If you want to have a look at the components, just PM me..
     
  17. CC_YN

    CC_YN

    Joined:
    Jul 30, 2021
    Posts:
    11
    Hi, is it safe to delete the .tpsheet file after import? If not, what is the usage of this file?
     
  18. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    60
    No. Don't delete that file.

    It's required for slicing the sprite sheets while you use the Unity Editor or during Build. It's also required when you do a re-import. So you should not delete the file.

    However it's not used at runtime - so there's no need to deploy it to the target system.
     
    CC_YN likes this.
  19. Azag_Tot

    Azag_Tot

    Joined:
    Dec 20, 2020
    Posts:
    3
    Good day!
    I have texture atlass and tpsheet. How do I can edit this atlass if I don't have original separate textures?
     
  20. CodeAndWeb

    CodeAndWeb

    Joined:
    Jul 31, 2014
    Posts:
    60
    You currently can't. If you don't have the original textures, the only way is to use a graphic tool (Affinity Photo, Photoshop,..) to split the texture manually.
     
    Azag_Tot likes this.