Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: elvess on December 04, 2013, 10:43:10 AM

Title: UILabel chat question
Post by: elvess 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?
Title: Re: UILabel chat question
Post by: ArenMook 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.         }
Title: Re: UILabel chat question
Post by: elvess 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?)"
Title: Re: UILabel chat question
Post by: ArenMook 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.