fgm24/Assets/Scripts/SoundManager.cs

25 lines
537 B
C#
Raw Permalink Normal View History

2024-02-03 14:22:53 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundManager : MonoBehaviour
{
private static SoundManager INSTANCE;
private AudioSource source;
void awake() {
if (SoundManager.INSTANCE == null) {
SoundManager.INSTANCE = this;
DontDestroyOnLoad(gameObject);
return;
}
Destroy(gameObject);
}
static void PlaySound(AudioClip clip, float volume = 1) {
INSTANCE.source.PlayOneShot(clip, volume);
}
}