Search Unity

Button stuck animation due to SetActive?

Discussion in 'UGUI & TextMesh Pro' started by Syzo, Mar 4, 2017.

  1. Syzo

    Syzo

    Joined:
    Nov 1, 2016
    Posts:
    17
    Hey forum community,

    I have searched this and couldn't find a solution, so I'm posting this myself.
    I created this simple function:

    Code (CSharp):
    1. public void Shop()
    2.     {
    3.         buttons.SetActive(false);
    4.         square.SetActive(true);
    5.     }
    The button gets stuck on Highlighted animation... What could be causing the problem?

    Extra information:
    Navigation is set to "none"
    The problem occurs when I set buttons.SetActive(true)
     
  2. Syzo

    Syzo

    Joined:
    Nov 1, 2016
    Posts:
    17
    bump?
     
  3. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,807
    Syzo likes this.
  4. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    There's an Issue in Unity's Issue Tracker about the problem. Please vote for it so we can get it fixed ASAP! If you need some work-arounds, there are some near the end of this thread (very hacky, should only be considered temporary).
     
    Syzo likes this.
  5. hirok

    hirok

    Joined:
    Nov 2, 2013
    Posts:
    7
    Here's my symptom.

    A button with transition set to animation.
    Normal state sets image's alpha to 1.
    Disable state sets image's alpha to 0.5.

    Call SetActive(false) during the animation blending, assuming the image alpha at the moment is 0.7.
    Call SetActive(true) then try toggle between the state. The state machine's still functioning, I can still blend between Normal and Disable state but... the end alpha of the image is 0.7 * 1 in the Normal state and 0.7 * 0.5 in the Disable state.
    It looks like there's a invisible ini value cached and the ini value is now stucked.
    I still cannot find a way to reset the invisible ini value.