25 lines
537 B
C#
25 lines
537 B
C#
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);
|
|
}
|
|
}
|