Author Topic: Setting / Getting position of UIDraggablePanel  (Read 9748 times)

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Setting / Getting position of UIDraggablePanel
« on: February 22, 2013, 08:15:08 PM »
Hello,

We are using the UIDraggablePanel class along with UIGrid and UICenterOnChild for a horizontal list of photos.

What I am needing to do is find out the current index of the list, and also be able to set the current index of the list since the photos are split into categories (e.g. the first 4 are category 1, the next 3 are category 2 etc.).  There are category buttons on the screen (similar to a toggle button group), and these need to take you to the index of the first photo of that category.  Also, if you drag the panel around, it should automatically switch the category based on which photo is centered.

Do you know of a simple way to achieve this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting / Getting position of UIDraggablePanel
« Reply #1 on: February 23, 2013, 02:13:18 AM »
Knowing the current position on the screen, run through your list's children and determine which one is the closest to the center. That's your index.

Wumpee

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 53
    • View Profile
Re: Setting / Getting position of UIDraggablePanel
« Reply #2 on: February 23, 2013, 02:58:28 AM »
Thanks ArenMook.

That's what I've ended up doing.  It'd be nice to have a helper class built into NGUI for this functionality also.

Maybe even if UIScrollBar had the ability to get a child count and set the index.