Author Topic: UILabel "vibrates" all the time  (Read 6961 times)

taorui

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UILabel "vibrates" all the time
« on: July 23, 2015, 04:06:40 AM »
Hi,
I recently updated NGUI from 3.7.9 to 3.9.0b on Unity4.6.7f1 and I found some UILabels in my project became "vibrating", which means their widths (or maybe locations) change all the time and never stop.
All these "vibrating" labels are using dynamic font, set as ResizeFreely, and using Advanced anchor like only set Left anchor to its neighbor.

You can see this in following steps in a new project:
1. create an UIWidget container and add an UISprite as a child, set its anchors as Unified to the container.
2. create an UILabel (say label1), use font: "Fantasy Font - Normal" in NGUI example, input some text, set it ResizeFreely, and only set its left anchor to UISprite's right side. Anchor executes "OnUpdate".
3. create another UILabel(say label2), do same thing to label2 and set its left anchor to label1's right side.
4. run game and you may see label1 and/or label2 are "vibrating". If not, try to modify label1's left anchor's distance to UISprite.
5. it's easier to happen if sets text every frame in Update().

I'm not sure what causes this but when I tried to check the diff between these two versions, I found that two lines are added in UIWidget.cs (line 1213~1214 in OnAnchor()), which rounds up newPos.x and newPos.y. And if I commented them out, then "vibrating" disappears and UILabel works as usual.

I would like to ask how to solve this problem, or just I shouldn't use UILabel in such a way?
Thank you.
« Last Edit: July 23, 2015, 04:53:01 AM by taorui »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #1 on: July 24, 2015, 10:39:13 AM »
You need to set your pivot properly. If something is anchored to the left side, set the pivot to be on the left as well. You likely left it in the center, which is why you are running into this issue.

taorui

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #2 on: July 26, 2015, 08:48:32 PM »
Thank you very much for the reply, I will review the pivots. ;)

doncarlos91

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #3 on: July 28, 2015, 08:51:53 AM »
Hi, i have a same issue, although my Anchors and Pivot settings are -- correct.
Can you suggest some another solution ?

Thanks in advance..

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #4 on: July 28, 2015, 06:47:21 PM »
Only way a widget will "vibrate" is if your anchoring causes widget size to use numbers not dividable by two and you happen to be moving it. For example width of 117 will cause an issue, while 118 will not.

doncarlos91

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #5 on: July 29, 2015, 09:16:55 AM »
Thanks for your answer , but unfortunately it did not help me.
i`m using 3.7.2 version

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #6 on: July 31, 2015, 09:39:11 PM »
I'm sorry, 3.7.2 is very old. You should update before seeking support as I can only help you with up to date versions.

doncarlos91

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #7 on: August 03, 2015, 08:28:41 AM »
Hi , thanks for your reply, i already updated NGUI to 3.9.0  version, but unfortunately the issue persists :)

doncarlos91

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 27
    • View Profile
Re: UILabel "vibrates" all the time
« Reply #8 on: August 05, 2015, 02:57:56 AM »
I have  changed my font extension from .otf to .ttf - and it worked well