Author Topic: Adding children under UIDraggable panel at runtime  (Read 1863 times)

superbsumit

  • Guest
Adding children under UIDraggable panel at runtime
« on: September 23, 2013, 02:57:05 AM »
Hi

Here is my situation - I have a UIDraggable panel with UITable script on it.

So till now everything works fine, when I am adding some gameObject's as a children to the UIDraggable panel, and then reposition the UITable afterwords( to make all the children's separated from each other). This adding as a child is done at runtime using NGUITools.AddChild().

Now the problem occurs when I have to add some children at the top of the UI table and some at bottom, as previously all the children's were added at the bottom only. Here's what I wanna achieve :

Lets assume that this is my UIDraggable panel with 2, 3 and 4 as panel's children :
2
3
4

Now Lets say I have to add 6 at the bottom of the table like this:

2
3
4
6

And then add 5 and 7 at the top of the table like this:
7
5
2
3
4
6

The bottom one can be added easily according to my current flow, but the top one make some issues for me. Please help me here, as I am kinds stuck here.
I don't find anything under NGUITools.AddChild() to solve this for me.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Adding children under UIDraggable panel at runtime
« Reply #1 on: September 23, 2013, 07:16:16 AM »
You need to turn on alphabetic sorting on the table, and you need to name your children accordingly in a sequence you want them to appear -- 001, 002, 003, etc.