- Home /
Unity 2019.3 any way to make mouse events pass thru an UI element without disabling "Raycast Target" ?
Id like to know a way to do it with all mouse events, but to clarify my specific situation: I have a Canvas with a empty Scroll View to display some items, during runtime it gets populated with a lot of prefab objects, they are the same prefab with each item information, i have a Event Trigger component on the prefab with a Pointer Enter + Exit + Click, now comes the problem, THE SCROLL, the scroll wheel gets "absorbed" by the prefab, thus preventing me from "scroll wheeling" my item list, except when the pointer is between the spaces(really little "cracks") of the prefabs that's why i know the prefabs are blocking the Content game object from receiving the scroll event. So is there any way to pass the mouse events of a UI object to either the object below it or to his parent object? Note... go ahead and puke all the C# on me i will love it... provided the C# code comes with explanations, I'd like to LEARN WHY I'M DOING IT rather to copy and paste some code i don't know how it does the desired effect. Learning why I'm doing it allows me to adapt it to others situations/events.
TNX IN ADVANCE!!!!
Same behavior in the ignore raycast layer, mouse events stops on the prefab.
Answer by PuzzleBuilder · Feb 25 at 09:35 PM
I believe you could add a "Canvas Group" component to the blocking element or canvas with "Block Raycasts" unchecked. Hopefully this applies to your specific situation. Documentation:
https://docs.unity3d.com/2018.3/Documentation/Manual/class-CanvasGroup.html
Your answer
Follow this Question
Related Questions
UnityEngine.EventSystems.. Trying to figure it out .js 1 Answer
Why does my code hang when calling a script in a multi-nested event function 0 Answers
Is there a way to activate a button press in unity xr using the interactor events 1 Answer
Event.current.Use() not consuming event in editor SceneView 1 Answer