- Home /
HELP! Buttons stop working when made a child of a "Canvas Group" empty in 4.6.3f1?
Okay so now I have noticed a big problem for me.
While creating a rather complicated MainMenu with a few pages and my SceneHUD canvas, I have been using the Rect Transform version Empty GameObject to organize these into containers and/or pages so that I can keep track of all of the little details, but more over, also to control visibility of my widgets that are not always needed. Just to keep the players view from getting too cluttered when certain this are not needed to be Tracked. things like health Bars when the player is not in a combat state or area.
Normally this works out great for me from an organization standpoint. However, my goal is that not everything should be visible at once, and I want a smooth Fade-in and Fade-out transition effect of entire button/widget groups. And not just the buttons background, but the child objects inside them as well.
The Canvas Group script or plug-in, I know allows for entire groups of items to have their Alpha set 0-1, Toggle Intractable of all the children, Block Raycasts, and finally Ignore Parent Groups.
The moment I put a canvas group on the parent empty, all of the child button objects inside 100% breakdown. I have tried toggling the intractable, block raycasts and ignore parent groups in various combinations I even tried turning on and off the whole "Canvas Group" script it self to no avail. even when off but present on the parent empty, Buttons just do not work at all for me.
It took me an hour of troubleshooting to figure out it was the Canvas Group causing this. whats worse it happens even when the button group object is a child of another empty with canvas group attached.
The only way to fix this issue, it to work my way up the container family tree of the canvas and remove every single canvas group from the inspector. Not just turn them off or fiddle with the toggles, but remove it entirely.
I need the overall control of the group's alpha value for my desired fading effect, and I am not aware of any other way to control this with out having to dive over my head in code. I lucky I can code a main menu control script that is usable with the event system with Application.LoadLevel(string veritable) and .Quit() abilities.
The question is not how to organize my pages, as that is covered already, as I have said before.
If you want a figure of how I have it organized right now, I have like 5 Pages for the HUD (Health, $$anonymous$$agic, Sta$$anonymous$$a, Active Weapon, Active Power, pause menu, targeting reticle) alone and like 10-ish for $$anonymous$$ain $$anonymous$$enu (Settings, Game $$anonymous$$anual taking a good chuck of pages, Credits, the splash screen, etc). How to control Alpha visibility and Intractable Toggles while not breaking the buttons inside the Empty or in your case the Panel.
That is the actual question. As far as I can tell the only way to control alpha of the parent and child object at once, and that come stock in unity, is the Canvas Group.
A UI Panel is no different then a UI Image, it just starts with a low alpha and a sprite already setup. The empty object serves as a container stripped of all the junk. Placing a Canvas Group on the panel object still breaks down the buttons inside the panel, and lastly the UI Panel only controls alpha for it's own UI Image, not the alpha's of the children as well.
I can activate and deactivate the Empty Objects for the instant pop on and off effect all day long. What I want is a 2-3 second smooth fade in and out effect and still keep the buttons working for when the buttons are visible again.
For now, the popping change over is how I am forced to have it. I can do the fading in/out effect with script controlled items that the player does not have to interact with via direct manipulation with a mouse cursor and raycasts.
Grrr... Okay well answer that was a bust. hopefully a better, more on topic, answer will show up soon. Until then, I am still working on it.
Thank you anyways for the attempt at an answer GJF, I wish it had actually helped.
I just encountered the same issue in unity 5, would be nice to know what's going on...
Answer by Nimred · May 27, 2015 at 01:52 PM
I had the same problem, but in my case using "Blocks raycasts" (and "Interactable" of course) fixed it. (Unity 5.0.1f1)
Answer by MonkeyZero · Mar 05, 2015 at 11:38 PM
So with the awesome release of Unity5, this issue is now not even an issue. Thus I guess this is solved.
Answer by HonoraryBob · May 26, 2015 at 07:11 PM
It's an issue for me: the same thing happened to me using Unity 5 when I made some buttons into children of a GO with a CanvasGroup.