Add simple audio system

This commit is contained in:
WillJeynes
2026-08-25 17:22:12 +01:00
parent 4c3f94dba1
commit c92d5a633a
20 changed files with 346 additions and 23 deletions
+38
View File
@@ -0,0 +1,38 @@
using System.Collections.Generic;
using UnityEngine;
using Utils;
using Utils.Utils;
public class AudioManager : Singleton<AudioManager>
{
private AudioSource audioSource;
[SerializeField]
private List<GameEntry<AudioClip>> clips = new List<GameEntry<AudioClip>>();
[SerializeField]
private List<AudioClip> speech = new List<AudioClip>();
private
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
audioSource = GetComponent<AudioSource>();
audioSource.pitch = 1;
}
public void PlaySound(string type)
{
audioSource.pitch = 1f;
audioSource.PlayOneShot(clips.ByKey(type));
}
public void PlaySpeechSound(bool pitchDown)
{
int index = Random.Range(0, speech.Count);
audioSource.pitch = pitchDown ? 0.5f:1f;
audioSource.PlayOneShot(speech[index], 1.5f);
}
}