Author Topic: UITable elements  (Read 4363 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
UITable elements
« on: June 19, 2012, 04:14:35 AM »
Hi,

Is there a way to retrieve the list of children of a UITable ? I mean, I could just do a loop on the children of the Transform, but I want them in the same order as sorted by the UITable.

When I do : for (int i = 0; i < friendTable.GetChildCount(); i++)
I retrieve Friend 01, Friend 06, Friend 05 etc...

Thanks.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UITable elements
« Reply #1 on: June 19, 2012, 04:43:03 AM »
Getting the true order is actually quite tricky, as if I recall. They are stored in the order that they are created.

What I did was search for the list once and make a tag.

Then you can just refer to each of your elements as a string instead of an array number.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UITable elements
« Reply #2 on: June 19, 2012, 04:57:18 AM »
Thanks for the answer,

Yes I could do that, but let's say I get all my Facebook friends score (not sorted), so the order they are created is wrong. Then UITable sort them right (because I named them Friend - Score for example). If I could retrieve the sorted list, I would not have to re-do the same work that's already been done by UITable.

PhilipC

  • Guest
Re: UITable elements
« Reply #3 on: June 19, 2012, 08:32:08 AM »
The sorted list the UITables uses is only a local function (Reposition) variable. So no there is no way to get this sorted list you would have to resort yourself.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UITable elements
« Reply #4 on: June 19, 2012, 08:33:48 AM »
Hum, okay, but I mean, you could in NGUI add something like an array of Transform or something like that.

But thanks for the answer !

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable elements
« Reply #5 on: June 19, 2012, 12:17:03 PM »
Yeah there is simply no way to change the order in which Unity keeps their transforms as far as I know. The sorting in UITable is done in the Reposition() function as Phil mentioned, and it's local and temporary.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UITable elements
« Reply #6 on: June 20, 2012, 03:41:48 AM »
I do not want to insist or seems insistent, but you're saying that the Reposition() function is local and temporary, I'm just saying that maybe it could be public and not-temporary :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable elements
« Reply #7 on: June 20, 2012, 12:11:05 PM »
Good idea. I've done just that. You will see UITable.children in the next update.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UITable elements
« Reply #8 on: June 20, 2012, 12:13:14 PM »
Awesome !

Thanks :)