🔊 Make Every Click Sound Delicious

Want your button to feel extra satisfying?
Let’s add a little audio feedback — a “click!” sound, a coin jingle, or a dramatic BOOM if you’re feeling spicy.

In this lesson, you’ll learn how to:

  • Import and use audio clips
  • Trigger sounds via UI events
  • Control volume and playback in code

🎧 Step 1: Import a Sound Clip

  1. Find or download a short sound effect (WAV or MP3 works)
  2. Drag the audio file into your Assets/Audio/ folder
  3. Rename it to something clear like ClickSound

🎛️ Step 2: Add an AudioSource

  1. Create an empty GameObject → call it AudioManager
  2. With it selected, go to Inspector → Add Component → AudioSource
  3. In the AudioSource, uncheck:
    • Play On Awake (we’ll play it manually)
  4. Drag your ClickSound into the Audio Clip field

🧠 Step 3: Write the Sound Trigger Code

Update your ClickCounter script:

csharpCopyEditpublic AudioSource clickSound;

public void CountClick()
{
    clickCount++;
    clickText.text = "Clicks: " + clickCount;

    if (clickSound != null)
        clickSound.Play();
}

🔗 Step 4: Assign the AudioSource

  1. Select the GameObject with your ClickCounter script
  2. In the Inspector, drag the AudioManager (with the AudioSource) into the Click Sound field

Done! Now Unity knows which sound to play.


🧪 Bonus Tips

  • Add multiple AudioSources for different sound effects (coin, error, bonus)
  • Control volume via clickSound.volume = 0.5f;
  • Use clickSound.PlayOneShot() if you want to play overlapping sounds

🧠 Recap

  • Imported and organized audio clips
  • Used an AudioSource to play sound effects
  • Triggered audio through button click via script
  • Enhanced game feel and user feedback

🧪 Mini Challenge: Sound Fiesta 🎉

  • Add a second sound that plays when player hits 10 clicks
  • Use PlayOneShot() to prevent audio from being interrupted
  • Add a mute/unmute toggle button using audioSource.mute = true/false

🚀 What’s Next?

You’ve got the visuals, the logic, and the sound. Time to bring it all together!

In the next lesson, we’ll finalize and polish your first full game.

🎮 Go to Lesson 17 → Project 1: Build the Full Clicker Game