106 lines
2.6 KiB
C#
106 lines
2.6 KiB
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class UiControl : MonoBehaviour
|
|
{
|
|
|
|
public bool IsTransisi, IsTidakPerlu;
|
|
|
|
string SaveNamaScene;
|
|
|
|
private void Awake()
|
|
{
|
|
if(IsTransisi && IsTidakPerlu)
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
// Tombol back Android
|
|
//if (Input.GetKeyDown(KeyCode.Escape))
|
|
//{
|
|
// if (!string.IsNullOrEmpty(SaveNamaScene))
|
|
// {
|
|
// SceneManager.LoadScene(SaveNamaScene);
|
|
// }
|
|
// else
|
|
// {
|
|
// // Jika belum ada scene disimpan, kembali ke scene sebelumnya dalam Build
|
|
// int previousSceneIndex = SceneManager.GetActiveScene().buildIndex - 1;
|
|
// if (previousSceneIndex >= 0)
|
|
// {
|
|
// SceneManager.LoadScene(previousSceneIndex);
|
|
// }
|
|
// }
|
|
//}
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
// Cek apakah ada popup aktif dari PopupManager
|
|
BackButtonManager popupManager = FindObjectOfType<BackButtonManager>();
|
|
if (popupManager != null && popupManager.AdaPopupAktif())
|
|
{
|
|
return; // Jangan pindah scene jika masih ada popup terbuka
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(SaveNamaScene))
|
|
{
|
|
SceneManager.LoadScene(SaveNamaScene);
|
|
}
|
|
else
|
|
{
|
|
int previousSceneIndex = SceneManager.GetActiveScene().buildIndex - 1;
|
|
if (previousSceneIndex >= 0)
|
|
{
|
|
SceneManager.LoadScene(previousSceneIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void btn_suara(int id)
|
|
{
|
|
KumpulanSuara.instance.Panggil_Sfx(0);
|
|
}
|
|
|
|
//materi
|
|
public void btn_suaraMateri(int id)
|
|
{
|
|
if (KumpulanSuara.instance != null)
|
|
{
|
|
KumpulanSuara.instance.Panggil_SuaraMateri(id);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogWarning("KumpulanSuara instance belum siap!");
|
|
}
|
|
}
|
|
|
|
|
|
public void Btn_Pindah(string nama)
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
SaveNamaScene = nama;
|
|
GetComponent<Animator>().Play("end");
|
|
}
|
|
|
|
public void Btn_Restart()
|
|
{
|
|
SaveNamaScene = SceneManager.GetActiveScene().name;
|
|
//GetComponent<Animator>().Play("end");
|
|
}
|
|
|
|
public void pindah()
|
|
{
|
|
SceneManager.LoadScene(SaveNamaScene);
|
|
}
|
|
|
|
|
|
public void Btn_KeluarGame()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
}
|