Search Unity

2 sprites that have a same pixel width, end up having different widths when imported to Unity

Discussion in '2D' started by zeroBudget, Jun 23, 2021.

  1. zeroBudget

    zeroBudget

    Joined:
    Nov 14, 2019
    Posts:
    62
    I couldn't find a similar thread on this. Let me know if this should be posted in a different section.

    Basically, I have two images. One of them is a JPG file that is 4000x600 pixels, and the other is a PNG file that is 4000x34 pixels.

    They are supposed to scroll in unison. But when I import them into Unity... their widths in dimensions are not the same. One has a slightly longer width than the other even though they are both supposed to be the same width.

    I even set the same scale of 1 - and one is still longer than the other despite their original images having the same width in pixels. Why is this the case? Why are they different when imported into Unity?
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Does the png have transparency at the edges?
     
  3. zeroBudget

    zeroBudget

    Joined:
    Nov 14, 2019
    Posts:
    62
    I don't beleive so, but when I view the png file in Windows photo viewer, it tends to randomly "expand" by a few pixels on each side. I don't know why. I'm gonna make them the same file type and see if that makes a difference.
     
  4. zeroBudget

    zeroBudget

    Joined:
    Nov 14, 2019
    Posts:
    62
    Update:
    So I made both JPGs and I have the same issue.

    I noticed though, that when I increased the original file's height (from 4000x34 to 4000x200), the issue seemed to be fixed.

    It seems like Unity stretches out your image more if it is already too short and wide?

    This is what I mean below:

    The top line is the original, the bottom line is the new one. Both original images were 4000 pixels wide and different hieghts, but when uploaded to Unity, the taller image ends up being more narrow.

    upload_2021-6-23_12-44-20.png
     
  5. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    What does your import settings for the textures look like?
     
  6. zeroBudget

    zeroBudget

    Joined:
    Nov 14, 2019
    Posts:
    62
    upload_2021-6-25_18-10-44.png
     
  7. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Looking at your import setting I see Unity is currently limiting the size of your texture to 2048. It is then stretching it out to the correct size which could cause the size variation. By default all textures have a max size of 2048, you can put this up to see if that will helps. If it doesn't help then I would file a bug report as I really have no clue as to why it would do this. I have never experienced this problem, or didn't notice it.
     
  8. zeroBudget

    zeroBudget

    Joined:
    Nov 14, 2019
    Posts:
    62
    Thanks for that bit of help, I'll see it that works.