Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PauseMenu : MonoBehaviour
- {
- public Transform pause;
- void Start()
- {
- Cursor.lockState = CursorLockMode.Locked;
- Cursor.visible = false;
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- if (pause.gameObject.activeInHierarchy == false)
- {
- Camera.main.GetComponent<CameraController>().enabled = false;
- Time.timeScale = 0;
- pause.gameObject.SetActive(true);
- Cursor.visible = true;
- }
- else
- {
- Camera.main.GetComponent<CameraController>().enabled = true;
- Time.timeScale = 1;
- pause.gameObject.SetActive(false);
- Cursor.visible = false;
- }
- }
- if (pause.gameObject.activeInHierarchy == false)
- {
- Camera.main.GetComponent<CameraController>().enabled = true;
- Time.timeScale = 1;
- Cursor.visible = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement