Welcome,
Guest
. Please
login
or
register
.
April 30, 2026, 01:39:39 PM
Home
Help
Search
Login
Register
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIGrid sorting in editor but not on iOS...
« previous
next »
Print
Pages: [
1
]
Author
Topic: UIGrid sorting in editor but not on iOS... (Read 3437 times)
JRufer
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 3
UIGrid sorting in editor but not on iOS...
«
on:
September 27, 2013, 01:54:40 PM »
I have a UIGrid to display an ordered list of items. When I view it in the editor, they are sorted correctrly but when I run the compiled app on my iPad, the items are out of order. My code for loading the grid is below. Any help would be appreciated.
for
(
int
i
=
0
;
i
<
items
.
Length
;
i
++
)
{
string
itemKey
=
items
[
i
]
;
string
gameObjectName
=
itemKey
.
Substring
(
sessionID
.
Length
)
;
Debug
.
LogError
(
"real key = "
+
gameObjectName
)
;
ItemState state
=
GameObject
.
Find
(
gameObjectName
)
.
GetComponent
<
ItemState
>
(
)
;
state
.
LogValues
(
)
;
if
(
showUnaltered
==
true
||
altered
==
true
)
{
GameObject row
=
NGUITools
.
AddChild
(
ListParent, ListItemPrefab
)
;
row
.
name
=
i
.
ToString
(
)
.
PadLeft
(
8
,
'0'
)
;;
populateRow
(
state, row, forReview, i
)
;
}
}
UIGrid grid
=
ListParent
.
GetComponent
<
UIGrid
>
(
)
;
grid
.
cellHeight
=
175
;
grid
.
repositionNow
=
true
;
Logged
Nicki
Global Moderator
Hero Member
Thank You
-Given: 33
-Receive: 141
Posts: 1,768
Re: UIGrid sorting in editor but not on iOS...
«
Reply #1 on:
September 27, 2013, 02:10:42 PM »
If the grid isnot set to sorted, it should position the children after when they were added.
If you put it to sorted, it's by game object name. I recommend you name your gameobjects and set it to sorted so you get control.
Logged
JRufer
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 3
Re: UIGrid sorting in editor but not on iOS...
«
Reply #2 on:
September 27, 2013, 02:37:09 PM »
Thanks for the quick reply. The UIGrid is set to sorted and in the loop I am renaming the rows with 0 padded numbers. This is what made it work in the editor. What I don't know is why they are not sorted on the target device.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIGrid sorting in editor but not on iOS...
«
Reply #3 on:
September 27, 2013, 06:24:02 PM »
My guess is your renaming happens after the UIGrid sorts everything. You might want to tell it to re-sort everything after you're done renaming stuff.
Logged
JRufer
Newbie
Thank You
-Given: 0
-Receive: 0
Posts: 3
Re: UIGrid sorting in editor but not on iOS...
«
Reply #4 on:
September 27, 2013, 06:49:27 PM »
I could programmatically call sort after all the children are added but the public sort property seems to take care of that, even for dynamically added children. The grid is always sorted in the editor. I can't figure out what is going wrong in the deliverable.
Logged
ArenMook
Administrator
Hero Member
Thank You
-Given: 337
-Receive: 1171
Posts: 22,128
Toronto, Canada
Re: UIGrid sorting in editor but not on iOS...
«
Reply #5 on:
September 27, 2013, 07:08:55 PM »
As I said, double-check the order in which things get called. It may not be the same order as in the editor. To be safe, always sort after renaming things.
Logged
Print
Pages: [
1
]
« previous
next »
Tasharen Entertainment Forum
»
Support
»
NGUI 3 Support
»
UIGrid sorting in editor but not on iOS...