0
\$\begingroup\$

We have animation states for Normal, Highlighted, Pressed and Disabled. How to set animation when a button is clicked?(after button released not pressed)?

Thanks in advance

\$\endgroup\$
0
\$\begingroup\$

In order to use animations as UI buttons transition, an Animator component should exist. you can generate it.

ui button

in the generated animation controller, just drag and drop your animations into the state inspector.

Doc: https://docs.unity3d.com/Manual/script-SelectableTransition.html

Now, in case you want to fire your events AFTER the button click (onPointerUp), you'll have to use Event Trigger component instead.

\$\endgroup\$
  • \$\begingroup\$ What I want (click button and after clicked not after pressed run animation) 1.Click the button. 2.Play the button animation. 3.The button animation gets finished. 4.After that we call some method in some script. \$\endgroup\$ – Sh.Adel Nov 12 '18 at 10:59
  • 1
    \$\begingroup\$ Then you will have to use the Event Trigger component with an OnPointerUp event that calls some method on your script. play animation -> waitforseconds -> call logic. \$\endgroup\$ – Omar Guendeli Nov 12 '18 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.