How to make a GUI Button shrink when pressed

Is there any way to make it so when you click the gui button it gets a little smaller and then when you let go it goes back the the original size?

If you use old GUI, than you need to create style for button. Also create two textures of one size (for example, 64x64), but the picture of the second texture will be a little less than the first as it is necessary for you. Further, in new style you add to the fields “Normal” and “Hover” the first texture, and in the field of “Active” the second texture. Also don’t forget to specify your style in the button. I hope that it will help you.

If you use the UI you can fully animate your transitions. This allows whatever effect you want for mouse down.

using System;
using UnityEngine;
using UnityEngine.UI;

namespace GameApp
{
    [Serializable]
    class ScaleButton : Button
    {
        [SerializeField]
        private float ClickScale = 0.75f;

        public override void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData)
        {
            base.OnPointerDown(eventData);
            transform.localScale = transform.localScale * ClickScale;
        }

        public override void OnPointerUp(UnityEngine.EventSystems.PointerEventData eventData)
        {
            base.OnPointerUp(eventData);
            transform.localScale = Vector3.one;
        }

        void OnApplicationFocus(bool isFocus)
        {
            if (!isFocus)
            {
                transform.localScale = Vector3.one;
            }
        }
    }
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Buttons : MonoBehaviour {

	void OnMouseDown () {
		transform.localScale = new Vector3(0.97f, 0.97f, 0.97f);
	} 

	void OnMouseUp () {
		transform.localScale = new Vector3(1f, 1f, 1f);
	}
}