There is also overhauled camera zoom behavior, an update to the match logic, tweaks to the main menu scene.
105 lines
2.5 KiB
C#
105 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Reflection;
|
|
using log4net;
|
|
using Managers;
|
|
using SlimUI.ModernMenu;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.SceneManagement;
|
|
public class PauseMenu : MonoBehaviour
|
|
{
|
|
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
private Canvas Canvas;
|
|
public GameObject Camera;
|
|
public GameObject UIEventSystem;
|
|
public GameObject PauseMenuButtons;
|
|
public GameObject ExitConfirmDialog;
|
|
public GameObject FocusButtonExitConfirm;
|
|
public GameObject FocusButtonPause;
|
|
|
|
private EventSystem eventSystem;
|
|
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
Canvas = gameObject.GetComponent<Canvas>();
|
|
Canvas.enabled = false;
|
|
PauseMenuButtons.SetActive(false);
|
|
eventSystem = UIEventSystem.GetComponent<EventSystem>();
|
|
UIEventSystem.SetActive(false);
|
|
}
|
|
|
|
public void Show(Transform transform)
|
|
{
|
|
gameObject.transform.SetPositionAndRotation(
|
|
transform.position,
|
|
transform.rotation);
|
|
Canvas.enabled = true;
|
|
Camera.SetActive(true);
|
|
UIEventSystem.SetActive(true);
|
|
PauseMenuButtons.SetActive(true);
|
|
ExitConfirmDialog.SetActive(false);
|
|
eventSystem.SetSelectedGameObject(FocusButtonPause, null);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
Canvas.enabled = false;
|
|
Camera.SetActive(false);
|
|
UIEventSystem.SetActive(false);
|
|
}
|
|
|
|
public void OnContinue()
|
|
{
|
|
MatchManager.G.PausePressed();
|
|
}
|
|
|
|
public void OnMainMenu()
|
|
{
|
|
UIManager.G.MatchMusic.FadeOutAudio(0.3f, true);
|
|
StartCoroutine(StartSceneTransition());
|
|
}
|
|
|
|
private IEnumerator StartSceneTransition()
|
|
{
|
|
Canvas.enabled = false;
|
|
SceneManager.LoadScene((int)SceneEnum.MainMenu, LoadSceneMode.Additive);
|
|
yield return new WaitForSeconds(0.2f);
|
|
GameObject menu = GameObject.Find("Main Menu Camera");
|
|
if (menu != null && menu.TryGetComponent(out SlimUIMainMenu menuScript))
|
|
{
|
|
UIManager.G.HideHUD();
|
|
menuScript.MenuTransition(Camera.GetComponent<Camera>().transform,
|
|
GameManager.G.CurrentScene);
|
|
}
|
|
else
|
|
{
|
|
Log.Error("Can't transition back to main menu. Menu camera or script not found.");
|
|
}
|
|
}
|
|
|
|
public void OnExit()
|
|
{
|
|
PauseMenuButtons.SetActive(false);
|
|
ExitConfirmDialog.SetActive(true);
|
|
eventSystem.SetSelectedGameObject(FocusButtonExitConfirm, null);
|
|
}
|
|
|
|
public void OnConfirmedExit()
|
|
{
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#else
|
|
Application.Quit();
|
|
#endif
|
|
}
|
|
|
|
public void OnBackToPauseMenu()
|
|
{
|
|
PauseMenuButtons.SetActive(true);
|
|
ExitConfirmDialog.SetActive(false);
|
|
eventSystem.SetSelectedGameObject(FocusButtonPause, null);
|
|
}
|
|
|
|
}
|