Author Topic: Grid pageview  (Read 6521 times)

rganeyev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Grid pageview
« on: October 02, 2012, 07:59:26 AM »
Hi all. I want to implement pageview: scrollable grid with buttons on it, like ios/android menu table with N * M buttons.
and if items count is large, you can scroll left/right to get to next page.

I tried to implement it myself using uitable, but it only scrolls up/down & i can't make it behave like a scrolling to other page.
Is there any common solution to that problem?


Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Grid pageview
« Reply #1 on: October 02, 2012, 11:31:49 AM »
Look into UICenterOnChild, then you can make children that are a page big and it will work like a paged scrollview.

If you want to scroll other than up and down, look at the inspector for the dragpanel and set the scale in the script on Y axis as well.

rganeyev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Grid pageview
« Reply #2 on: October 03, 2012, 05:59:54 AM »
Nicki, thank you for ur reply, but I can't understand how to implement this.

Assume, we have a page of 3x3 elements prefab(9 elements in one page).
Every button in page has a collider inside, so we can tap and OnClick method will be invoked.
And we have collider on prefab to make it scrollable - let me call it mainCollider.

And we have a scrollview based on panels as shown in examples.
If button collider overlaps mainCollider, i can't normally scroll, otherwise I can't tap on buttons.
How to deal with that?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Grid pageview
« Reply #3 on: October 04, 2012, 03:06:08 PM »
Your elements need to have a UIDragPanelContents component on it to catch the drags, and the elements need to be closer to the camera than the mainCollider.

rganeyev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Grid pageview
« Reply #4 on: October 05, 2012, 02:50:42 AM »
I tried to do that, but i can't scroll touching buttons, because button collider will be hit and OnClick action wil be invoked.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Grid pageview
« Reply #5 on: October 05, 2012, 09:23:56 AM »
In the quest log example you can both tap on the quest logs to expand/shrink them, and drag the scroll view around by holding the tap.

rganeyev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Grid pageview
« Reply #6 on: October 10, 2012, 09:26:02 AM »
Well, it's ok, buttons inside work well, but... I want grid! Grid with 3x3 buttons inside!
If i make like u said, I need to make one gameobject with main collider and put 9 buttons in it. But in this case that button never gonna be invoked, because maincollider will  get all touches and buttons never get them.

Did I miss something? What am I doing wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Grid pageview
« Reply #7 on: October 10, 2012, 09:33:00 AM »
You don't need some "main" collider. You need a collider on the "summary" label that shrinks / hides the children just like in the quest example. What's underneath it doesn't matter. You can put any number of widgets there, with colliders or without.

rganeyev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Grid pageview
« Reply #8 on: October 11, 2012, 09:09:58 AM »
Ouch, yes, it works well. Thank you!