Author Topic: Seems to be half pixel problem  (Read 6482 times)

zhenghongzhi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Seems to be half pixel problem
« on: October 29, 2015, 04:30:52 AM »
When I place a image on the left-top corner at (0,0), there is a small gap on the top?
Is this the half pixel problem? How can I fix this? Thank you!


Unity5.2.1
NGUI3.9.4b

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Seems to be half pixel problem
« Reply #1 on: October 29, 2015, 07:33:33 AM »
Most likely because your window's dimensions are not dividable by two. What is its size?

zhenghongzhi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Seems to be half pixel problem
« Reply #2 on: October 29, 2015, 09:24:25 PM »
Yeah, I checked that and that's the problem. Thank you
Now I have another question. My sprite is 465*123, and it becomes 466*124 in the scene. Anything causes this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Seems to be half pixel problem
« Reply #3 on: October 31, 2015, 02:07:12 AM »
1 pixel of padding is added automatically in order to make dimensions dividable by two, otherwise you can't center a sprite as it would fall in between of pixels.