- Home /
(New GUI) Make elements ignore mouse?
I ran a search for this but couldn't find anything, as most of the questions and answers pertained to the old GUI system rather than the new one.
That being said, is there any way to tell an element of the new GUI to ignore the mouse all-together? I'm not just talking about ignoring mouse clicks, but even ignoring the mouse's position.
The reason I ask is because I'm trying to design a tooltip that simply consists of a panel with text inside it. The tooltip only becomes visible when the cursor hovers over a button, at which point it's constantly updated to match the mouse's position (and nudged over a bit on the X axis).
The problem I'm having with this approach is that since the mouse cursor moves a little quicker than the tooltip's position updates, you're sometimes able to cover the tooltip before it gets out of the way, which in turn also covers the button (and, for that split second, prevents the button from being clicked!). This isn't a game breaker since it does eventually get out of the way, but it's annoying nonetheless.
I also tried removing the tooltip's panel so that it consisted only of text, thinking that perhaps the panel itself was the culprit, but unfortunately text appears to "block" the cursor as well.
If anyone knows of a way to keep the new GUI elements from registering the mouse's position or even an obscure workaround, I would greatly appreciate it!
Thank you in advance!
@fafase: It looks like neither panels nor text elements feature an "Interactable" property by default, so unless I'm missing something that option isn't available.
Answer by Chubzdoomer · Oct 09, 2014 at 09:37 AM
I was just given the solution by one of Unity's developers on the forum.
To make a canvas or one of its elements completely ignore all mouse input, simply add a Canvas Group component to that canvas or element (Add Component->Layout->Canvas Group), then turn off Blocks Raycasts.
Great thanks! This is especially helpful when using UI in VR when I don't want the mouse to accidentally highlight or select elements.
Answer by unimechanic · Oct 08, 2014 at 03:03 PM
You should also ask in the Beta group where our developers can help.
Your answer
Follow this Question
Related Questions
object with multiple colliders ignoring mousedown for some. 3 Answers
Cannonball not shooting according to the rotation of the cannon. 1 Answer
Setting the mouse position to specific coordinates 5 Answers
How to I get an object to disappear when I use the mouse to click on it? 1 Answer
MousePos To Transform 1 Answer