Made the Hub buttons not interactable when in a game
This commit is contained in:
@@ -986,6 +986,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 3fbcc366ef6e3480399963dee7cad1cd, type: 3}
|
m_Script: {fileID: 11500000, guid: 3fbcc366ef6e3480399963dee7cad1cd, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
gameButtonsParent: {fileID: 704873499}
|
||||||
--- !u!4 &642245994
|
--- !u!4 &642245994
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class HubManager : MonoBehaviour
|
public class HubManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public GameObject gameButtonsParent;
|
||||||
|
|
||||||
public void LoadScene(string sceneName)
|
public void LoadScene(string sceneName)
|
||||||
{
|
{
|
||||||
UnloadGameScene();
|
UnloadGameScene();
|
||||||
@@ -20,6 +23,8 @@ public class HubManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Debug.Log("No game scene to unload");
|
Debug.Log("No game scene to unload");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChangeGameButtonsInteractability(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@@ -27,6 +32,15 @@ public class HubManager : MonoBehaviour
|
|||||||
if (InputSystem.GetDevice<Keyboard>().escapeKey.wasPressedThisFrame)
|
if (InputSystem.GetDevice<Keyboard>().escapeKey.wasPressedThisFrame)
|
||||||
{
|
{
|
||||||
UnloadGameScene();
|
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