avatarDaniele Quero, PhD

Summary

The web content provides a tutorial on how to create animated buttons in Unity by utilizing the Animator component and recording property changes to animate button states such as Highlighted and Pressed.

Abstract

The article "Unity UI — Animated Buttons" on the undefined website demonstrates a straightforward method for implementing animations in Unity UI buttons. It guides readers through the process of setting up animation transitions directly in the Unity Editor by using the Animator component. The tutorial explains how to auto-generate animation clips for different button states and then manipulate properties like scale, position, and color while in record mode to create dynamic animations. The author emphasizes the ease of this approach and its potential for creating complex and engaging button animations. The article also includes visual aids such as screenshots and animated GIFs to illustrate the steps and results. Additionally, the author encourages readers to support their work by joining Medium through their referral link and subscribing to their newsletter for updates on new content.

Opinions

  • The author believes that adding animations to Unity UI buttons is unbelievably simple with the right approach.
  • They express enthusiasm about the potential for creativity with button animations, suggesting that readers can have fun while making their buttons more interactive and visually appealing.
  • The author is confident that even complex and articulated animations are within reach using Unity's Animator transitions.
  • There is an implicit opinion that reader support through Medium membership and newsletter subscriptions is valuable and beneficial for both the readers and the author.

How to Unity

Unity UI — Animated Buttons

Button Animation Transition in Unity

As summarized in a previous article, Unity has several ways to implement button transitions, such as “what happens when the button is pressed”.

In this article, I will show you how to implement animation transitions in the easiest way possible so that, instead of just changing colours when your Unity UI buttons are interacted with, you may have animations!

It is unbelievably simple: in the Unity Editor, first set the animation transition in the button component inspector view.

Button Animation Transition in Unity

Click the Auto Generate Animation button now. This will generate a new Animator, with the same name as your button, which contains the default animations for the button. One for each transition.

Button Animator View
Button Auto-Generated Animation Clip

You’ll be asked to choose a path to save those clips. As you can see from the Animator, each state corresponds to a button transition, for example, Selected.

Let’s have some fun now.

The easiest way to bring life to your buttons is to “record” your animations, so select one clip (I chose Highlighted) and click the red record button above.

Choosing a button Animation Clip

You are now in the record mode of the Unity Editor: any change you make to any property will be counted as animation.

Unity Record Mode

For the Highlighted transition, I changed the button scale to 1.5. Click again the record button to end the record mode and bring back to normal any changed property.

Highlighted Animation

Cool, huh?

But let’s see what happens in the Animator view!

Highlighted Animation as seen from the Animator

As you can see, the button is idling in the Normal state, until I highlight it by hovering with the mouse pointer. At this point, an animation transition from Any State brings it to the Highlighted state and back to Normal when the mouse is away.

You can animate it as you like! You can change scale or position or colour. Everything! This is what I did for the Pressed state:

Pressed Animation

But what’s truly powerful is that you can also manipulate the transitions within the Animator, creating very complex and articulated button animations!

If you liked the article, please clap to it and share it! Also, take a look at my games!

Access my stories and those of other Medium writers for just $5 a month. With no additional cost to you, I will receive half of your payments as a commission: it’s a great way to support me!

Join my newsletter and receive regular notifications when I post.

Unity
Unity Ui
Unity Game Development
Recommended from ReadMedium