- Home /
What does group content have to do with mouse clicks?
I was looking at using GUI groups and was looking through the documentation. I guess I had never noticed this before but for the content property, the docs say:
Text, image and tooltip for this group. If supplied, any mouse clicks are "captured" by the group and not If left out, no background is rendered, and mouse clicks are passed
My question is why does the presence of content dictate how mouse clicks are handled for the group (am I understanding this correctly)? Can any of the Unity guys explain the rationale behind this? That seems totally arbitrary to me. Wouldn't some sort of input handling strategy be better here, and potentially other parts of the API?
I just did some quick tests, and I can't see any difference with or without content in the group. I know you don't need content for other controls in the group to get clicks, but I had thought that content might capture clicks to overlapping controls, but that does not seem to be the case. Error in docs maybe? (there does seem to be an incomplete sentence in there).
Answer by qJake · Jun 08, 2010 at 10:07 PM
This behavior is because if your group has a background image attached to it, the click will "hit" the background, and register a click on it (so any controls underneath it won't get hit, since they aren't visible because of the background). However, if there is no background, the group's background becomes transparent, and any controls underneath are then visible, which need to be handled (since the user can see them), hence, the mouse clicks will "pass through" the transparent portions of the group.
Basically, it accounts for GUI objects behind the group. If you can see stuff underneath, it needs to be able to be clicked. :)
Answer by PrimeDerektive · Jan 21, 2011 at 02:01 PM
I'm pretty sure that's referring to the possibility of actually want to make the entire group clickable, by providing GUIContent you could in effect make the whole group a huge clickable button, or have a tooltip on hover (just like you would with any other GUI element by passing it GUIContent).
But it would have nothing to do with the clicks of any elements inside the group, they would handle their own clicks.
Your answer
Follow this Question
Related Questions
How to group variables in the Inspector? 5 Answers
Disable mouse click navigation when selecting GUI menu option 1 Answer
How to cast spells by mouse click 2 Answers
GUI based character control 2 Answers
Create a sliding Menu 2 Answers