ReisenTasker/Assets/Scripts/GameManager.cs
2026-09-04 11:51:28 -07:00

68 lines
1 KiB
C#

using System;
using UnityEngine;
public class GameManager : MonoBehaviour
{
#region Statication
public static GameManager instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
DontDestroyOnLoad(this);
instance = this;
}
#endregion
//this is just for general functions and variables that will be reused
public Camera camera;
public GameObject pauseMenu;
public void OnSceneChange()
{
camera = Camera.main;
}
public Vector3 GetMouseWorldPos()
{
return camera.ScreenToWorldPoint(Input.mousePosition) + new Vector3(0,0,10);
}
public void SetPause(bool state)
{
if (state)
{
Time.timeScale = 0f;
}
else
{
Time.timeScale = 1f;
}
}
public void SetPauseMenu()
{
if (!pauseMenu.activeSelf)
{
SetPause(true);
pauseMenu.SetActive(true);
}
else
{
pauseMenu.SetActive(false);
SetPause(false);
}
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
SetPauseMenu();
}
}
}