Added basic sound manager

This commit is contained in:
SpoodyTheOne 2024-02-03 14:22:53 +01:00
parent 49360ba4e8
commit c9ca60b19f
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,24 @@
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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95cd959a7274673b79164bc2664ed6e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: