77 lines
1.9 KiB
C#
77 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
public class ControlsMenu : MonoBehaviour
|
|
{
|
|
[SerializeField] private ControlsButtons keyboardButton;
|
|
[SerializeField] private ControlsButtons controllerButton;
|
|
|
|
[Space]
|
|
|
|
[SerializeField] private GameObject keyboardSettings;
|
|
[SerializeField] private GameObject controllerSettings;
|
|
|
|
[Space]
|
|
|
|
[SerializeField] private Image gamepadKeybindsImage;
|
|
[SerializeField] private Sprite xboxKeybindsSprite;
|
|
[SerializeField] private Sprite playstationKeybindsSprite;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (!UIManager.Instance.getInterface<GameObject>("LoginScreen").activeInHierarchy)
|
|
{
|
|
SetInitialState();
|
|
}
|
|
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
keyboardButton.GetButton().onClick.AddListener(OnKeyboardButton);
|
|
controllerButton.GetButton().onClick.AddListener(OnControllerButton);
|
|
|
|
gamepadKeybindsImage.sprite = xboxKeybindsSprite;
|
|
}
|
|
|
|
private void SetInitialState()
|
|
{
|
|
keyboardButton.SetState(false, keyboardSettings);
|
|
controllerButton.SetState(true, controllerSettings);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
InputHandler inputHandler = Player.Instance.GetInputHandler();
|
|
if (inputHandler.UsingGamePad)
|
|
{
|
|
if (inputHandler.IsXboxController)
|
|
{
|
|
gamepadKeybindsImage.sprite = xboxKeybindsSprite;
|
|
}
|
|
else
|
|
{
|
|
gamepadKeybindsImage.sprite = playstationKeybindsSprite;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnKeyboardButton()
|
|
{
|
|
keyboardButton.SetState(false, keyboardSettings);
|
|
controllerButton.SetState(true, controllerSettings);
|
|
|
|
}
|
|
|
|
private void OnControllerButton()
|
|
{
|
|
keyboardButton.SetState(true, keyboardSettings);
|
|
controllerButton.SetState(false, controllerSettings);
|
|
|
|
}
|
|
|
|
}
|