- Home /
in 4.6RC1 uGUI, sprites blocks buttons/scrollrect from clicking/scrolling
(sorry my English wasn't very good...) I built a scene with 4.6 RC1, as the pictures 1 & 2
picture 1:
picture 2:
players could scroll the scene to left or right to see more levels(by using a invisible ScrollRect) each level was Instantiated from prefab, put under a GridLayoutGroup, and contains a button for player to click at the front side were sea waves.
now here comes the problem: 1. for now, i put scrollview behind level buttons and sea waves. so only 1/3 of the screen could respond the scroll, even the sea waves would block the scrollview 2. if i put scrollview before level buttons, i can't trigger buttons any more. any idea how to make them together peaceful?
ps: i also try to settle this problem through physics2D layer collision matrix, but didn't work (or maybe it's my own problem beacuse i'm not quite understand it yet) and i also tried setting the GraphicRaycaster script on canvas, but also didn't change anything(and that's really wired)
Answer by troien · Nov 18, 2014 at 08:56 AM
For the waves in the front, you should check the answer I gave to this question.
As for your buttons, maybe you'll need to write your own ICanvasRaycastFilter. But I'm not sure what you are trying to achieve. Since how do the buttons and the scrollrect need to co-operate, and how do they work now (If you put buttons in front of scrollrect)
thank you so much, the first problem was solved!
to the second part, i'm trying to make a scrollview that covers the whole screen yet i can still click on the level button. i checked the scripting reference of ICanvasRaycastFileter, and it looks excactlly fit my purpose, but i couldn't find further instructions on how to use it in code...how should i use it? was there a demo?
Is the purpose of the scrollview to scroll the level buttons?
If so, I created a test scene with this hierarchy
And these values in the Inspector
Now the result looks like what you describe you want. The black background image won't scroll, but is needed as a child of the Scrollview. Otherwise you can only drag the buttons. With the image you can drag the buttons by dragging the image if I'm still making sense right now :p
Edit: I guess what I'm trying to say is, make the buttons a child of the scrollrect. Because I think implementing the ICanvasRaycastFilter is something you usually don't need to do sinse Unity has better alternatives. I haven't found any instructions how to use it other than the link to the docs. I did make a example in another answer to a question before. But in that case there also was a better alternative by changing the hierarchy in my opinion.
Thank you so much, i tried it and it totally works. It's my mistake by spliting ScrollRect and Buttons into two parts
The example about iCanvasRaycastFilter you gave is also a great help, again, thank you a lot!
Answer by yuriythebest · Aug 19, 2015 at 02:00 PM
Hey guys! Just had a lot of problems with this - in Unity3d 5 event triggers will NOT work (you won't be able to drag) - use good ole buttons!!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613171812im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to display texture field with label on top like the "Add Terrain Texture" window? 1 Answer
GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced) 2 Answers
Destroy text 1 Answer
Rect with a height of 0 has a non-zero height 1 Answer
changing from mouse click to keys 0 Answers