PBG2H23ABR_PBG2H23AKL_PMC_P.../Plunderblock/Assets/Scripts/ScriptsJan/InputScripts/MenuScript.cs

57 lines
1.3 KiB
C#
Raw Normal View History

2024-08-13 21:11:05 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MenuScript : MonoBehaviour
{
[SerializeField] int menuLayer; // Shows at what layer the current Menu is and what esc should do
[SerializeField] GameObject defaultMenu;
[SerializeField] GameObject settingsMenu;
// Update is called once per frame
void Update()
{
escPressed();
}
public void escPressed()
{
if(Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown("o"))
{
if(menuLayer == 0)
{
defaultMenu.SetActive(true);
Cursor.lockState = CursorLockMode.None;
menuLayer = 1;
}
else if(menuLayer == 1)
{
defaultMenu.SetActive(false);
lockCursor();
menuLayer = 0;
}
else if(menuLayer == 2)
{
settingsMenu.SetActive(false);
defaultMenu.SetActive(true);
menuLayer = 1;
}
}
}
public void setMenuLayer(int i)
{
menuLayer = i;
}
public void quit()
{
Application.Quit();
}
public void lockCursor()
{
Cursor.lockState = CursorLockMode.Locked;
}
}