Author Topic: UILabel  (Read 174101 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #90 on: June 21, 2014, 04:08:33 PM »
Positive. Widget's pivot point is what changes the text's vertical alignment. Try it -- new scene, ALT+SHIFT+L, resize it so that it's large in size then change the widget's pivot to top.

Fractalbase

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #91 on: June 21, 2014, 04:25:40 PM »
I've having an issue with the Overflow setting.  The default is shrink content.  I want clamp content.  However, only 1 line of all of the lines in the text are shown.  While the game is running, if I select either of the resize options, the setting goes back to shrink content, but all of the lines of text are properly displayed.  Any ideas?

Fractalbase

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #92 on: June 21, 2014, 04:43:06 PM »
Regarding vertical alignment, I figured out the issue.  The Anchors of UILabel for "Bottom" and "Top" must be set to "Target's Bottom" and "Target's Top" (respectively) in order for the vertical alignment to work.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #93 on: June 21, 2014, 07:55:44 PM »
If the widget is anchored on all sides, then it must assume the "Shrink" method. When the label's resize setting goes up against anchors, anchors win. Only one can adjust the height. Not both.

If you want to anchor the label and still have it auto-resize itself, then don't anchor both sides. For example, for Resize Height to work, anchor the Top side, but leave the Bottom not anchored.

dkozlovtsev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 35
    • View Profile
Re: UILabel
« Reply #94 on: July 04, 2014, 07:50:16 AM »
NGUIText.PrintCharacterPositions can be used to determine the positions of all characters. You can use it to position your sprite. Just don't forget to call label.UpdateNGUIText() prior to calling that function.

UILabel.ApplyOffset is also needed to properly determine glyth position to place sprite on it, but it is protected, can it be made public? currently the only way is to change code or derive from UILabel and i would like to avoid both.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #95 on: July 04, 2014, 03:02:09 PM »
Certainly.

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Re: UILabel
« Reply #96 on: July 08, 2014, 06:47:00 AM »
Where do I have to look to see NGUIText.ParseSymbol? Or all BBCode commands?
In particular, I need to make break lines.
Thank you.


BBcode style:

[b]bold[/b]
[i]italic[/i]
[u]underline[/u]
[s]strikethrough[/s]

...etc. Look inside NGUIText.ParseSymbol.
Game developer on Casual Arena.

Fractalbase

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #97 on: July 08, 2014, 07:03:29 AM »
To break lines (make multiple lines), all you have to do is insert a carriage return character : '\n'

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #98 on: July 08, 2014, 01:25:50 PM »
@Tatanan: NGUIText.ParseSymbol is a function. NGUI comes with full source code -- you can view it when you need it. The full list is b, i, u, s, sub, sup, url, color tags (RrGgBb, RrGgBbAa), and alpha tags (Aa).

Bypp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UILabel
« Reply #99 on: July 14, 2014, 09:26:13 AM »
Hello ! Quick question concerning label text size. When I set a size for the text and set tit to shrink in case of overflow, is there a way to set the maximum size of my text ? I don't want a small amount of text to appear huge ! So I'd just set a maximum size for that case !

Is this possible ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #100 on: July 15, 2014, 12:58:57 AM »
The font size specified on the labels is the maximum font size. NGUI won't grow this value, only shrink it.

Bypp

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UILabel
« Reply #101 on: July 18, 2014, 10:36:31 AM »
All I see is the relative size ! Thing is, I need to support many resolutions and that size depends (I'm also using fonts with different sized atlases, which might affect the final result), and setting that relative size to say 0.5 works well to some extent, but on a Kindle Fire device, the text will be considerable smaller, and on PC versions, the text will still grow pretty large unless I drastically reduce relative size. Is there a way to manually calculate that size depending on resolution ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #102 on: July 19, 2014, 12:46:51 PM »
Relative size? Are you using NGUI 2? There is no such thing in NGUI 3. You specify the font size on the labels themselves.

Tulrath

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UILabel
« Reply #103 on: September 03, 2014, 04:17:25 PM »
Aren,

When I set the top or bottom gradient color from code, the color value doesn't seem to be getting set correctly.


...here is the code...


  1. UILabel label = GetComponent<UILabel>();
  2. label.gradientTop = new Color(255f,220f,0);
  3. label.gradientBottom = new Color(255f,0,0);
  4.  

...but when this runs, the color values seem to get "re-scaled" to a value between 0 and 65025, which results (apparently) in them not being considered correct colors, or just being ignored. 

At runtime if I then try to change the color values in the color gadget in the Unity Inspector to the proper RGB values, I get (in this example) a nice red-to-orange gradient as expected.  But when I set them through code, I get these "squared" values and the text just appears white.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #104 on: September 04, 2014, 11:09:40 AM »
That's because Color values range from 0 to 1, not 0 to 255.

If you want to use 0 to 255, use Color32.