Files

41 lines
1.1 KiB
C#
Raw Permalink Normal View History

2022-03-12 19:55:32 +01:00
using UnityEngine;
2023-08-29 17:42:32 +03:00
using UnityEngine.EventSystems;
2023-10-04 15:28:25 +03:00
using UnityEngine.UI;
2022-03-12 19:55:32 +01:00
public class ControlsMenu : BaseMenu
{
2023-08-29 17:42:32 +03:00
[SerializeField] private InputManager _inputManager = default;
2022-12-14 18:33:44 +02:00
[SerializeField] private GameObject[] _controlSchemes = default;
private Audio _audio;
private int _currentControlSchemeIndex;
2022-03-12 19:55:32 +01:00
2022-12-14 18:33:44 +02:00
void Awake()
{
_audio = GetComponent<Audio>();
}
2022-07-15 00:01:28 +03:00
2022-12-14 18:33:44 +02:00
public void ToggleControlsScheme()
{
_audio.Sound("Select").Play();
_currentControlSchemeIndex++;
if (_currentControlSchemeIndex >= _controlSchemes.Length)
{
_currentControlSchemeIndex = 0;
}
for (int i = 0; i < _controlSchemes.Length; i++)
{
_controlSchemes[i].SetActive(false);
}
_controlSchemes[_currentControlSchemeIndex].SetActive(true);
}
2023-08-29 17:42:32 +03:00
private void OnDisable()
{
2023-10-09 12:39:56 +03:00
PreviousSelectable.Select();
2023-08-29 17:42:32 +03:00
_inputManager.SetPrompts(_inputManager.PreviousPrompts);
2023-09-26 01:27:40 +03:00
if (HotBarToggle.PreviousSelected != null)
EventSystem.current.SetSelectedGameObject(HotBarToggle.PreviousSelected.gameObject);
2023-08-29 17:42:32 +03:00
}
2022-03-12 19:55:32 +01:00
}