Author Topic: UILabel that was TTF, then switches to NGUI still uses TTF var for checks  (Read 14736 times)

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
I had a TTF label that I made into a NGUI font label. I noticed there were some sizing problems. When i debugged into the code I saw that it was doing null checks on the ttf font which must still have been set in the serialization. Hence it got the default font size wrong. The label was experiencing some other incorrect behavior which I am hoping is related to this as well.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
We had the same problem, just switch on Unity font, make it null(remove the ttf from the UILabel) and switch again to NGUI Font. This way it should be null.

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
I have about 2 billion labels, so hoping this can be fixed in the code :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
How did you happen to do that? The UILabel.bitmapFont property intentionally clears the true type font reference right after assigning the bitmap value you passed to it...

greyhoundgames

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 39
    • View Profile
I had about 100 prefabs with labels that were all TTF fonts. I dropped them all in, in the filter box i typed in UILabel. Then with them all selected I clicked on the font type box and changed it to NGUI.

Then I applied all the prefabs.

How I noticed this problem in the first place is that the default font size # was showing 25 which was the UILabel.fontSize variable value instead of 64 which was the NGUI font file size.

Thats when i put a breakpoint in the UILabelInspector class and saw that the default font size getter was determining that the ttf font was not null and returning the font size itself.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Aren, I already told you about a similar problem on this topic:
http://www.tasharen.com/forum/index.php?topic=12501.msg57019#msg57019

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
I found the reason for this... label inspector was using Unity's serialized properties instead of actual class properties that would have set it properly.