MIF_E31222823/Assets/SCRIPT/SoundManager.cs

38 lines
744 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SoundManager : MonoBehaviour
{
public static SoundManager Instance { get; set; }
public AudioSource music;
private void Awake() // ← diperbaiki di sini
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(this.gameObject); // Tambahkan ".gameObject" untuk lebih tepat
}
else
{
Destroy(gameObject);
}
}
void Start()
{
// Bisa diisi kalau perlu
}
void Update()
{
// Bisa diisi kalau perlu
}
public void MuteSound()
{
music.mute = !music.mute; // Cara singkat toggle mute
}
}