Author Topic: UI2D Sprite not considering Pixel Size when doing Snap / MakePixelPerfect  (Read 5487 times)

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Using version 3.8 (didnt see any patch notes about changing/fixing this since then)

With the old UI Sprite, using Unity Atlases, the "pixel size" is factored in when doing Snap/MakePixelPerfect. If set to 0.5, the sprite size will be half of the raster's size.

With the new UI2D Sprite, the pixel size seems to have no impact on Snap/MakePixelPerfect. Am I missing something?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
That's probaby a minor bug. You can try fixing it by modifying UI2DSprite's MakePixelPerfect function from:
  1. int w = Mathf.RoundToInt(rect.width);
  2. int h = Mathf.RoundToInt(rect.height);
to:
  1. int w = Mathf.RoundToInt(pixelSize * rect.width);
  2. int h = Mathf.RoundToInt(pixelSize * rect.height);