Search Unity

Feedback Better sprite slicing. Grid based pivots.

Discussion in '2D' started by illinar, Nov 27, 2020.

  1. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    I want to have sprites that have pivots in the center of the grid cells, but the sprites themselves to be trimmed.

    Sprites like this:
    upload_2020-11-27_12-21-11.png

    But then the pivots are relative to the bounds, and this doesn't work with animation well. So I want pivots to be relative to the grid. As if I sliced by grid cell.

    upload_2020-11-27_12-23-35.png
     
    Last edited: Nov 27, 2020
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    Do you want them to be trimmed so there's less overdraw? If so, then if you ensure that on the sprite's texture you have it set to Tight (instead of Full Rect) then it will automatically essentially trim it. The rect will remain large but there won't be empty overdraw (edit: With Tight setting, distinction is between sprite.textureRect, which is small, vs sprite.rect which remains large). It's also possible to provide a Custom Outline to fine-tune it within the Sprite Editor.

    If on the other hand you have some very particular need, then you could use the scripting API for the Texture Importer and process your textures sprite metadata to achieve the effect you want. This would probably mean using the trim tool by hand, then processing it to position the pivots as if they are on a grid.
     
    Last edited: Nov 27, 2020
    illinar and eses like this.
  3. illinar

    illinar

    Joined:
    Apr 6, 2011
    Posts:
    863
    Thank you for the information. I didn't know that there are two rect variables. I will use tight for the texture rect. Yes processing option would be on the table, but I just need less overdraw.