34 lines
1009 B
C#
34 lines
1009 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
public class OptionsButton : 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;
|
|
}
|