Button stuck animation due to SetActive?

Hey forum community,

I have searched this and couldn’t find a solution, so I’m posting this myself.
I created this simple function:

public void Shop()
    {
        buttons.SetActive(false);
        square.SetActive(true);
    }

The button gets stuck on Highlighted animation… What could be causing the problem?

Extra information:
Navigation is set to “none”
The problem occurs when I set buttons.SetActive(true)

bump?

I’ve never encountered that myself but you could try this:

https://docs.unity3d.com/ScriptReference/UI.Selectable.InstantClearState.html

This would involve getting all selectable components (button component) under “buttons” and calling this on them before setting them inactive.

1 Like

There’s an Issue in Unity’s Issue Tracker about the problem. Please vote for it so we can get it fixed ASAP! If you need some work-arounds, there are some near the end of this thread (very hacky, should only be considered temporary).

1 Like

Here’s my symptom.

A button with transition set to animation.
Normal state sets image’s alpha to 1.
Disable state sets image’s alpha to 0.5.

Call SetActive(false) during the animation blending, assuming the image alpha at the moment is 0.7.
Call SetActive(true) then try toggle between the state. The state machine’s still functioning, I can still blend between Normal and Disable state but… the end alpha of the image is 0.7 * 1 in the Normal state and 0.7 * 0.5 in the Disable state.
It looks like there’s a invisible ini value cached and the ini value is now stucked.
I still cannot find a way to reset the invisible ini value.