Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: appminis-mike on March 05, 2014, 08:45:26 PM

Title: UITable not spacing resized items properly
Post by: appminis-mike on March 05, 2014, 08:45:26 PM
I'm adding some elements to a UITable (using NGUITools.AddChild), and I set their heights according to their needs of their contents. After all of this, I call the UITable's Reposition() function. However, the elements are not spaced properly. There are large gaps between them, as though the table still thinks they are their original size. I have the table's padding set to 6, so I would expect only 6 pixels of gap between them, but there is much, much more.

What might cause this behavior?

Thank you.
Title: Re: UITable not spacing resized items properly
Post by: ArenMook on March 06, 2014, 10:46:54 AM
You set heights of what, exactly? And what's the structure of what you're instantiating via AddChild?
Title: Re: UITable not spacing resized items properly
Post by: appminis-mike on March 06, 2014, 11:31:25 AM
They're prefabs with UIWidget scripts on them, and child elements with other UIWidgets, UILabels, and UISprites. I'm setting the height of the top level UIWidgets.

It looks like this:

Element (UIWidget)
  Background (UIWidget)
    Sprite (UISprite)
  Title (UILabel)
  Description (UILabel)

where Element.height is what I'm setting, and I'm adding an arbitrary number of those to the UITable.
Title: Re: UITable not spacing resized items properly
Post by: ArenMook on March 06, 2014, 11:57:39 AM
Are they anchored? Anchors won't update until later, unless you explicitly call UpdateAnchors() on all the widgets (you can gameObject.BroadcastMessage it).
Title: Re: UITable not spacing resized items properly
Post by: appminis-mike on March 06, 2014, 12:10:43 PM
Element is not anchored, and it is being sized properly (I can see the borders in the scene view). Its children are, though, and I tried calling gameObject.BroadcastMessage("UpdateAnchors"), but that didn't help. Everything looks to be sizing properly, it's just the positions within the UITable that are off.
Title: Re: UITable not spacing resized items properly
Post by: ArenMook on March 07, 2014, 10:37:16 AM
Calling UpdateAnchors should immediately update the position of everything, and the table considers the bounds of all the children underneath your "Element" widget when calculating the final bounds. If you can't figure this out, I can have a look if you give me a small repro case (just don't post it here -- email to support at tasharen.com).