1
0
Fork 0
This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
Global-Game-Jam-2019/Assets/Scripts/MainMenu.cs
2019-01-27 14:54:55 +01:00

40 lines
1,013 B
C#

using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
{
public Button playButton;
public Button exitButton;
public Button helpButton;
public GameObject helpCanvas;
public Text bestScoreText;
private bool helpCanvasVisible = false;
// Start is called before the first frame update
void Start()
{
playButton.onClick.AddListener(OnPlayButtonClick);
exitButton.onClick.AddListener(OnExitButtonClick);
helpButton.onClick.AddListener(OnHelpButtonClick);
bestScoreText.text = PlayerPrefs.GetInt("best_score", 0).ToString();
}
void OnPlayButtonClick()
{
SceneManager.LoadScene("MainScene");
}
void OnExitButtonClick()
{
Application.Quit();
}
void OnHelpButtonClick()
{
helpCanvasVisible = !helpCanvasVisible;
helpCanvas.SetActive(helpCanvasVisible);
}
}