I have a uGUI canvas that has a script with DontDestroyOnLoad attached, so it will persist from our Title Scene to our Gameplay Scene. It does persist, and mostly works, but the buttons aren’t working as expected. They do appear and send their onClick events when clicked, but graphically they’re completely unchanging. They’re supposed to have different images for hovered and pressed states but those simply don’t appear when hovering or pressing the buttons. This all works in Title Scene even if I go to Gameplay Scene and then return, but never in Gameplay Scene.
Some facts that might be relevant:
The buttons use the Animation method for switching between states. (We’re using it instead of the simpler methods because we want to change the color of both the button image and the color of a child text component when switching states.)
In both Title Scene and Gameplay Scene there’s also another canvas that doesn’t use DontDestroyOnLoad.
There’s a separate EventSystem in both Title Scene and Gameplay Scene, and neither of them use DontDestroyOnLoad.
Anybody? If we can’t use the Animation method for button state changes, then we’ll have to redesign our buttons so they don’t require the button-label to change colors. (Unless there’s another way to do that besides Animation–I’d love to hear it if there was.)
I think a bug report would be most helpfull. Not sure if its something you’re doing or if its the system failing to register the Canvas ect.
Things i’d check if you want.
What does the Inspector say (bottom of the inspector in the preview area) for the EventSystem when in the second scene does it notice that you are over the button?
What does EventSystem say about registered Raycasters?
If you use color transition instead does that work?
@phil-Unity : Thanks much for the reply. The inspector readout is the same in the title scene and in DoNotDestroy scenes–see screenshot.
-I’ll let Tommi answer 32, not sure how to check for that.
-Color transition does work. Is it possible to change the button label text color with that method? If so, I’d be willing to switch.
I want to change the button color/graphic (prefer texture, but could live with changing the color only) AND the text color – basically reverse both colors from light on dark to dark on light. Can I do that without animations?