Strange warning when using UI Button Script. Bug or not?

So I was playing around with attatching the Button Script to 3D Objects and use them as buttons with Transition mode Animation. I didn’t generate the Animation so I manually added the Animator component which ended up over the Button script in the Inspector.
And here comes the strange warning 5 times on pressing play and 5 times on stopping:
Animator has not been initialized.
UnityEngine.UI.Selectable:OnDisable()

I wondered why this was happening and looked at my other buttons. The only difference is that the Animator in those comes after the Button script. And that’s actually the cause. When I move the Animator down, the warnings stops.

So my question is: Is this a bug? Should I report this? Did I miss some kind of documentation on this?

TL;DR
When using Button script or any other UI.Selectable derived script the Animator has to be below the Button script or you’ll get warning spammed.

1 Like

You should report this :slight_smile:

Have been asking this long ago here: Animator has not been initialized Warning - Unity Engine - Unity Discussions and finally got an answer! Thanks, KayelGee!

I had this happen too but the Animator already was the last component in the list, so that didn’t fix it for me. After some digging I discovered that it was because the button was child of an object with a CanvasGroup on it that had Interactable disabled.

I guess that that tries to set the inactive state of the button before it was able to initialize its animator :slight_smile: Setting the group to interactable and then turn it off later fixes the issue for me.

I’d like to report this, but can someone tell me where?

1 Like

In the editor go to: Help → Report a Bug