In my 2D game I have some icons, and I’ve implemented mouse events so that rolling over one will cause it to highlight and clicking one will cause it to become selected and remain highlighted.
I’ll need some menu screens to come up at times during the game, so I started to implement that but encountered a problem…
Currently I just have some text displayed as well as a blank Image element set to a colour so that it creates a background for the text to appear on. Mostly out of curiosity I set the opacity down to see what would happen when I clicked on the icons visible through the Image element.
Long story short… I’ve come to the conclusion that when the Image has its Visibility setting (under Behavior) set to Visible, clicking on the icons will cause the BeginCursorOver and EndCursorOver events to fire once each. I’ve isolated it to exactly that; every other pin is disconnected including OnClicked, but for some reason if I click on an icon through the Image then both Begin and EndCursorOver will fire, even though nothing will happen if I click on an icon that isn’t under the Image.
Why might this be happening and how could it be fixed? I’m asking mostly out of curiosity and to understand the situation better so I can avoid any confusion later on; in practice I’ll probably use Set Input Mode UIOnly when the menus come up but I’d rather not leave this hanging. I assume it has something to do with testing if the mouse is over in order to test if something has been clicked, but it looks like it isn’t supposed to be checking at all because the Image should be in the way (as it is if I try to mouseover the icons normally with the Image in the way; it blocks the normal behaviour but clicking causes this anomaly).
Even if I use Hit Test Invisible for the Image, clicking on an icon under the Image won’t cause anything to happen and it behaves exactly as if the Image wasn’t there apart from appearing on-screen. i.e., making the Image Visible is actually causing interaction with an object underneath that doesn’t happen if the Image is set to let everything through.