[SOLVED] 4.6 : Sending mouse events through an image

Hello everyone,
I am currently converting my user interface to 4.6 UI and I have to say, that’s a really good tool once you get the hang of it !

Here’s my problem ; I am using an image to add a noise effect to my UI. The problem is that this image is visually above everything in the UI, so none of my buttons or scrollviews are getting any mouse event.

Here is an example with a ScrollView. I moved the noise to the left so a zone of the scrollview is scrollable.

Is there a way for the UI to ignore this noise image? I tried removing the noise’s layer from the graphic raycaster’s blocking masks, but it didn’t work.

Thanks a lot !

EDIT - SOLUTION : The “Canvas Group” component contains a variable “blocks raycast”. Simply adding the canvas group and unchecking it did the trick.

Extended problem : Lower in this thread, I’m talking about another similar problem and my solution : my boxes in the grid are catching every event, so my scrollrect doesn’t scroll.

1 Like

I think you may use CanvasGroup component for that.

2 Likes

That was it ? That was so simple ? Yes, it was.
Thanks a lot !

I was still having trouble with another problem, still with the scrollrect.
The setup is exactly the same as the image posted.

When the player points a box in the grid, it executes a function called by an eventtrigger attached to the box.
But when I’m pointing at this box, and try to scroll, nothing happens, I’m guessing because all events are caught by the pointed box, and the scrollrect never receives any event.

So it’s basically the same problem (an image is catching all my events) but the canvasgroup solution doesn’t work, because I need the box to catch SOME events, but not ALL events.
As the documentation says about EventTrigger

NOTE: Attaching this component to a GameObject will make that object intercept ALL events, and no event bubbling will occur from this object!

So the main problem is the EventTrigger Object. Simply recoding one myself, catching only the events I need, solved the problem.

using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;

public class GoThroughImage : MonoBehaviour,IPointerEnterHandler,IPointerExitHandler
{
public void OnPointerEnter (PointerEventData eventData)
{
//Do stuff
}

public void OnPointerExit (PointerEventData eventData)
{
//Do other stuff
}
}

The “GoThroughImage” only blocks pointer enter and exit events, and the scrollrect gets the scroll, drag and drop events.