You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using UnityEngine;
|
|
|
|
using System.Collections;
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
public class PauseMenu : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
public GameObject pauseMenu;
|
|
|
|
private bool paused = false;
|
|
|
|
|
|
|
|
public GameObject homeObj;
|
|
|
|
public PlayerMovement mov;
|
|
|
|
private Inputs Input;
|
|
|
|
private InputAction pause;
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
pause.performed += _ => ToggleActive();
|
|
|
|
}
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
Input = new Inputs();
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
pause = Input.Movement.Pause;
|
|
|
|
pause.Enable();
|
|
|
|
}
|
|
|
|
private void OnDisable()
|
|
|
|
{
|
|
|
|
pause.Disable();
|
|
|
|
}
|
|
|
|
public void ResumeGame()
|
|
|
|
{
|
|
|
|
paused = false;
|
|
|
|
}
|
|
|
|
public void GoToHome()
|
|
|
|
{
|
|
|
|
mov.rb.position = homeObj.transform.position;
|
|
|
|
paused = false;
|
|
|
|
}
|
|
|
|
private void ToggleActive()
|
|
|
|
{
|
|
|
|
if (paused)
|
|
|
|
{
|
|
|
|
pauseMenu.SetActive(true);
|
|
|
|
Time.timeScale = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pauseMenu.SetActive(false);
|
|
|
|
Time.timeScale = 1;
|
|
|
|
}
|
|
|
|
paused = !paused;
|
|
|
|
}
|
|
|
|
}
|