⚙️ About

The Audio Module is responsible for playing sounds and music in your game.

Sounds are stored in the AudioData ScriptableObject and played using AudioController. Music is played using AudioController's music system. Volume and mute settings are managed through AudioController and SettingsManager.

📄 Components

AudioController.cs - Main script responsible for sound playback, volume control and AudioSource management.

AudioData.cs - ScriptableObject database that stores references to audio files.

AudioManager.cs - Bridge between EventManager and AudioController for backward compatibility.

SettingsManager.cs - UI manager for sound/music mute controls.

image.png

🪄 Usage

How to play sound

Basic way (Recommended)

Use the AudioHelper static methods for easy sound playback:

using EKStudio.Audio;

public class Test : MonoBehaviour
{
    public void PlayWinSound()
    {
        AudioHelper.PlaySound("WinSound");
    }

    public void PlayMusic()
    {
        AudioHelper.PlayMusic("BackgroundMusic", loop: true);
    }
}

EventManager way (Backward Compatible)

Your existing code will continue to work without changes:

// These work exactly as before
EventManager.Broadcast(GameEvent.OnPlaySound, "WinSound", 0);
EventManager.Broadcast(GameEvent.OnPlaySound, "MatchSound", 0);
EventManager.Broadcast(GameEvent.OnSoundStart, "BackgroundMusic");
EventManager.Broadcast(GameEvent.OnSoundStop);

Direct AudioController way