AudioManager

This commit is contained in:
GamerClassN7 2021-01-31 11:28:34 +01:00
parent f3138df77c
commit c37d3871d3
2 changed files with 40 additions and 0 deletions

View 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()
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88653155d9189b64fbf28ad102c21f11
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: