Search Unity

Button Animation Getting Stuck With SetActive

Discussion in 'UGUI & TextMesh Pro' started by JAKJ, Aug 24, 2014.

  1. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    I have buttons being animated to scale to 1.11 on mouse over and 1.25 on click. It works fine, but when I click the button, I call SetActive on their parent to disable them and bring up a new set of buttons, and when I go back to the original buttons, they are stuck in partial animation rather than being back to scale 1. (For example, when I switch menu modes and back again, and choose one of the stuck buttons in the inspector, the scale is stuck around 1.22 or so, and if I hover, it goes down to 1.11, and if I click, it goes up to 1.25, but if I go back off the button it goes back to the 1.22 it was at before.

    To fix this, I went into the Animation window for the "Normal" state, started recording a keyframe, changed the scale and reverted it (so it essentially was a "no op" at 1), and now when the button comes back the animator fixes it.

    I'm not sure if this is a bug or not. But I think it should definitely be included in documentation/tutorials for the animator as a "gotcha".
     
    realGalaxy, CanisLupus and Marble like this.
  2. Dunny

    Dunny

    Joined:
    Nov 12, 2012
    Posts:
    3
    yeah I have this problem too, anyway to force a reset?
     
  3. millerlyte87

    millerlyte87

    Joined:
    Oct 31, 2014
    Posts:
    6
    For anyone interested, a solution that worked for me was to make sure every property was set in the initial animation: "Normal".
    e.g. If "Highlighted" animation sets the sprite or changes color, then "Normal" must have those properties set also
     
    VincentPham likes this.