Author Topic: Inset widget with dynamic height weird drifting position bugs  (Read 5976 times)

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Inset widget with dynamic height weird drifting position bugs
« on: October 16, 2014, 08:27:47 PM »
I'm trying to build an inset widget (let's call it InsetWidget) much like what is described on the UIRect documentation, but designed such that the inner widget is a UILabel that resizes its height based on the text. As the inset UILabel expands, the outer containing UIWidget should also expand.

I've been able to create this by having the UILabel not anchor its bottom, and having the containing UIWidget anchor its bottom to the bottom of the inset UILabel.

Unfortunately I'm getting very weird bugs where this InsetWidget's height is drifting slowly larger. I've also on re-running seen an issue where the height of the UILabel was going back and forth between a negative and positive value, causing the whole thing to wobble.

Is this a legitimate way to build this sort of Widget or will doing this always lead to problems?

(As well these widgets are being added to a UITable if that means anything. I haven't yet tested how this runs outside of that situation)

Running NGUI 3.5.5

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Inset widget with dynamic height weird drifting position bugs
« Reply #1 on: October 17, 2014, 05:10:08 AM »
1. Update your NGUI. Because... bug fixes.
2. Make a label -- ALT+SHIFT+L. Set it to resize freely instead of shrink content.
3. Add a child sprite to it -- ALT+SHIFT+S, change its depth to be label's depth -1. Resize it to cover the label as you want it to be.
4. Enable Unified anchoring on the sprite. It will automatically anchor to the label.
5. Now select the label and type something. The sprite will resize automatically.

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: Inset widget with dynamic height weird drifting position bugs
« Reply #2 on: October 20, 2014, 07:54:19 PM »
Ok that worked thanks.

I'd love to upgrade NGUI, but we're in the thick of things at the moment and I'm really not able to risk having some sort of compatibility problem.

It's a shame that Unity doesn't have a better upgrade system that would allow you to roll back in case something goes wrong.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Inset widget with dynamic height weird drifting position bugs
« Reply #3 on: October 20, 2014, 11:51:45 PM »
Unity doesn't need it. You can easily set up a git repository and revert back if something goes wrong. There is no reason to work without a repository set up, regardless of what you're doing.

Tiktaalik

  • Newbie
  • *
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 39
    • View Profile
Re: Inset widget with dynamic height weird drifting position bugs
« Reply #4 on: October 21, 2014, 02:27:10 AM »
Of course you're right. We have source control so we could easily roll back.