Author Topic: Content driven label size with min/max pixel size  (Read 10057 times)

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Content driven label size with min/max pixel size
« on: September 11, 2016, 11:38:11 PM »
I've been struggling to find a way to get this to work. I can have "resize freely" or "clamp content", but there is no option that lets allows both.

I could just set it to a fixed size of 300, but I need the label to grow/shrink due to having a background sprite anchored to it.

(NGUIText.GetEndOfLineThatFits is almost what I need (with some extra custom code), but it's giving the wrong side of the string.)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Content driven label size with min/max pixel size
« Reply #1 on: September 13, 2016, 11:07:15 AM »
NGUIText calls are context sensitive. You must first set what you're working with before using any NGUIText call. For example, label.UpdateNGUIText(), then use NGUIText.GetEndOfLineThatFits.

Wisteso

  • Full Member
  • ***
  • Thank You
  • -Given: 21
  • -Receive: 3
  • Posts: 103
    • View Profile
Re: Content driven label size with min/max pixel size
« Reply #2 on: September 13, 2016, 12:36:27 PM »
The problem is I would need something like "NGUIText.GetStartOfLineThatFits" but that doesn't exist, and with all the context stuff it's pretty messy to to add it anywhere besides the same class.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Content driven label size with min/max pixel size
« Reply #3 on: September 17, 2016, 12:17:02 AM »
What would that do? Start of line that fits is just the beginning of the text line. The end of line that fits is used to determine where the line should wrap.