Now that we have a functioning animator controller, it’s time to accept player input so that we can actually pause the game and bring up the menu.

To do this, create a new C# script called PauseController. This will be a very simple script; it's 20 lines including whitespace, because all it needs to do is update the isPaused parameter of our animator controller. Here it is, in all its glory:

using UnityEngine;public class PauseController : MonoBehaviour
public Animator canvasAnimator;
int isPausedHash;
void OnEnable ()
isPausedHash = Animator.StringToHash ("isPaused");
void Update ()
if (Input.GetButtonDown ("Cancel")) {
canvasAnimator.SetBool (isPausedHash, !canvasAnimator.GetBool …

So far in our efforts to create an animated pause menu, we have set up the required UI elements for the menu, and created the animation clip that will drive the transition between the paused and unpaused states of the game. Now, we’re going to move ahead and set up the Animator Controller that will actually handle the user’s request to pause or unpause.

Default Pause Menu Animator
Default Pause Menu Animator

In our Unity3D project, click the Canvas gameObject in the inspector, then open the Animator window (as far as I know, there is no hotkey for this, but you can find it in Window menu under the Animator label). You should see a fresh animator editor with three states: Any State, Entry, and Pause (or whatever you called the pause animation that we created in step 2), with a transition from Entry to Pause. …

Following the setup of all the UI elements for the pause menu in part one, we’re now going to create an animation for the transition between the unpaused and paused states of the game. As a reminder, here’s a preview of the finished state of the pause menu, showing the transition animation:

[caption id=”attachment_152" align=”aligncenter” width=”825"]

Pause menu animating in and out with example gameplay in background
Pause menu animating in and out with example gameplay in background

Pause Menu in Action[/caption]

Before we get started, let’s talk a little bit about animation in Unity3D. Unity’s animation system, Mecanim, uses curves to represent motion. Most commonly, these motion curves drive the movement of 3D models, but you can actually use Mecanim to animate any public property that Unity knows how to serialize. …