How to animate a UI panel?
I am trying to have a tongue from my character shoot out when you are on an option (say if you are on start, not clicking just highlighting, it will play the animation of the tongue going to the option once and stay there and when you unhighlight it plays the animation backwards) I also have another character with a tongue that will go to the other option if it is highlighted and do the same as above. I have tried using the animator (maybe I am not using it right)
Answer by Yuzuke · May 17, 2017 at 06:25 AM
Click the panel, add animation component.
Ctrl+6 or Window - Animation to pop up animation tab and dock wherever you want.
In the empty animation tab there'll be a message with a button to let you create a clip, press create. a window will pop up, type a name maybe "TongueOut" and choose where to save and confirm.
Press "Add Property", choose someone you need it's value changed, or just changing them in the inspector and the properties will automatically fills in. and you want to mess with the key frames & timeline a little bit. basically some typical animation editing work, just like any other animation-editing-software.
When you done your "TongueOut". maybe you need another "TongueIn", then you'll need to find the red recording button in the animation tab,and press the TongueOut double arrow button below. and choose Create new clip.
When all done, set Animations Size = 2 in the inspector , and drag those two clips in.
Get that animation component reference somewhere in your script and play them when you need it. something like this: @kalley51
Panel panel_Foo; Animation anim_Foo ; void OnEnable() { panel_Foo = GameObject.FindGameObjectWithTag("panelFoo"); anim_Foo = panel_Foo.GetComponent<Animation> (); } void TongueOut() { anim_Foo.Play("TongueOut"); } void TongueIn() { anim_Foo.Play("TongueIn"); }
Your answer
![](https://koobas.hobune.stream/wayback/20220612122151im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to show and hide a Button and don't affect the Animation on it. 0 Answers
Animate alpha of material on UI panel 0 Answers
How do I stop my main menu from closing before the player is done interacting with it? 0 Answers
Multiple game objects playing DIFFERENT animations with a simple Mouse Over/Button Hover? 1 Answer
Problem trying to animate UI elements on different screens 0 Answers