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. Dismiss Notice

Resolved How to preserve sprite size with Aseprite importer

Discussion in '2D' started by switchCTRL, Jul 6, 2023.

  1. switchCTRL

    switchCTRL

    Joined:
    Dec 19, 2021
    Posts:
    4
    Hi, i am currently trying to import sprites from Aseprite with a lot of layers each for an individual part of a character. My layer structure looks like this:
    Bildschirmfoto 2023-07-06 um 14.56.07.png
    The sprite is 64x64px and I need to preserve that size because of the position of each body part or clothing. Currently I cannot find an option to preserve the size and all slices are trimmed. Is there an option to set the slicing mode to per cell size instead of trimmed?
     
    granpasnoopy likes this.
  2. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    875
    There is currently no way to remove the trimming for each cell. Aseprite does a trim pass when saving the pixel data down to the .aseprite file, so when we load the data up in Unity, it no longer has the size you see in Aseprite.
    However, I am curious why you need to preserve the size. Could you expand on how it fails?
     
  3. switchCTRL

    switchCTRL

    Joined:
    Dec 19, 2021
    Posts:
    4
    Hi Ted, thanks for the answer.
    I use sprite libraries and sprite swap to construct a character. My Aseprite files contains a layer for each part which can be modified in my game, for example there are different pants, hair, jackets, shirts etc.. After the import every sprite is by its own size, e.g. 10x12 px. My character is constructed in a 64x64px sprite. Now I am missing every position of these parts. Everything would be at the center.
    But if Aseprite saves a trimmed sprite how do they know where the sprite goes if I load a saved file?
    This is how I currently export the sprites to png and then to unity (this is a hairstyle):
    radical_curve.png

    In Unity i have something like this with the Aseprite importer:
    Bildschirmfoto 2023-07-06 um 19.47.29.png
     
  4. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    875
    Looking at the image, I think the following import settings are suitable for your use case:
    Import Mode: Individual - So that each cell is imported as its own Sprite, so you can swap it out easily
    Pivot Space: Canvas - So that the pivot for each Sprite is calculated according to its position in the original canvas, rather than the final Sprite.

    Have you tried these settings out?

    Every cell has position data stored with it. This is also the data we use to calculate the "Pivot Space: Canvas"-pivot. With this data, you can easily position the trimmed sprites back in place. That is what Aseprite does.
     
    switchCTRL likes this.
  5. switchCTRL

    switchCTRL

    Joined:
    Dec 19, 2021
    Posts:
    4
    Maybe I am missing something. I can only choose between "Animated" and "Sprite Sheet" as import mode. Only when choosing animated I can set the pivot space. But it works now with that combination, thanks :)
     
  6. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    875
    Thats good to know, maybe the wording of "Sprite Sheet" could be improved. The idea behind the "Sprite Sheet" option is that you are in control of slicing the Sprites up yourself, rather than letting the importer do it for you. This was requested by some of the users.
    I'll make a note to see if the name can be improved.

    Happy that you got it all working in the end!
     
    switchCTRL likes this.