Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: rganeyev on October 02, 2012, 07:59:26 AM

Title: Grid pageview
Post by: rganeyev 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?

Title: Re: Grid pageview
Post by: Nicki 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.
Title: Re: Grid pageview
Post by: rganeyev 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?
Title: Re: Grid pageview
Post by: Nicki 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.
Title: Re: Grid pageview
Post by: rganeyev 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.
Title: Re: Grid pageview
Post by: ArenMook 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.
Title: Re: Grid pageview
Post by: rganeyev 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?
Title: Re: Grid pageview
Post by: ArenMook 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.
Title: Re: Grid pageview
Post by: rganeyev on October 11, 2012, 09:09:58 AM
Ouch, yes, it works well. Thank you!