This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Game/InGameMenuManager.cs

52 lines
1.3 KiB
C#
Raw Permalink Normal View History

using UnityEngine;
using UnityEngine.UI;
public class InGameMenuManager : MonoBehaviour
{
2023-06-01 17:03:48 +02:00
[SerializeField] private Button settingsButton;
[SerializeField] private Button returnToMenuButton;
[SerializeField] private Scrollbar sensitivitySlider;
[SerializeField] private Scrollbar volumeSlider;
private InGameManager gameManager;
private Animator menuAnimator;
private PlayerComponent player;
// Start is called before the first frame update
2023-06-01 17:03:48 +02:00
private void Start()
{
2023-06-01 17:03:48 +02:00
menuAnimator = GetComponent<Animator>();
settingsButton.onClick.AddListener(SettingsClicked);
returnToMenuButton.onClick.AddListener(SettingsUnClicked);
2023-06-01 17:03:48 +02:00
player = FindObjectOfType(typeof(PlayerComponent)) as PlayerComponent;
gameManager = FindObjectOfType<InGameManager>();
}
2023-06-01 17:03:48 +02:00
// Update is called once per frame
private void Update()
{
}
2023-06-01 17:03:48 +02:00
private void SettingsClicked()
{
2023-06-01 17:03:48 +02:00
menuAnimator.SetBool("SettingsOpen", true);
}
2023-06-01 17:03:48 +02:00
private void SettingsUnClicked()
{
menuAnimator.SetBool("SettingsOpen", false);
}
2023-06-01 17:03:48 +02:00
public void UpdateSensitivity()
{
2023-06-01 17:03:48 +02:00
player.SetSensitivity(sensitivitySlider.value * 4f);
}
2023-06-01 17:03:48 +02:00
public void UpdateVolume()
{
2023-06-01 17:03:48 +02:00
gameManager.SetVolume(volumeSlider.value * 2);
}
2023-06-01 17:03:48 +02:00
}