Author Topic: UILabel chat question  (Read 1732 times)

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
UILabel chat question
« on: December 04, 2013, 10:43:10 AM »
Hello. I need a chat. And I made it according to the example in NGUI 2.7. But i need to scroll it when the length of message is bigger than chat panel. I can do it by wheel on PC but cant on Android by finger. How can I scroll chat window with finger?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel chat question
« Reply #1 on: December 04, 2013, 11:21:23 AM »
Add the following function to the UITextList:
  1.         void OnDrag (Vector2 delta)
  2.         {
  3.                 if (textLabel != null)
  4.                 {
  5.                         float val = delta.y * ((style == Style.Chat) ? -1f / textLabel.fontSize : 1f / textLabel.fontSize);
  6.                         mScroll = Mathf.Max(0f, mScroll + val);
  7.                         UpdateVisibleText();
  8.                 }
  9.         }

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: UILabel chat question
« Reply #2 on: December 04, 2013, 11:37:14 AM »
An error: "Assets/NGUI/Scripts/UI/UITextList.cs(132,76): error CS1061: Type `UILabel' does not contain a definition for `fontSize' and no extension method `fontSize' of type `UILabel' could be found (are you missing a using directive or an assembly reference?)"

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel chat question
« Reply #3 on: December 04, 2013, 03:01:53 PM »
Ah, 2.7... yeah that  one won't have font size. You can use bitmapFont.size instead I think. Currently the latest of the 3.X cycle that's in the Professional repository has an improved text list script that adds both touch and scroll bar support.