How to use button to change animation state

Hi,

I just started learning Unity3d and am loving it. I have an Animator script that do exactly what i wanted. I have 2 paramenters, float speed and trigger run. When i press the UpArrowKey, my animation will walk and then run. while running when i press space my animation will jump. Below is the script.

using UnityEngine;
using System.Collections;

public class DogScript : MonoBehaviour {

    Animator anim;
    int jumpHash = Animator.StringToHash("Jump");
    //int runStateHash = Animator.StringToHash("Base Layer.Run");
	// Use this for initialization
	void Start ()
    {
        anim = GetComponent<Animator>();
	}
	
	// Update is called once per frame
	void Update ()
    {
        float move = Input.GetAxis("Vertical");
        anim.SetFloat("Speed", move);
        Debug.Log(move);

        //AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0);
        if (Input.GetKeyDown(KeyCode.Space) /*&& stateInfo.fullPathHash == runStateHash*/)
        {
            anim.SetTrigger(jumpHash);
        }

	}
}

However, i would like to use a UI button to replace the the now keyboard function. How can i achieve this?

public void ChangeToJumpAnimation(){

             anim.SetTrigger(jumpHash);
         }

Just put it in a function and attach the script to an empty gameobject. Then Drag the EmptyGameObject with the script attached into the functions of the UI Button and select ,ChangeToJumpAnimation()"