Author Topic: (problem) Objects stacking in grid  (Read 2352 times)

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
(problem) Objects stacking in grid
« on: February 26, 2014, 05:48:12 PM »
Hey all, I upgraded a project of mine from 2.x to 3.x today.  It took all day but more or less went off without too much issue.

The problem I'm having is probably due to not understanding all the new features, but I can't figure it out myself.
Basically I have a UIScroll View on a Panel, and a Grid child beneath it.  During runtime I instantiate a simple button prefab with three child labels under the Grid via the AddChild function, and this is the result:



And my Panel and Grid properties are like so, respectively:



I appreciate any help you can give!

dillrye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: (problem) Objects stacking in grid
« Reply #1 on: February 26, 2014, 06:05:46 PM »
Did you call Reposition() on the grid after adding the children?

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: (problem) Objects stacking in grid
« Reply #2 on: February 26, 2014, 06:29:12 PM »
Yes:

  1.                         UITable mTable = NGUITools.FindInParents<UITable>(childInstance.Value);
  2.                         if (mTable != null) {
  3.                                 mTable.repositionNow = true;
  4.                         }

Unless that's wrong!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: (problem) Objects stacking in grid
« Reply #3 on: February 27, 2014, 04:49:02 AM »
You're using a UIGrid, not a UITable. So the code is indeed wrong.

artician

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Re: (problem) Objects stacking in grid
« Reply #4 on: February 27, 2014, 09:59:41 AM »
That was it.  Thank you!

I was using someone else's code and thought they knew better than me, and that those functions were interchangeable.  It works now.

Much appreciated!