- Home /
UI Transition Animation State properties are being overwritten
I have some buttons with transition type of animation. For each of Normal, Highlighted, Pressed, and Disabled, there are keyframes for Image Color and Scale. They all work correctly as you navigate around a canvas with multiple buttons. However, if you disable the canvas while a button is in any state other than normal, the values for the Normal state get overwritten when re-enabling the canvas.
An example:
Normal state, button has a keyframe for colour black and scale 1.
Highlighted state, color is green, scale is 2.
Pressed state has a keyframe for colour white and scale 2.
Mouse over, it correctly transitions to Highlighted.
Click on the button, it correctly transitions to Pressed. You can see in the inspector that the Image color is white and scale is 2.
Now take some action in code because of that button press. For example, in the OnClick(), disable the current canvas and enable a new one, maybe a different menu. Then return to the original canvas.
Now the button is in Normal state as expected, but the color is still white and scale is still 2. You can view the Animator for the button and see the progress bar cycling through the Normal state.
Hovering over the button and pressing it correctly transition to the Highlighted and Pressed states, and their color and scale are correct. Returning to Normal state, the colors do not get set back to the values in original Normal keyframe. They are being set to the values from when the canvas was disabled.
How can I prevent Transition Animations from overwriting the Normal-state animated properties?
Your answer
Follow this Question
Related Questions
Unity 5 UI animations not smooth on device. 0 Answers
Animator has not been initialized?? 3 Answers
How to change UI button animation speed (4.6 UI) 2 Answers
How to do an animation transition 2 Answers
Button animation (transition) reset 0 Answers