This commit is contained in:
Ian Woods 2026-06-30 23:27:36 -07:00
parent 2286de6fbc
commit d14305d804
10 changed files with 218 additions and 27 deletions

View file

@ -1,5 +1,5 @@
// Assets/_Project/Scripts/Audio/AudioCategory.cs
namespace TD.Audio
{
public enum AudioCategory { TowerFire, EnemyHitDeath, UI, Music }
public enum AudioCategory { TowerFire, EnemyHitDeath, UI }
}

View file

@ -0,0 +1,27 @@
// Assets/_Project/Scripts/Audio/MusicPlayer.cs
using UnityEngine;
namespace TD.Audio
{
/// <summary>
/// Plays a single looping music track for the scene it lives in.
/// Add to a GameObject in the scene, assign a clip, and it starts on load.
/// </summary>
[RequireComponent(typeof(AudioSource))]
public class MusicPlayer : MonoBehaviour
{
[SerializeField] private AudioClip clip;
[Range(0f, 1f)]
[SerializeField] private float volume = 1f;
private void Start()
{
var src = GetComponent<AudioSource>();
src.clip = clip;
src.volume = volume;
src.loop = true;
src.playOnAwake = false;
src.Play();
}
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 292ad37b9e4d1d7c28e59cf4dc1e99fa

View file

@ -13,7 +13,6 @@ Centralised voice-limited audio for the game. Lives in `Assets/_Project/Scripts/
| `TowerFire` | Tower attack sounds |
| `EnemyHitDeath` | Enemy damage and death sounds |
| `UI` | Button clicks, placement confirmation, etc. |
| `Music` | Background music |
Voice limits and volume per category are configured in the Inspector on the `AudioManager` scene GameObject.
@ -25,7 +24,6 @@ Suggested defaults:
- TowerFire: 4 voices, volume 1.0
- EnemyHitDeath: 8 voices, volume 1.0
- UI: 4 voices, volume 1.0
- Music: 2 voices, volume 0.8
## Adding a new sound-emitting component