Author Topic: UILabel Issue  (Read 8690 times)

justinISO

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 52
    • View Profile
UILabel Issue
« on: September 24, 2013, 05:30:08 PM »
I have three UILabels to display a recap at the end of a game. The only calls to these labels in my code is
labelName.text ="blah blah blah";

These three labels all use the same uifont/atlas so I am very confused on how this is even possible but once in a while this will happen.



As you can see the third label should say a number like 005 but it looks like this.

Anyone had this problem before or know what causes it?

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: UILabel Issue
« Reply #1 on: September 24, 2013, 06:22:12 PM »
Is that what it looks like in the editor or when you run the game?

Assuming you're using a dynamic font, occasionally as you are displaying new characters the character get added to the texture. If the texture ran out of space Unity will pump up the dimensions of the texture and the labels need to be refreshed with new UV coordinates.

If it is in the editor doing a save will usually refresh the panels and cause the geometry to be regenerated with the correct atlas. If this is happening in the game itself the UILabel's texture coordinates are not being updated properly. See if you can manually refresh the panel that it is located on UIPanel.Refresh().

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Issue
« Reply #2 on: September 24, 2013, 06:24:25 PM »
You need to use NGUI 3.0. All previous versions suffer from some issues with dynamic fonts when the texture gets enlarged, as Ferazel mentioned.

justinISO

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 52
    • View Profile
Re: UILabel Issue
« Reply #3 on: September 25, 2013, 04:43:58 PM »
Alright I have updated to NGUI 3.0 and haven't seen the bug yet.

However I have some now broken code that I cannot seem to fix. Specifically this line.

  1. UIAtlas.Sprite tmp = uiAtlas.spriteList [i];

This used to work fine but now the sprite list only seems to return UISpriteData how do I convert it to the UIAtlas.Sprite it used to be?

Thanks,
Justin

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Issue
« Reply #4 on: September 25, 2013, 07:01:04 PM »
You don't. There is no more UIAtlas.Sprite. It's only kept private for backwards compatibility. You need to work with UISpriteData now if you intend to modify it. On the plus side, it should be much more intuitive than UIAtlas.Sprite.

TriplePAF

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UILabel Issue
« Reply #5 on: September 30, 2013, 08:37:19 AM »
I'm currently converting some middleware components that are also using UIAtlas.Sprite. My question is what is the equivalent to UIAtlas.Sprite "outer Rect" and "inner Rect" in UISpriteData. My line of code is looking like this:

new Vector3(sprite.paddingLeft * sprite.inner.width, -sprite.paddingTop * sprite.outer.height, 0);

Kind regards,

Peter Fonk.

Should I have started my own topic about this subject?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Issue
« Reply #6 on: September 30, 2013, 11:35:53 AM »
Sprite padding values were 0-1 relative values, and now they are in pixels already, so no need to multiply by width/height anymore.

Outer rect is X, Y, width, and height of the sprite.

Inner rect doesn't exist anymore. It used to be something weird. Now you just have a border in pixels that you add to X and Y, and subtract from (X+width) and (Y+height).

TriplePAF

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UILabel Issue
« Reply #7 on: September 30, 2013, 11:38:22 AM »
That makes sense.  ;D

Thanks for answering my question.


Peter Fonk.