71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class menu : MonoBehaviour
|
|
{
|
|
[Header("UI Panels")]
|
|
public GameObject settingsPopUp;
|
|
public GameObject infoPanelBox;
|
|
|
|
[Header("Sound Settings")]
|
|
public Image soundIconImage;
|
|
public Sprite soundOnSprite;
|
|
public Sprite soundOffSprite;
|
|
private bool isMuted = false;
|
|
|
|
void Start()
|
|
{
|
|
|
|
if (settingsPopUp != null) settingsPopUp.SetActive(false);
|
|
if (infoPanelBox != null) infoPanelBox.SetActive(false);
|
|
}
|
|
|
|
|
|
public void StartButton(string scenename)
|
|
{
|
|
SceneManager.LoadScene(scenename);
|
|
}
|
|
|
|
|
|
public void ToggleSettings()
|
|
{
|
|
if (settingsPopUp != null)
|
|
settingsPopUp.SetActive(!settingsPopUp.activeSelf);
|
|
}
|
|
|
|
|
|
public void ToggleSound()
|
|
{
|
|
isMuted = !isMuted;
|
|
AudioListener.pause = isMuted;
|
|
|
|
if (soundIconImage != null)
|
|
soundIconImage.sprite = isMuted ? soundOffSprite : soundOnSprite;
|
|
}
|
|
|
|
|
|
public void OpenInfo()
|
|
{
|
|
if (infoPanelBox != null)
|
|
{
|
|
infoPanelBox.SetActive(true);
|
|
Debug.Log("Panel Info Aktif : " + infoPanelBox.name);
|
|
}
|
|
settingsPopUp.SetActive(false);
|
|
}
|
|
|
|
public void CloseInfo()
|
|
{
|
|
if (infoPanelBox != null) infoPanelBox.SetActive(false);
|
|
}
|
|
|
|
|
|
public void ExitGame()
|
|
{
|
|
Debug.Log("Keluar Game...");
|
|
Application.Quit();
|
|
}
|
|
} |