Author Topic: Ordering items in a horizontal scrollview.  (Read 5381 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Ordering items in a horizontal scrollview.
« on: April 06, 2014, 07:56:20 AM »
I've got the following:

ScrollView
   Grid (sorting horizontal)
      item1
      item2
      item3

Items are being added to the Grid dynamically.
In the scrollview, the items are being randomly displayed.  How to keep the ordering ?

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #1 on: April 06, 2014, 11:19:00 AM »
I changed it to Alphabetic and the ordering works based on the name of the item.

Only problem is that is scrollList that is Drag/Drop enabled and also needs to be able to drop elements back into itself.  That was why I needed the Ordering to be horizontal.  Perhaps I'm missing something.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #2 on: April 06, 2014, 01:35:59 PM »
Hierarchy view displays things in an alphabetic order. But when you iterate through list of transform's children, the order is not alphabetic. NGUI goes by the latter unless you turn on sorting. The drag & drop example has the grid sort items by their Y position, which makes drag & drop of items into place possible.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #3 on: April 06, 2014, 10:51:03 PM »
Ok, so which setting should I use if I want sorting to be alphabetic and be able to drag/drop items within the same scrollList.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #4 on: April 08, 2014, 12:32:02 AM »
It's one or the other. Either it's alphabetic, or it's based on position. You can't have both. You can first sort alphabetically, then switch the grid to use position-based sorting. But when you drop some item titled "Zeta" between "Alpha" and "Beta", that's exactly where it will stay as it will be based on its position.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #5 on: April 08, 2014, 11:47:33 PM »
Ok, understood, here's a use case:

1. order by alphabetic.
2. order by position, drop in other items.
3. exit game, when game starts, will the order be kept ? How to serialize the ordering positions ?
4. Is there support for serializing scrollList ordering data.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #6 on: April 09, 2014, 03:37:41 AM »
3. Nope. How would it? Where would the logic to keep the positions come from if you don't write it yourself?
4. Likewise no. Serialize what? Arbitrary data that got created dynamically? What's there to save? References to dynamically created data? This is Unity, not magic. :P

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #7 on: April 09, 2014, 06:31:04 AM »
Ok understood, I have to serialize it myself.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #8 on: April 09, 2014, 06:35:06 AM »
1. Ordering is by Position
2. How to get the 5th item in the Grid? 
3. Actually, ordering is any of the valid choices, how can we the 5th item in the grid?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Ordering items in a horizontal scrollview.
« Reply #9 on: April 10, 2014, 07:50:47 AM »
See my response in your other topic. In the future, one is enough. No point in duplicating questions.