ClientServer/Client/Assets/Scripts/UI/ControlsButtons.cs
TG9six 03a642d635 first push
first push
2025-09-06 17:17:39 +04:00

35 lines
1012 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ControlsButtons : MonoBehaviour
{
[SerializeField] Image buttonImage;
[SerializeField] TMP_Text buttonText;
[SerializeField] Button thisButton;
private Color unselectedColor = new Color(0.227451f, 0.227451f, 0.227451f, 1f);
private Color selectedColor = new Color(1f, 0.4640272f, 0f, 1f);
public void SetState(bool isInteractable, GameObject connectedMenu)
{
if (UIManager.Instance.loginScreen) return;
if (!UsingGamepad())
{
thisButton.interactable = isInteractable;
}
buttonText.color = isInteractable ? Color.white : Color.black;
buttonImage.color = isInteractable ? unselectedColor : selectedColor;
connectedMenu.SetActive(!isInteractable);
}
public Button GetButton() => thisButton;
private bool UsingGamepad() => Player.Instance.GetInputHandler().UsingGamePad;
}