I have a main menu scene in which the buttons work using button component's animation transition. I created a simple animation for them that changes their vertex color to blue when selected. The problem is that surprisingly, some of them don't work this way. In fact, they don't even work with other transitions such as color tint.
As you can see in the gif, the animation transitions are working fine. But the truth is that these are (plus a few other buttons in the options menu) the only buttons that have working transitions.
When you press the quit button, a small panel shows up that asks if you really want to quit the game. This is where the problem appears. Although the yes button should be selected based on the script, it just stays unselected which also shows that the transition animation is not working. I've checked these buttons using animation tab's preview mode and they seem to work fine there but when the actual game starts, they just remain unselected.
I realized that there should be a big structural difference between the buttons that work and those that don't but I'm not able to find it. To prove this, I changed the transition mode of new game button (that is working fine) and the highlighted and selected color turned blue but when I did the same for the yes button (which cannot be selected), there was no change in the colors.
This is the part in my main menu script that controls the exit panel. I don't see any problems in the script as I don't in the editor. But still, some of the buttons can't be selected when the condition is due (All the game objects are assigned in the inspector).
public void OpenExitPanel()
{
exitPanel.SetActive(true);
EventSystem.current.SetSelectedGameObject(null);
EventSystem.current.SetSelectedGameObject(exitPanelFirstButton);
mainMenu.SetActive(false);
}
public void CloseExitPanel()
{
exitPanel.SetActive(false);
EventSystem.current.SetSelectedGameObject(null);
EventSystem.current.SetSelectedGameObject(exitPanelClosedButton);
mainMenu.SetActive(true);
}
I also tried creating new buttons (Text Mesh Pro) but again, some of the transitions work and some don't.
This problem is also present in the pause menu but unlike the main menu, none of the buttons can be selected there. I even used Debug.Log to check and see if the first button is selected and it was; but still the animation transition doesn't work.
I believe that this is a Unity bug but I decided to ask it here just to see if I'm missing something.
Thank you in advance.
EventSystem.current.SetSelectedGameObject(exitPanelClosedButton);
next frame using a Coroutine of 1 frame and see if it helps). \$\endgroup\$OpenExitPanel
function because the exit panel can't be closed now. I wrote something and updated the code but it's not working. Is it possible to tell me what part of the code is wrong? I'm not the best at coding :) \$\endgroup\$