2021-01-31 10:28:34 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Audio;
|
2021-01-31 10:43:20 +00:00
|
|
|
|
using System;
|
2021-01-31 10:28:34 +00:00
|
|
|
|
|
|
|
|
|
public class Audiomanager : MonoBehaviour
|
|
|
|
|
{
|
2021-01-31 10:43:20 +00:00
|
|
|
|
public AudioSound[] clips;
|
2021-01-31 10:28:34 +00:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
2021-01-31 10:43:20 +00:00
|
|
|
|
foreach (AudioSound c in clips)
|
2021-01-31 10:28:34 +00:00
|
|
|
|
{
|
2021-01-31 10:52:14 +00:00
|
|
|
|
c.source = gameObject.AddComponent<AudioSource>();
|
2021-01-31 10:43:20 +00:00
|
|
|
|
c.source.clip = c.clip;
|
|
|
|
|
c.source.volume = c.volume;
|
|
|
|
|
c.source.pitch = c.pitch;
|
2021-01-31 10:28:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Play(string name)
|
|
|
|
|
{
|
2021-01-31 10:43:20 +00:00
|
|
|
|
AudioSound s = Array.Find(clips, sound => sound.name == name);
|
|
|
|
|
s.source.Play();
|
2021-01-31 10:28:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|