how do i fix the quirk about the button size not returning to its normal size ?

posted to: Scripting UI

So i checked that navigation was set to none on all elements but once i enter the options menu the button is kept big, same with the level select 

it occurred to me that it was because the click animation scale to 1.5 

i tried adding 1 frame animation for the normal, with 1 frame, scale 1 to 1 and it seems to fix it visually but not sure if it is going to kill performance.
Is normal animation executed all the time or just on transitions? 

  • Jonathan Gonzalez(jgonzalez) replied

    Did you set the "navigation" settings on the button component to "none"? There used to be a weird issue in Unity where if you hovered over buttons that used animations it would get stuck in that state and start looping and it was due to how Unity thought you were navigating through the buttons. Using the normal state animation should be fine, but I would check the navigation setting first.

  • Jose Miguel Hernandez(jmiguelhdezgmailcom) replied

    Yes , i checked but i will double check. thanks! 

  • Jose Miguel Hernandez(jmiguelhdezgmailcom) replied

    just for reference, this is what i did last

    i added a canvasgroup component to the empty objects(starmenu, optionsmenu, levelmenu). Then used the 3 values to hide the buttons instead of disable the group. There is still a bug in unity in which the button still remains highlighted when using the canvasgroup(although if you move the mouse to hightlight other object it returns to normal). I am using one of the WA listed in the forums,  using a delay between setting blockraycast=false and the other 2 parameters. I am not sure if that is the best way to solve it but i can live with this for now.  

    https://forum.unity.com/threads/clicking-a-button-leaves-it-in-mouseover-state.285167/

    public void OptionsButton ()
    {
       EventSystem.current.SetSelectedGameObject(null);

       StartCoroutine(DelayedDisableCanvasGroup(startMenu));
       EnableCanvasGroup(optionsMenu);
    }


    void EnableCanvasGroup(CanvasGroup cg)
    {
    cg.blocksRaycasts = true;
    cg.interactable = true;
    cg.alpha = 1;
    }
    IEnumerator DelayedDisableCanvasGroup(CanvasGroup cg)
    {
    cg.blocksRaycasts = false;
    yield return new WaitForSeconds(0.01f);
    cg.interactable = false;
    cg.alpha = 0;
    }

  • Jim McLachlan(jimmack) replied

    Having asked exactly the same question myself, I've just found a solution that means you can avoid all that scripting.  I posted an answer to my own question.  I hope that helps.

    Jim.