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

Question How Max size in unity sprite import setting resize a sprite?

Discussion in '2D' started by KaveeM2007, Feb 17, 2023.

  1. KaveeM2007

    KaveeM2007

    Joined:
    Jan 18, 2022
    Posts:
    21
    Hi guys, this is something I really couldn't understand although I did thousands of google searches. How actually unity max size option in sprite import settings resize a sprite?

    For example, in my case I have an sprite (a PSB file) which original dimensions as 4096x4096 (WidthxHeight) . I made it in photoshop with a resolution of 300. And in Unity I changed it to 2048 in max size. I kept the PPU (PizelsPerUnit) at 100 which is the default value.

    I also had an earlier PSB sprite, the same tree but with original dimensions of 1000x1000 and resolution of 300. I was also made in photoshop too. I also set it's Max size to 2048 in import size. I kept it's PPU at 100 too.

    So my guesses was that the both GameObjects (As they were PSB files), will be the same size in the editor. At that time, I thought the MaxSize option changed the dimension of the sprites(PSB files). Like, the 4096x4096 one to 2048x2048 and the 1000x1000 one to 2048x2048. Both of the sprites had the same PPU (100)

    But for my surprise, when I put them in the scene, they were of 2 sizes. This was bugging me, according to me both the sprites were the same size with same dimensions.

    Then I went and changed their Pixels per unit values like below keeping the Max size same in both (2048 - MaxSize)
    • 4096x4096 -- 4096 PPU (was 100)
    • 1000x1000 -- 1000PPU (was 100)
    Now, both the GameObjects were the same size in the scene ( transform values of both the GameObjects were same from the beginning)

    (The MaxSize in the import setting was changed it Default panels, it wasn't platform specific. Quality setting it the project setting tab were kept default. I am using Unity 2020.3.19f1 in 2D template)

    I was so confused by this, so now I have these question, if you can answer it would be a huge help.
    1. How unity MaxSize works in import setting, does it change the dimensions or does it do something else. Can someone give me a detailed review cuz I'm really confused with it.
    2. How PPU works in unity.
    3. What are the changes in importing PSB files and usual Sprite Sheets.
    4. How unity Resize Algorithm works
    That's all for now, Can someone please help me with this huge confusion I'm in.
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    Hey, I'll do my best to answer your questions.

    It's the max resolution. It won't change the size of your sprite in the scene, just the resolution. It also won't upscale low resolution sprites to whatever you set it to. Your 1000x1000 sprite won't be affected at all regardless of whether "MaxSize" is 1024x1024, 2048,2048, or 4096x4096. Your 4096x4096 sprite will have its resolution halved if you set "MaxSize" to 2048x2048, but its size in the scene will remain the same.

    PPU stands for "Pixels per Unit." In other words, how many pixels take up a single unit of space in Unity. It's how unity measures space. Generally, it's ideal for all sprites to have the same PPU, so that you can decide their sizes in your image editor. Raising the PPU makes the sprite smaller in the scene because more pixels fit in a unit.

    PSB files can be more convenient, and you have more options when it comes to adding 2D bones. Unity makes a sprite sheet out of your PSB file, so when you build your game I don't think there are many differences, if any.

    No idea, but I don't think this is necessary information. The important thing to note is that regardless of how your sprite's resolution changes with the "MaxSize" setting, its size in the scene will remain the same and is decided by its original resolution.
     
  3. KaveeM2007

    KaveeM2007

    Joined:
    Jan 18, 2022
    Posts:
    21
    Thank you so much for this information, I think I now understand how the whole import settings works. By the way, is importing sprite sheets and PSB files the same? I thought PSB files take more space than sprites, usually like 6 MB - 8 MB(These sizes are according to how my file explorer showed me in the properties tab of the PSB file, I dont know how big it is in unity)
     
    Unrighteouss likes this.
  4. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    PSB's are definitely bigger, but that's only in the editor. When you build your game they should be identical because PSB's build a sprite sheet (if Unity has optimized everything correctly, I don't know how everything works under the hood).
     
    KaveeM2007 likes this.
  5. KaveeM2007

    KaveeM2007

    Joined:
    Jan 18, 2022
    Posts:
    21
    I think the size difference is neglectable. I found it by doing an experiment. Here is the result!

    For my surprise, I found that using PNG files cost you more space than PSB files. Here I have 3 folders with unity builds.
    _EmptyScene - The Scene is empty, there are only the default files in the build ( Project Data, CrashHandler, etc)
    _PNG - There is a GameObject(Sprite) which's original asset is a PNG file in the scene. It is a tree and let's call it "Tree1"
    _PSB - There is a GameObject(Sprite) which's original asset is a PSB file in the scene. It is the same tree we named "Tree1".

    As you see, using PSBs may cost you less space.
    Do Note that Both have same common setting and the PSB file has also Mosaic and Character Rig properties ticked. There aren't any skins or a skeletons for both PNG and PSB. Also both has MipMaps turned off.

    So what thought you have on this experiment? Is using PSB more efficient and beneficial?
     

    Attached Files:

  6. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    Sounds like they are, at least compared to PNGs.