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 freezes after disabling the parent panel

Discussion in 'Animation' started by EdPS, Oct 15, 2015.

  1. EdPS

    EdPS

    Joined:
    Sep 15, 2015
    Posts:
    3
    Hi guys,

    I am playing with the UI system and I am hitting some walls right now with buttons animations, with what could possibly be a bug.

    I have a canvas with 2 panels. One panel for a menu with a button and other for the content to be displayed after pressing the button. When I hit the button in the first panel, this panel is set to inactive (SetActive(false)) and the second panel is set to active to be displayed.

    The button's transition is set to type Animation, where a sprite with another color is put in its place when pressed, and scaled down a little. Unity automatically creates a smooth transition between the 2 states
    Normal:
    ButtonUp.png
    Pressed:
    ButtonDown.png
    The problem I encounter is that because when I click the button, I immediately disable the panel containing the button and the transition back to normal isn't finished when this happens, when I activate the menu panel again, the animation is stuck as in the second image (yellow) even though I am not interacting with the button.

    I can't find I way to make the button return to its original form; it seems like Unity now takes the last frame of the animation before disabling as the new normal state.

    One workaround I could think of is to force Unity to not to animate between the 2 states, so when I click the button it immediately goes back to its original form, before the panel turns inactive. But I can't find a way to affect the way Unity animates between the states. I could use Sprite Swap, but I would lose the ability to scale down the button.

    Any ideas?
     
    DryreL likes this.
  2. DryreL

    DryreL

    Joined:
    Feb 23, 2020
    Posts:
    49
    Same problem here. I'm looking for solution.
     
  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

    Unity 2019.4.20
     
    Funnyneck likes this.