44 lines
946 B
C#
44 lines
946 B
C#
using UnityEngine;
|
|
|
|
public class MusikAbadi : MonoBehaviour
|
|
{
|
|
public static MusikAbadi instance;
|
|
|
|
[Header("=== SPEAKER ===")]
|
|
public AudioSource speakerBGM;
|
|
public AudioSource speakerSFX; // <-- Tambahan speaker buat klik
|
|
|
|
[Header("=== KASET SUARA ===")]
|
|
public AudioClip kasetKlik; // <-- Kaset suara pop/klik
|
|
|
|
void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
transform.SetParent(null);
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
public void MuteMusik()
|
|
{
|
|
if (speakerBGM != null)
|
|
{
|
|
speakerBGM.mute = !speakerBGM.mute;
|
|
}
|
|
}
|
|
|
|
// Fungsi pemutar bunyi klik yang abadi
|
|
public void BunyiKlik()
|
|
{
|
|
if (speakerSFX != null && kasetKlik != null)
|
|
{
|
|
speakerSFX.PlayOneShot(kasetKlik);
|
|
}
|
|
}
|
|
} |