Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: laurentl on September 30, 2013, 09:34:25 PM

Title: UITable pushing widgets down
Post by: laurentl on September 30, 2013, 09:34:25 PM
I am using UITable to create dynamically a group of tabs that are aligned either horizontally or vertically.

Each tab is made up of about 5 sprites and a texture.

When a new item appears, the sprite that says "NEW" is enabled and that sprite appears above the tab.

When that happens, the NEW tab get's pushed on the Y axis like so:
https://www.youtube.com/watch?v=qZls9tT61MM

Why is that?
Title: Re: UITable pushing widgets down
Post by: ArenMook on October 01, 2013, 07:23:42 PM
I vaguely remember there being a bug in the table with the "up" type table alignment. It supposed to be pushed up, not pushed down. I am not sure if it was ever fixed in 3.0, come to think of it...

Any particular reason you don't just use a UIGrid here instead?
Title: Re: UITable pushing widgets down
Post by: ArenMook on October 01, 2013, 08:06:11 PM
Yup, confirmed to be still bugged in 3.0. Here's how to fix it. Open up UITable, line 125. The statement currently reads:
  1.                         if (direction == Direction.Down)
  2.                         {
  3.                                 pos.y = -yOffset - b.extents.y - b.center.y;
  4.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  5.                         }
  6.                         else
  7.                         {
  8.                                 pos.y = yOffset + b.extents.y - b.center.y;
  9.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  10.                         }
And it should be:
  1.                         if (direction == Direction.Down)
  2.                         {
  3.                                 pos.y = -yOffset - b.extents.y - b.center.y;
  4.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  5.                         }
  6.                         else
  7.                         {
  8.                                 pos.y = yOffset + (b.extents.y - b.center.y);
  9.                                 pos.y -= (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  10.                         }