Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: marasto on April 28, 2012, 02:00:49 AM

Title: Major problems with fonts, soft clip, rendering issues
Post by: marasto on April 28, 2012, 02:00:49 AM
Hi,
first of all hello everybody because I'm new in the forum! And thank a lot  for the great great package NGUI. Awesome work, clean and effective.

I'm just stating working with NGUI those days but I've found some very annoying problems. Probably there is something wrong in my approach but I need some further help.

Problem 1: Font are not rendered correctly when I build the game. Inside the editor (and launching the game from there) the labels are perfect and crisp. However if I try to build the game for Mac (didn't try today IOS or Android but I can do that) the character position are totally wrong in both vertical and horizontal direction. It seem that the kerning information are missing or invalid..
I'm using latest Unity version
(https://img.skitch.com/20120428-86e2mur3a734e7145gg3qh1r2h.jpg)
(https://img.skitch.com/20120428-mqk5n757kc9adysy15ea2yhyif.jpg)
 
To be honest I found that problem only today afternoon when I switched to Unity PRO version.. It seem strange that this can happen but I have no other reason apart this one.

Problem 2: Drawing an interface with fixed dimension (UIRoot automatic flag set to off) didn't work as expected. I mean, I have a lot of aliasing due to wrong texture sampling even if the interface is pixel perfect and the half pixel offset is applied by the Anchor component. If i set the automatic flag in UIRoot the interface is displayed crisp and perfect, fonts are good and there are no appreciable artifact.

Problem 3: soft clip (but in think rendering of multiple panels) doesn't work. I need to use a scroll list and inspired by the sample I did the UI using the DraggablePanel and DraggablePanelItem components. I created a prefab for the items and I'm instantiating the objects are runtime. No problem with that, however :
- sometimes (too often) the soft clipping (but also hard, alpha etc) doesn't work anymore.
- Don't know why but the items (or any Widget added to panel parent too) are rendered behind the "clipping" panel, regardless of Z depth
- While dragging multiple components they disappear all together and sometime one of them is rendered behind the clipping panel

The fact is that I didn't make major changes to the scene, only a minor adjustments of the prefabs and UIAtlas. When that problem start presenting the only thing I can do is to create a new interface from scratch in a new scene for let it work. If I use a backup version and start again with the modifications from scratch the same things works correctly. There should be something saved inside the scene or in cache that cause the issue.

Problem 4: Sometime the UIRoot (or camera) doesn't render anymore... I need to create a new interface (always in a new scene) and restart for here.

Sorry for this long post but I found extremely tedious to work that way. I spent hours and hours making the interface again and again thinking that was something wrong :(

Bye
Cristian
Title: Re: Major problems with fonts, soft clip, rendering issues
Post by: ArenMook on April 28, 2012, 02:08:59 AM
1. Make sure your label is pixel-perfect. This means make sure to click the Make Pixel-Perfect button on it, then check each parent and make sure that you're using whole integer numbers, not floating point numbers for position, and that the scale remains at (1, 1, 1), UIRoot excluded. Last, make sure that your game window's dimensions are even. Ie: 800x600, not 801x601.

2. Same as above.

3. Clipping works only if shaders are enabled. If you have GLES 1.1 emulation on, or have it set to "Fastest" quality setting, then your shaders are off, and clipping won't work. For the draw order, make sure to bring the clipped panel forward by adjusting its transform's Z value. New panel = new draw call, means you need to separate it by Z or Unity won't know what's in front of what.

4. You mean your UI stops rendering? As in, in the editor? Just click on the game window or hit CTRL+S. Unity doesn't send update events in the editor sometimes, so UI doesn't get rebuilt.
Title: Re: Major problems with fonts, soft clip, rendering issues
Post by: Nicki on April 28, 2012, 07:04:29 AM
Somewhere in your hierarchy you could have offset a gameobject's localposition with a float, like 1.4f.

Alternatively, your game window is not the full size it wants to be, then everything gets weird. For instance, if I choose Iphone 4 tall (960*480) in an iOS build, and my window isn't quite that size, everything looks like crap.

It sounds like you may have free aspect on the game window, which makes disabling the UIRoot automatic wonky, since it will try to resize and calculate the height of the number put in as if the pixel height of your windows is that. If you put in 500, but it really is 600px, you're gonna have a bad time.
Title: Re: Major problems with fonts, soft clip, rendering issues
Post by: marasto on May 06, 2012, 06:35:21 AM
Thank guys for your support!

1. Make sure your label is pixel-perfect. This means make sure to click the Make Pixel-Perfect button on it, then check each parent and make sure that you're using whole integer numbers, not floating point numbers for position, and that the scale remains at (1, 1, 1), UIRoot excluded. Last, make sure that your game window's dimensions are even. Ie: 800x600, not 801x601.

2. Same as above.

3. Clipping works only if shaders are enabled. If you have GLES 1.1 emulation on, or have it set to "Fastest" quality setting, then your shaders are off, and clipping won't work. For the draw order, make sure to bring the clipped panel forward by adjusting its transform's Z value. New panel = new draw call, means you need to separate it by Z or Unity won't know what's in front of what.

4. You mean your UI stops rendering? As in, in the editor? Just click on the game window or hit CTRL+S. Unity doesn't send update events in the editor sometimes, so UI doesn't get rebuilt.

1) All the UI was already pixel perfect and the game screen is fixed to 1024x728 pixel. The problem was due to atlas texture. I don't know why, really. I just made the texture again using TexturePacker and re-exported the font using bmGlyph and then it worked. Pretty strange but at least it work now

2) I notice that the Player preference saves doesn't contains the right quality settings for the rendering. I forced the render quality default to good (so antialias is present) and that way it was fine.

3) It was not a problem of emulation or quality settings. To be able to fix that I needed to rebuild the interface from scratch. Your latest fixes to DraggablePanel also mitigate other issues that I had so far.

4) Unity editor doesn't send some events or update. By creating a new scene and UI root element the problem was fixed.

Somewhere in your hierarchy you could have offset a gameobject's localposition with a float, like 1.4f.

Alternatively, your game window is not the full size it wants to be, then everything gets weird. For instance, if I choose Iphone 4 tall (960*480) in an iOS build, and my window isn't quite that size, everything looks like crap.

It sounds like you may have free aspect on the game window, which makes disabling the UIRoot automatic wonky, since it will try to resize and calculate the height of the number put in as if the pixel height of your windows is that. If you put in 500, but it really is 600px, you're gonna have a bad time.

In fact I set free-aspect and that cause the problem. Thank Nicki!