AudioManager
This commit is contained in:
parent
f3138df77c
commit
c37d3871d3
29
Assets/Scripts/AudioManager.cs
Normal file
29
Assets/Scripts/AudioManager.cs
Normal file
@ -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<AudionSource>();
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Scripts/AudioManager.cs.meta
Normal file
11
Assets/Scripts/AudioManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 88653155d9189b64fbf28ad102c21f11
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user