Author Topic: lots of problems with fonts and scale  (Read 5348 times)

terravires

  • Guest
lots of problems with fonts and scale
« on: May 08, 2013, 04:26:25 AM »
So I've watched the tutorial videos, both cgcookie and the latest NGUI videos, read the forums and websites, but for the life of me I can't get my copy of NGUI to work correctly.

I've got NGUI 2.6.1c and Unity 4.1.2f1 (pro).

I setup my scene using the NGUI UI wizard.  I then create an atlas using the NGUI atlas tool and add some pngs.  All good so far, but then when I try to add my fonts I have problems.  I created my font using BMFont 1.13, select font with white and alpha, rename the .fnt to a .txt.  I can see the font correctly in the .tga file.  Import those into unity.  But when I go to the font wizard in NGUI and try to add it to the atlas it does nothing.  I select the font text, the png and the atlas.  No errors, no warnings, nothing in console.  The green button changes to red and now says replace but the atlas never gets updated.

So I gave up using that method and went with dynamic fonts.  That worked to a degree.  But as has been posted many times before, I get tons of problems with layers and widgets that disappear.  I also am having problems with the move tool when I move layers.   Sometimes it works as expected, other the transform gets all random values and the scale/values all go to 0 giving me an errors.  Sometimes when I'm on the move tool and try to grab an axis it ends up rotating the widget instead of moving.   Then finally, for some reason when I have my game scene view (editor) split window with game view (camera) and I just select a panel, the views seem to zoom in cropping the edges.  I have to click play to get the zoom restored to default. (2D ortho camera in editor and for my NGUI camera)

Honestly, it's been a rather large nightmare to work with.   >:( 

Edit: also one request, when you edit the text of a widget, say label, enter doesn't work since it's mutli-line, so I would expect then ESC stops edit.  Instead it just resets the text.  There is no easy way out of the text field other than try to select something else.  My opinion is ESC should just stop edit and CTRL-Z should be left for undo.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lots of problems with fonts and scale
« Reply #1 on: May 08, 2013, 06:19:30 PM »
Escape handling is on Unity's side, there is nothing I can do there.

If you can't get a hang of how green dot handles work, you can disable them via the NGUI menu. In short, with handles enabled you shouldn't be using the move tool as handles overwrite its behaviour. Note that the mouse cursor changes as you hover over parts of the widget and its corners? It's showing you what will happen.

With dynamic fonts you have to adjust Z on labels, bringing them forward (-1 works in most cases). Note that this assumes 2D UI. For 3D UIs you shouldn't use dynamic fonts and multiple panels due to how Unity sorts objects.

With bitmap fonts, the way you described your process should work, although there is no need to rename FNT to TXT anymore. If the button changes from green to red, it means the font has been added to the atlas. What do you gauge the "does nothing" by? The font should be usable by that point.


terravires

  • Guest
Re: lots of problems with fonts and scale
« Reply #2 on: May 08, 2013, 08:58:21 PM »
Escape handling is on Unity's side, there is nothing I can do there.

If you can't get a hang of how green dot handles work, you can disable them via the NGUI menu. In short, with handles enabled you shouldn't be using the move tool as handles overwrite its behaviour. Note that the mouse cursor changes as you hover over parts of the widget and its corners? It's showing you what will happen.

I'm not trying to use the green handles as I was trying to move via the unity axis to keep a strait line.  My cursor was outside the green box and handles and was on the red arrow tip for X axis.

And as I said, for some reason when I try to use the NGUI move (move cursor inside green box) it doesn't always work.  Sometimes it move a few pixels and sometimes the transform values go crazy and end up at all zeros.  I'm doing this from ortho back view.


Quote
With dynamic fonts you have to adjust Z on labels, bringing them forward (-1 works in most cases). Note that this assumes 2D UI. For 3D UIs you shouldn't use dynamic fonts and multiple panels due to how Unity sorts objects.
Yes, I read the many posts on this but am still having problems with overlap due to having more than one atlas. 

My current setup, with dynamic font and 2D UI.
Panel
- labels
- buttons

Panel
- sprite (Z +1)
- labels
- empty-gameobj container (Z -1)
-- button
-- labels
-- sprites
- empty-gameobj container (Z -2)
-- button
-- labels
-- sprites

I'm also not sure why, but using dynamic fonts and trying to hit "make pixel perfect" just resets the scale.  Is that by design?  I amused it would just round to the closest pixel size.

Quote
With bitmap fonts, the way you described your process should work, although there is no need to rename FNT to TXT anymore. If the button changes from green to red, it means the font has been added to the atlas. What do you gauge the "does nothing" by? The font should be usable by that point.

That's just it, the font is not added to the atlas.  If I look at the atlas you can't see the font.  If I try to use it at that point I get corrupted pixels instead of text.  The only change I see is that there is a new font prefab.



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: lots of problems with fonts and scale
« Reply #3 on: May 09, 2013, 07:02:47 AM »
You've discovered a bug, seems regular atlased bitmap fonts got broken in 2.6.1. I'm putting up 2.6.1e that should fix it now.

In regards to your sprites... keep in mind if you have sprites using the same atlas, one at +1 and another at -1, it's the same thing as having both of them at Z of 0, as the two of them cancel each other out. Unity sorts by the center.

Your layout should look like this:

Panel
- sprite
- labels (-1, only if using dynamic font)
- empty-gameobj container
-- button
-- labels (-1 if dynamic)
-- sprites
- empty-gameobj container
-- button
-- labels (-1 if dynamic)
-- sprites