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

Scale sprites into one spritesheet?

Discussion in '2D' started by lior_rosenspitz, Feb 29, 2016.

  1. lior_rosenspitz

    lior_rosenspitz

    Joined:
    Jan 24, 2015
    Posts:
    24
    Is it possible to create a customized sprite-packer policy which will also scale down the sprites in order to fit in one spritesheet?

    I've tried different solutions, and there's something similar in 'TexturePacker' 3rd party software, but it has its own cons comparing to the built-in Unity's SpritePacker. Especially with 2d animations (using frame by frame method, with lots of alpha to cut on the sides).
    The main problem is when I want to reduce an atlas, I will need to guess how much I want all the sprites to be scaled in order to fit into one atlas.
    Any ideas?
     
  2. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    > I've tried different solutions, and there's something similar in 'TexturePacker' 3rd party software, but it has its own cons comparing to the built-in Unity's SpritePacker. Especially with 2d animations (using frame by frame method, with lots of alpha to cut on the sides).​

    You don't have to use frame by frame animations if you use our free importer from the Asset store https://www.assetstore.unity3d.com/en/#!/content/16641

    You can create optimized polygon meshes which have less overdraw and fewer vertices than the internal packer. It also allows you to pack the sprites tightly.

     
  3. lior_rosenspitz

    lior_rosenspitz

    Joined:
    Jan 24, 2015
    Posts:
    24
    Hi,
    We already tried it, and the problem wasn't how to squeeze the assets into one atlas (or import it to unity), but the main issue was when trying to play it.
    We got a series of sprites, not always fill the whole box, and an animation bouncing in it. Both unity and SpritePacker can crop/trim to make it efficient, but for now we only got Unity to play the assets correctly.
    (Somehow it remember the original position of the cropped asset, and play present it correctly, while SpritePacker doesn't).
    Or do we miss something?
     
  4. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    I am quite sure that you missed something. Not beeing able to play an animation would be a really big issue.
    I'll need your .tps file with the settings you are using in TexturePacker.
    Can you send me that? Either here or at [support at codeandweb.com].

    You are using Sprites, not UIImages, is that correct?
     
  5. lior_rosenspitz

    lior_rosenspitz

    Joined:
    Jan 24, 2015
    Posts:
    24
    OK,
    I was using UI-Images, but after you mentioned it I did tried Sprites, and that one was working fine.
    Is there a reason that SpriteRenderer component will act differently than UI-Image component with these kind of spritesheet?
     
  6. Andreas Loew

    Andreas Loew

    Joined:
    Feb 27, 2013
    Posts:
    17
    UIImages have several severe disadvantages

    1) They don't use polygon meshes - they always use rectangles / quads. This increases overdraw - and might lead to bad performance.
    2) They ignore pivot points - this is why you saw the animation jittering
     
    lior_rosenspitz likes this.
  7. lior_rosenspitz

    lior_rosenspitz

    Joined:
    Jan 24, 2015
    Posts:
    24
    I didn't know all that.
    Thank you for the explanation.