41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public AudioSource clickSound; // ← Tambahkan AudioSource di inspector Unity
|
|
|
|
public void PindahHalaman(string sceneName)
|
|
{
|
|
//ex:menu ke materi
|
|
StartCoroutine(PlayClickThen(() => SceneManager.LoadScene(sceneName)));
|
|
}
|
|
|
|
public void OpenLink()
|
|
{
|
|
StartCoroutine(PlayClickThen(() =>
|
|
{
|
|
Application.OpenURL("https://drive.google.com/drive/folders/1C5ap9xhlv2d8xzkTgXVtd96OZ0ycZqtV?usp=sharing");
|
|
}));
|
|
}
|
|
|
|
public void QuitApplication() //out
|
|
{
|
|
StartCoroutine(PlayClickThen(() => Application.Quit()));
|
|
}
|
|
|
|
//untuk mainkan suara dulu baru jalankan aksi
|
|
private IEnumerator PlayClickThen(System.Action action)
|
|
{
|
|
if (clickSound != null)
|
|
{
|
|
clickSound.Play();
|
|
yield return new WaitForSeconds(clickSound.clip.length); //utk menunda PH selama bbrp dtik
|
|
}
|
|
|
|
action?.Invoke(); //Untuk menghindari error kalau ternyata action tidak diisi
|
|
}
|
|
}
|