How to play background music and sound effects when a button is pressed. This tutorial is a beginners guide to audio in Unity.


Subscribe to Oxmond Tutorials. We upload new videos every day!
https://bit.ly/SubscribeOxmondTutorials

Download the free background music (The Night Sky) from the tutorial:
https://assetstore.unity.com/packages/audio/music/orchestral/the-night-sky-35720?aid=1100l4p9k

Download the mushroom Sound FX (FREE Casual Game SFX Pack):
https://assetstore.unity.com/packages/audio/sound-fx/free-casual-game-sfx-pack-54116?aid=1100l4p9k

Download the skybox from the tutorial (Fantasy Skybox FREE):
https://assetstore.unity.com/packages/2d/textures-materials/sky/fantasy-skybox-free-18353?aid=1100l4p9k

Other Free Assets from the Unity Assets Store:
https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k


The Mushroom script:

/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © 2019 OXMOND / www.oxmond.com 

*/

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

public class Mushroom : MonoBehaviour
{
    void OnMouseDown()
    {
        GetComponent().Play(); 
    }
}