Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

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.