From c37d3871d3153c672eeadaf3b509a94dd9f6a9fc Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sun, 31 Jan 2021 11:28:34 +0100 Subject: [PATCH] AudioManager --- Assets/Scripts/AudioManager.cs | 29 +++++++++++++++++++++++++++++ Assets/Scripts/AudioManager.cs.meta | 11 +++++++++++ 2 files changed, 40 insertions(+) create mode 100644 Assets/Scripts/AudioManager.cs create mode 100644 Assets/Scripts/AudioManager.cs.meta diff --git a/Assets/Scripts/AudioManager.cs b/Assets/Scripts/AudioManager.cs new file mode 100644 index 0000000..7e91745 --- /dev/null +++ b/Assets/Scripts/AudioManager.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Audio; + +public class Audiomanager : MonoBehaviour +{ + public [] clips; + // Start is called before the first frame update + void Awake() + { + foreach (AudioClip c in clips) + { + s.source = gameObject.AddComponent(); + s.source.clip = s.clip; + s.source.volume = s.volume; + s.source.pitch = s.pitch; + + + } + } + + // Update is called once per frame + void Play(string name) + { + Sound s = Array.Find(clips, sound => sound.name == name); + s.source.Play() + } +} diff --git a/Assets/Scripts/AudioManager.cs.meta b/Assets/Scripts/AudioManager.cs.meta new file mode 100644 index 0000000..a5be51a --- /dev/null +++ b/Assets/Scripts/AudioManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 88653155d9189b64fbf28ad102c21f11 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: