Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pretender on August 31, 2012, 09:57:07 AM

Title: sorting the elements in the grid?
Post by: pretender on August 31, 2012, 09:57:07 AM
Hi!

I am adding children to grid element by code. it seems that they are not sorted in sequence
checking/unchecking "sort" in the UIGrid gives different result but not in the sequence i have this list. i made the list public
so i can see what order elements are in the list. it seems alse that in both ways ("sort" checked or not) it does take into account
game object names that are added to the Grid element (elements beginning with "a" get displayed first...)

can i resolve this somehow, maybe using table instead of grid?
Title: Re: sorting the elements in the grid?
Post by: AndyGFX on August 31, 2012, 10:05:03 AM
I had similar problem, look here.  http://www.tasharen.com/forum/index.php?topic=1511.msg7812#msg7812 (http://www.tasharen.com/forum/index.php?topic=1511.msg7812#msg7812)
Title: Re: sorting the elements in the grid?
Post by: Rafe on September 04, 2012, 12:30:31 AM
It would be extremely helpful to have the Grid (or a new component) provide a list interface (Add(), Remove(), RemoveAt(), Insert(), etc) and maintain order. I'm writing a lot of extra code to keep numbers in front of names as I add and remove items.
Title: Re: sorting the elements in the grid?
Post by: ArenMook on September 04, 2012, 01:01:24 AM
Hmm... useful suggestion, thanks.
Title: Re: sorting the elements in the grid?
Post by: ENAY on September 04, 2012, 01:14:44 AM
Thanks for that link, made for interesting reading. This was a similiar situation I was having, duplicating a list of items in code. The order was unpredictable, as was reposition. On iPhone the contents were backwards.

As a 'quick' fix I resorted to sorting them manually myself just to be sure they would work across all platforms.

Unity seems to be particularly random at sorting created items any. You only have to do a GetComponentsInChildren search on a menu object and see the order stuff is sorted in. It makes for interesting peeking.
Title: Re: sorting the elements in the grid?
Post by: dlewis on September 04, 2012, 06:55:12 AM
I'm writing a lot of extra code to keep numbers in front of names as I add and remove items.

I'm doing the exact same thing ;)
Title: Re: sorting the elements in the grid?
Post by: pretender on September 11, 2012, 08:56:54 AM
Hi!

So how guys you resolve this issue?
Currently i am writing numbers to maintain the order but it seems that it does not work well.
Any advice on this?

Thanks!
Title: Re: sorting the elements in the grid?
Post by: ArenMook on September 11, 2012, 10:08:47 AM
Numbers must be in the form of 0001 0002 etc, not 1 2 3, because string comparisons think 10 is lower than 2 (but 10 would be higher than 02).
Title: Re: sorting the elements in the grid?
Post by: will_brett on September 17, 2013, 11:42:41 AM
I know this is an old thread, but did a solution ever get made? There are many instances that I would love to use the grid but the ordering is a problem. I would add numbers to each object in the grid, but the objects are being added throughout the game from different players over the network and the code is getting longer and more complex than it needs to be.
Title: Re: sorting the elements in the grid?
Post by: ArenMook on September 17, 2013, 02:40:15 PM
I suggest just write your own grid component if you need to control the order in which objects appear, and not using UIGrid.