Author Topic: Only rendering N characters in a Label?  (Read 7010 times)

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Only rendering N characters in a Label?
« Reply #15 on: April 30, 2014, 05:22:03 AM »
I think I see what you are saying now, you want the text to pop out as it does now, as if it were left assigned, except you want the full length of the word to be right aligned when it has finished?
Well what I would do is keep the UILabel left aligned, but adjust its transform in the X direction to the right side. First position the UILabel at the right side of where you want it and then use the UILabels 'printedSize' and subtract that from that position. In other words, you make a script which moves the UILabel according to the words text size.

I am still not 100% sure if that is what you are trying to achieve, but I hope this helps.

Thanks for the feedback Enay,

I guess I should have mentioned that this needs to work with multi-line labels too, so left justifying and adjusting the label position wouldn't work in our case =/

I tried modifying the UILabel.OnFill method to get it to only draw a maximum number of characters so that I could reveal the label slowly, but even that isn't working - it exhibits the same issue of growing out from the right side of the label.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Only rendering N characters in a Label?
« Reply #16 on: April 30, 2014, 05:24:16 PM »
Instead of filling characters slowly, simply adjust the alpha of the characters in your OnFill function. This way the characters will already be there, positioned properly. You will simply be "revealing" them gradually.

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Only rendering N characters in a Label?
« Reply #17 on: April 30, 2014, 05:44:25 PM »
Instead of filling characters slowly, simply adjust the alpha of the characters in your OnFill function. This way the characters will already be there, positioned properly. You will simply be "revealing" them gradually.

Thanks ArenMook.

Will this need to be done in the OnFill or the NGUIText.Print method which is called from OnFill? If I modify the tint in NGUIText.Print, it seems to work, but only for certain labels.

I'd really appreciate a more direct example if you have a minute to spare.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Only rendering N characters in a Label?
« Reply #18 on: April 30, 2014, 06:12:04 PM »
You would do it in your custom version of UILabel.OnFill. Just derive from UILabel and override that function. Call base.OnFill, then modify the alpha of the color array as needed. Note that you will also need to mark the widget as changing via MarkAsChanged() frequently, or OnFill will not be called again.