🇹🇷 Türkçe Dokümantasyon için tıklayın (README.tr.md)
AudioSystem is a catalog-driven, zero-GC, high-performance sound and music management engine for Unity (supporting Unity 2021.3 through Unity 6) featuring AudioRegistry PreloadedAssets discovery, dynamic AudioSource pooling with generation-safe SoundHandles, ping-pong BGM crossfades, and GUID-safe AudioKey inspector dropdowns.
- Zero Scene Setup & Build-Safe Discovery: Place
AudioCatalogassets anywhere underAssets/.AudioRegistryautomatically synchronizes catalogs viaPreloadedAssetsand verifies everything before builds viaIPreprocessBuildWithReport—noResourcesfolder or scene manager setup required. - Unity 2021.3 – Unity 6 Compatible: Uses
AudioClipon Unity 2021.3/2022.3 andAudioResource/AudioRandomContaineron Unity 6 (UNITY_6000_0_OR_NEWER). - GUID-Safe
AudioKey&[AudioId]Filtering:AudioKeybinds by immutable GUID (falling back to case-insensitive string ID), so renaming a sound in a catalog never breaks scene or prefab references. Use[AudioId("ui_")]onstringorAudioKeyfields to filter dropdown options by prefix. - True Zero-GC Pooling &
SoundHandle: Active emitters are ticked centrally without per-play coroutines orWaitWhileallocations, never kill sounds onAudioListener.pause, and return generation-safeSoundHandles (Stop,Pause,Resume,SetVolume,SetPitch,Follow). - Per-Entry Mixing, Variance, Cooldown & Concurrency Caps: Configure
volume,pitch,pitchVariance,spatialBlend,minDistance/maxDistance,loop,cooldown, andmaxConcurrentInstancesper sound entry, with clean mixer fallback (Entry.mixerGroup→Catalog.defaultMixerGroup→AudioRegistry.defaultSfxMixerGroup). - 2-Source Ping-Pong
MusicManager: Plays music from either anAudioKey, string ID, or rawAudioClip/AudioResourceusing two permanentAudioSources and logarithmic crossfades—rapid track changes orStopMusicmid-fade never leak zombie audio. - Mixer Volume Helpers & Edit Mode Preview: Includes
SetMasterVolume,SetSFXVolume,SetMusicVolume(ToLogarithmicVolume), and one-click▶preview buttons directly in Inspectors.
- Open Window > Package Manager in Unity.
- Click the
+icon in the top-left corner and select "Add package from git URL...". - Paste the Git URL:
https://github.com/ChasingImagines/AudioSystem.git
Right-click anywhere under Assets/:
Create > AudioSystem > Audio Catalog
AudioRegistry automatically registers the catalog and ensures it is included in PlayerSettings > Preloaded Assets. Add entries (player_jump, ui_click, bgm_boss) with their mixer groups, cooldowns, and concurrency limits.
using UnityEngine;
using Yasin.AudioSystem;
public class PlayerCombat : MonoBehaviour
{
[SerializeField] private AudioKey attackSound;
// Optional prefix filtering on either AudioKey or string fields:
[AudioId("ui_"), SerializeField] private AudioKey uiConfirmSound;
public void Attack()
{
SoundHandle handle = attackSound.Play(transform.position);
handle.Follow(transform);
}
}using UnityEngine;
using Yasin.AudioSystem;
public class AudioManagerExample : MonoBehaviour
{
[SerializeField] private AudioKey uiClickSound;
[SerializeField] private AudioKey explosionSound;
[SerializeField] private AudioKey battleTheme;
void Start()
{
// 1. 2D / UI Sound:
AudioSystem.PlayUI(uiClickSound);
// 2. 3D Spatial Sound with handle control:
SoundHandle handle = AudioSystem.Play(explosionSound, transform.position, volumeScale: 0.9f, pitchScale: 1.05f);
// 3. Background Music via AudioKey or AudioClip/AudioResource:
AudioSystem.PlayMusic(battleTheme, fadeDuration: 1.5f, loop: true);
// 4. Stop / Pause / Mixer Volume Controls:
AudioSystem.SetMasterVolume(0.8f);
AudioSystem.StopMusic(fadeDuration: 1f);
AudioSystem.StopAllSounds();
}
}- Author: Yasin Öztürk
- AI Pair-Programmer: Antigravity (Google DeepMind)
This project is licensed under the MIT License - created by Yasin Öztürk.