Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Charriu84 on February 09, 2017, 07:11:04 AM
-
Hi,
I noticed that my sprites have strange offsets (1 pixel gaps) on some aspect ratios (3:2) as you can see here:
(https://www2.pic-upload.de/thumb/32650265/ScreenShot2017-02-09at12.52.37.png) (https://www.pic-upload.de/view-32650265/ScreenShot2017-02-09at12.52.37.png.html)
This is a simple scene with just an 8x8 pixel sprite in it. The actual image behind it has the same dimensions. Notice how the pivot is at the bottom right of the rectangle, but the actual image is offset by some pixels. These are the settings
(https://www2.pic-upload.de/thumb/32650264/ScreenShot2017-02-09at12.52.47.png) (https://www.pic-upload.de/view-32650264/ScreenShot2017-02-09at12.52.47.png.html)
https://www.pic-upload.de/view-32650266/ScreenShot2017-02-09at12.52.58.png.html
I don't understand what causes this gap. Can anybody explain this to me? I'm using NGUI 3.9.6
-
Just google DirectX9 half pixel offset.
It's nothing you have to concern yourself with, and is something that will go away if you update your Unity and NGUI.
-
I've updated to Unity 5.5.1 and NGUI 3.11.2. I've tested it in an otherwise empty project and the problem still occurs. Am I missing something? Also I'm on macOS Sierra 10.12.
-
Oh, on a Mac there is no pixel offset, but there may be an alignment offset if your game window's dimensions are not dividable by two.
Check your game view size.
-
I did some more tests and it's not the gameview size. I've put the gameview to a fixed 960x640.
I have my UIRoot set to
Scaling Style = Constrained
Content Width = 2048 Fit = True
Content Height = 1536 Fit = False
My Camera is set to perspective and everythings fine. But when I switch the camera to Orthographic I see the gap.
-
Your content size is larger than your game view, so yeah there's bound to be some inconsistencies. 1 pixel according to NGUI (content size) is not the same as 1 pixel of your game view. If you make the game view match the UIRoot size, there won't be any gaps or padding. Anyway all of this is pointless anyway, assuming your target device is 2048x1536 (iPad?) -- as the downscaling to 960x640 is going to happen only in the editor.
-
Ah ok. It's not that pointless as my target device include all iOS devices. I used the constrained UIRoot because I wanted my UI to be in the correct scale corresponding to the aspect ratio of the device. Maybe I missunderstood this setting. But thanks for explaining.