For something like an AudioManager or GameManager,there’s only ONE AudioManager in the entire game world. So to me, it seems logical design-wise to make a Manager class static. Here is my current AudioManager class.
public class AudioManager : MonoBehaviour
{
public AudioClip[] AudioClips;
private AudioSource _audioSourceComponent;
void Start ()
{
_audioSourceComponent = this.GetComponent<AudioSource>();
PlaySound(0);
}
public void PlaySound(int clipIndex)
{
_audioSourceComponent.clip = AudioClips[clipIndex];
_audioSourceComponent.Play();
}
public void PlaySound(int clipIndex, float delayTime)
{
_audioSourceComponent.clip = AudioClips[clipIndex];
_audioSourceComponent.PlayDelayed(delayTime);
}
}
If I do not make this class static, I will have to create a public AudioManager and drag and drop this class every time I want a reference to the methods here that will enable me to play audio. It’s just a little more work, and it confuses me. I would like to say AudioManager.PlaySound instead of getting a reference to AudioManager, calling it AudioManager (redundant), and then AudioManager.PlaySound.
Does it make sense design-wise to make it static? I know one problem is, when I tried to make everything static, I could not use GetComponent. Can someone explain this to me?