death sounds, build sounds, better audio management

This commit is contained in:
Ian Woods 2026-06-30 23:12:27 -07:00
parent a7b2d1854d
commit 9f25844657
26 changed files with 313 additions and 12 deletions

View file

@ -58,7 +58,7 @@ namespace TD.Audio
}
}
public void Play(AudioClip clip, AudioCategory category, float pitch = 1f)
public void Play(AudioClip clip, AudioCategory category, float pitch = 1f, float volume = 1f)
{
if (clip == null) return;
if (!pools.TryGetValue(category, out var pool)) return;
@ -66,6 +66,7 @@ namespace TD.Audio
int idx = indices[category];
var src = pool[idx % pool.Length];
src.pitch = pitch;
src.volume = volume;
src.clip = clip;
src.Play();
indices[category] = idx + 1;

View file

@ -0,0 +1,16 @@
// Assets/_Project/Scripts/Audio/SoundConfig.cs
using UnityEngine;
namespace TD.Audio
{
[System.Serializable]
public struct SoundConfig
{
public AudioClip clip;
[Range(0f, 1f)] public float volume;
[Range(0f, 3f)] public float minPitch;
[Range(0f, 3f)] public float maxPitch;
public float RandomPitch() => Random.Range(minPitch, maxPitch);
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fce44aba7ccbe4224aeae2faa74b978f