Create a new c# script and paste this code. add the script to the object that own the animation

//Script Made By StrupsGames// using UnityEngine; using UnityEngine.UI; using System.Collections;
...