Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

Commit 27acef5

Browse files
committed
HideMenu script added
1 parent 3deafc8 commit 27acef5

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Assets/Scripts/hideMenu.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
public class hideMenu : MonoBehaviour
7+
{
8+
[SerializeField] private GameObject menu;
9+
// Start is called before the first frame update
10+
public void checkIfMenuIsHidden()
11+
{
12+
if (menu.active)
13+
{
14+
HideMenu();
15+
}
16+
else
17+
{
18+
ShowMenu();
19+
}
20+
}
21+
22+
void HideMenu()
23+
{
24+
menu.SetActive(false);
25+
Cursor.lockState = CursorLockMode.Locked;
26+
}
27+
28+
void ShowMenu()
29+
{
30+
menu.SetActive(true);
31+
Cursor.lockState = CursorLockMode.None;
32+
}
33+
34+
void Update()
35+
{
36+
if (Input.GetKey(KeyCode.Escape))
37+
{
38+
ShowMenu();
39+
}
40+
}
41+
}

Assets/Scripts/hideMenu.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)