Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started 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?
-
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.
-
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?
-
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.
-
I tried to do that, but i can't scroll touching buttons, because button collider will be hit and OnClick action wil be invoked.
-
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.
-
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?
-
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.
-
Ouch, yes, it works well. Thank you!