how to make ui button run an animation

I’m trying to make a button on my main menu run an animation to move that menu off screen and move a new menu on the screen (like on my main menu if i hit my settings button it moves my main menu of screen and my settings menu on screen) i have all the animations all ready i just need a script to run it I’m not so good with script and could use some help. thanks.

OK this is a basic script that’ll give you an idea of what to do. The two panels go into the public slots and you need a bool on each panels Animator called SwitchMenu. On one of the Menus play the exit Animation if true and on the other the enter Animation if true. Then do the opposite for the false settings for the bool. Make sure you switch off Loop for the animations.

Drag this script onto the canvas:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class MenuSwitch : MonoBehaviour {

	private Animator p1Anim;
	private Animator p2Anim;
	private bool swapPanel = false;

	public RectTransform panel1;
	public RectTransform panel2;

	// Use this for initialization
	void Start () {
		p1Anim = panel1.GetComponent<Animator>();
		p2Anim = panel2.GetComponent<Animator>();
	public void IveBeenClicked()
		swapPanel = !swapPanel;

		p1Anim.SetBool("SwitchMenu", swapPanel);
		p2Anim.SetBool("SwitchMenu", swapPanel);

On the button on each panel that swaps click + on the OnClick and drag the canvas onto the the slot that appears. From the dropdown select MenuSwitch → IveBeenClicked.

Should be able to swap between two panels, I could in a quick test.

Example script in C#