- Home /
How can I have a UI ScrollRect still scroll if pressing a button inside of it?
I've built a simple UI scene where players can switch the language of the game, and it's in a scrolling list because there are many languages to choose from.
The hierarchy is ScrollRect > Panel (background image) > List of Buttons.
Now, if I tap on a button, it works fine and changes the language as expected. If I tap and drag anywhere around the buttons (on the background panel), the scroll rect scrolls up and down, again as expected . The problem is that it's impossible to tap and drag from inside a button, the scroll rect just won't work in that case, and it feels like bad UX. The desired behaviour is that if I tap and drag inside a button, the OnClick of the button is cancelled, and the scrollrect begins to scroll. How can I accomplish this?
well this is weird because i have an application with a scrollRect handling a vertical panel of UI buttons and I have the right behaviour. I also created a simple scene with a scroll rect containing a panel containing several buttons and every is working fine... Try to recreate your bug with a simple display or provide screenshots of your actual setup.
Ah thanks so much @Nerevar you made me realize it's because of some custom code I added. For anyone who ends up encountering this, it was due to me having added an EventTrigger to the button, via code. It seems these custom handlers (for OnPointerUp, OnPointerDown, etc.) somehow interfere with Unity's input forwarding and breaks things!
Answer by m_fawadzahid · Oct 14, 2016 at 09:44 AM
Sorry but i dont seem to get it .... i am facing the same problem having a horizontal scrollrect > panel > button ... i have added drag event via EventTrigger on the button ... what i need is that the scroll drags if drag is horizontal and the button drags if drag is vertical from the button