[SOLVED] UI buttons only works on screen edges in editor

Hi all,

I have a problem with my buttons in the editor mode. To contextualize, I am working on a world exploring application and my buttons are in fact the text above the points of interest, so they are moving on the screen as the camera moves. But the fact is that when my buttons are on the edges of the screen, they work well. I think there is a kind of “working area” (see image bellow). Moreover, I don’t encounter this issue with the executable of the app.

I have searched for solutions, and found an answer of @Hellium (So my buttons stop working... - Questions & Answers - Unity Discussions), which groups several solutions that I found on the Unity forum. Unfortunately, all of them didn’t work for me.

Here is my button config and its position in the hierarchy:

Button inspector

Button hirarchy
4983125--485972--upload_2019-9-20_9-57-10.png

Also, here is the configuration of my EventSystem:

EventSystem inspector
4983125--485975--upload_2019-9-20_9-58-38.png

What I want is to make it working in the Unity editor when I hit play button, even in the “not working area”.
One last thing, I am using Unity 2018.2.7f1

Many thanks for your answers!

According to your hierarchy, your Canvas is a child of several gameObjects. Is your canvas set to World Space? If so, have you specified a camera?

What info do you get in the EventSystem “preview window” when you hover the button?

You haven’t specified any function in the onClick event of the button. Do you add a listener by code?

Hi Hellium, thank you for your reply ! :slight_smile:

My canvas is set to Screen Space - Overlay. I have tried to set it to World Space an added my camera as you said in your post, but when I do that, my button disappears (I mean, it is not destroyed or disabled, but is not visible on screen anymore).

In my EventSystem, when I hover the button in the “Working area” I got this :

pointerEnter: Text (UnityEngine.GameObject)
4990742--487256--upload_2019-9-23_10-12-51.png

And in the “Unworking area”:

pointerEnter: Pointer (UnityEngine.GameObject)
4990742--487259--upload_2019-9-23_10-13-13.png

Finally, yes, I added a listener to my button in my Start() function. In fact, I added two listeners, and is working the same way as only one.

POI_button.onClick.AddListener(ShowPOI_info);
POI_button.onClick.AddListener(DoubleClick);

4990742--487235--upload_2019-9-23_10-3-51.png
4990742--487238--upload_2019-9-23_10-5-22.png
4990742--487253--upload_2019-9-23_10-12-10.png

Keep your Canvas in the Screen space if you have designed your system this way, but Screen space canvas are not meant to be moved in your scene.

What is this Pointer gameObject? It is intercepting your mouse events. Uncheck the Raycast Target tickbox on this object and try again.

1 Like

Hi Hellium,

It works now ! :smile:

Yes, it was my Pointer gameObject which was intercepting my mouse event. Fyi, it is a kind of sight (a “+” in a text field) designed to reduce motion sickness.

Many thanks for your help :wink: