32 lines
790 B
C#
32 lines
790 B
C#
|
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;
|
|||
|
}
|
|||
|
}
|