Project Restructure (PLEASE UPDATE AFTER COMMIT)
This commit is contained in:
46
Assets/Old/Hub/HubManager.cs
Normal file
46
Assets/Old/Hub/HubManager.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HubManager : MonoBehaviour
|
||||
{
|
||||
public GameObject gameButtonsParent;
|
||||
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
UnloadGameScene();
|
||||
SceneManager.LoadScene(sceneName, LoadSceneMode.Additive);
|
||||
}
|
||||
|
||||
public void UnloadGameScene()
|
||||
{
|
||||
try
|
||||
{
|
||||
SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(1));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.Log("No game scene to unload");
|
||||
}
|
||||
|
||||
ChangeGameButtonsInteractability(false);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (InputSystem.GetDevice<Keyboard>().escapeKey.wasPressedThisFrame)
|
||||
{
|
||||
UnloadGameScene();
|
||||
ChangeGameButtonsInteractability(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeGameButtonsInteractability(bool interactable)
|
||||
{
|
||||
foreach (Transform button in gameButtonsParent.transform)
|
||||
{
|
||||
button.GetComponent<Button>().interactable = interactable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user