]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Audio/AudioManager.cs
Toneffekt für Knöpfe
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Audio / AudioManager.cs
1 using UnityEngine.Audio;
2 using System;
3 using UnityEngine;
4
5 public class AudioManager : MonoBehaviour
6 {
7     public Sound[] sounds;
8
9     void Awake()
10     {
11        foreach(Sound s in sounds)
12         {
13             s.source = gameObject.AddComponent<AudioSource>();
14             s.source.clip = s.clip;
15
16             s.source.volume = s.volume;
17             s.source.pitch = s.pitch;
18         } 
19     }
20
21     public void Play(string name)
22     {
23         Sound s = Array.Find(sounds, sound => sound.name == name);
24         s.source.Play();
25     }
26
27     public void Stop(string name) 
28     {
29         Sound s = Array.Find(sounds, sound => sound.name == name);
30         s.source.Stop();
31     }
32 }