Author Topic: UI Input Bug NGUI 3.0  (Read 6541 times)

Anahit

  • Guest
UI Input Bug NGUI 3.0
« on: September 24, 2013, 07:04:54 AM »
Hi There,

I've been working with UI Input which is Linked to the label I wish to alter.

Within Editor I'm setting the Max characters in UI Input and the Max Lines within UILabel.

Although when I click the Label within the running scene it is reseting the UILabel.MaxLines back to 1.

This is due to UIInput.Init setting the maxLinecount

  1.        
  2. protected void Init ()
  3.         {
  4.                 if (mDoInit)
  5.                 {
  6.                         mDoInit = false;
  7.                         if (label == null) label = GetComponentInChildren<UILabel>();
  8.  
  9.                         if (label != null)
  10.                         {
  11.                                 if (useLabelTextAtStart) mText = label.text;
  12.                                 mDefaultText = label.text;
  13.                                 mDefaultColor = label.color;
  14.                                 label.supportEncoding = false;
  15.                                 label.password = isPassword;
  16.                                 label.maxLineCount = 1;
  17.                                 mPivot = label.pivot;
  18.                                 mPosition = label.cachedTransform.localPosition.x;
  19.                         }
  20.                         else enabled = false;
  21.                 }
  22.         }
  23.  

This should probably set label.maxLineCount to the currently set maxLineCount so it doesn't reset on UIInput Init.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Input Bug NGUI 3.0
« Reply #1 on: September 24, 2013, 09:26:04 AM »
What's the bug here though? Max lines being set to 1 is intentional due to how the input works right now. If you remove that line the label won't auto-scroll to the right side as you type past the bounds.

Anahit

  • Guest
Re: UI Input Bug NGUI 3.0
« Reply #2 on: September 24, 2013, 09:32:28 AM »
I've got a UILabel for a description box that I want to stay a set width, I don't want it to scroll out of the box to the right. When it hits the width of the text box, I want it to go down on to the next line, if MaxLines is set to one, this causes it to scroll of the right of the UILabel. So I need to set MaxLines to anything but 1.

Currently I've just commented out label.maxLineCount = 1 and it's solved my issue. I just felt that it shouldn't automatically get set to 1.


BGL

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UI Input Bug NGUI 3.0
« Reply #3 on: October 09, 2013, 06:42:59 AM »
I got a similar issue because of the label.maxLineCount = 1;
I want my label to ShrinkToFit when the user types too much text, but this works only if maxLineCount is equal to 0.
I think that preventing to use the UIInput in different way is a bit too much restrictive.
What do you think about have an editor option like "Scroll text on overflow" that will force the maxLineCount to 1.
When this value is false, simply allow the UILabel to use its value of maxLineCount.
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Input Bug NGUI 3.0
« Reply #4 on: October 09, 2013, 07:27:23 AM »
UIInput is very restrictive anyway, and is scheduled to be re-designed in the near future. For the time being it's meant to work with a single line input.