SamsonGame/Assets/Scripts/Managers/Sounds/SoundsManager.cs

32 lines
790 B
C#
Raw Normal View History

2021-12-29 20:50:11 +03:00
using UnityEngine;
public class SoundsManager : MonoBehaviour
{
[SerializeField] private SoundContent _content;
public SoundClip[] Clips => _content.Sounds[_currentSoundPack].Clips;
private int _currentSoundPack = 0;
private void Awake()
{
foreach (SoundPack pack in _content.Sounds)
{
foreach (SoundClip s in pack.Clips)
{
s.Source = gameObject.AddComponent<AudioSource>();
s.Source.clip = s.clip;
s.Source.volume = s.volume;
s.Source.pitch = s.pitch;
s.Source.loop = s.loop;
s.Source.playOnAwake = false;
}
}
}
public void ChangePackBy(int index)
{
_currentSoundPack = index;
}
}