Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: justinISO on September 24, 2013, 05:30:08 PM

Title: UILabel Issue
Post by: justinISO 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.

(http://i919.photobucket.com/albums/ad40/justinISO32/labelIssue_zps78b4cb9b.png) (http://s919.photobucket.com/user/justinISO32/media/labelIssue_zps78b4cb9b.png.html)

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?
Title: Re: UILabel Issue
Post by: Ferazel 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().
Title: Re: UILabel Issue
Post by: ArenMook 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.
Title: Re: UILabel Issue
Post by: justinISO 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
Title: Re: UILabel Issue
Post by: ArenMook 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.
Title: Re: UILabel Issue
Post by: TriplePAF 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?
Title: Re: UILabel Issue
Post by: ArenMook 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).
Title: Re: UILabel Issue
Post by: TriplePAF on September 30, 2013, 11:38:22 AM
That makes sense.  ;D

Thanks for answering my question.


Peter Fonk.