I want to press a Button and play a sound?

Hi, I have a created a Button and I want to make that when I click on it the button let an audio play.

Thanks

Normally, I would actually incorporate this into a script, but this is actually pretty simple, and can be achieved entirely through the the editor. What you can do is attach an AudioSource component to your button, and add the Audio Source’s Play function to the button’s On Click event. To do this, click the plus button on the button component’s On Click event, and drag the audio source into it. Then, click the part that says “No Function”, Click on Audio Source, and find the Play method. You will also need to drag your sound file from the assets folder into the AudioSource’s AudioClip field. And, you will probably want to set PlayOnAwake to false. In the end, it should look something like this:

But if you really wanted to do it from script, you can attach an audio source in the same way, and do something like this:

public void Start()
{
        Button b = GetComponent<Button>();
        AudioSource audio = GetComponent<AudioSource>();
        b.onClick.AddListener(delegate() { audio.Play(); });
}

You can use following Unity editor extension for buttons click sound management: GitHub - nubick/unity-button-sounds-editor: Editor extension for Unity game engine. It helps to assign AudioClip to buttons and to play sounds by button clicks.