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

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 83f3ae347a44c6e1da40d37aab1ba991
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 619ed0e77e6deb6049c09744dff9687a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/_Project/Audio/music/menu/menu_1.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: d4626563ad3c90179b247207e7b9f0be
AudioImporter:
externalObjects: {}
serializedVersion: 8
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -2261,9 +2261,6 @@ MonoBehaviour:
- category: 2
maxVoices: 4
volume: 0.5
- category: 3
maxVoices: 4
volume: 0.5
--- !u!4 &176580462
Transform:
m_ObjectHideFlags: 0
@ -7339,6 +7336,150 @@ Transform:
m_Children: []
m_Father: {fileID: 1097152085}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &516125084
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 516125087}
- component: {fileID: 516125086}
- component: {fileID: 516125085}
m_Layer: 0
m_Name: MusicPlayer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &516125085
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 516125084}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 292ad37b9e4d1d7c28e59cf4dc1e99fa, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::TD.Audio.MusicPlayer
clip: {fileID: 8300000, guid: d4626563ad3c90179b247207e7b9f0be, type: 3}
volume: 0.632
--- !u!82 &516125086
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 516125084}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_Resource: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!4 &516125087
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 516125084}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &531325306
GameObject:
m_ObjectHideFlags: 0
@ -28772,3 +28913,4 @@ SceneRoots:
- {fileID: 1889390964}
- {fileID: 2139601601}
- {fileID: 176580462}
- {fileID: 516125087}

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