using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.Localization; public class TextChanger : MonoBehaviour { [SerializeField] private TextMeshProUGUI text; [TextArea(1, 5)] [SerializeField] private string keyboardOrMouseText; public LocalizedString localizedKeyboardOrMouseText; [TextArea(1, 5)] [SerializeField] private string xboxControllerText; public LocalizedString localizedXboxControllerText; private void OnEnable() { InputControlManager.OnControllerInput += HandleControllerText; InputControlManager.OnKeyboardOrMouseInput += HandleKeyboardOrMouseText; if (InputControlManager.Getinstance() != null) { if (InputControlManager.Getinstance().IsUsingJoystick) { HandleControllerText(); } else { HandleKeyboardOrMouseText(); } } } private void OnDisable() { InputControlManager.OnControllerInput -= HandleControllerText; InputControlManager.OnKeyboardOrMouseInput -= HandleKeyboardOrMouseText; } private void HandleKeyboardOrMouseText() { text.text = localizedKeyboardOrMouseText.GetLocalizedString(); } private void HandleControllerText() { text.text = localizedXboxControllerText.GetLocalizedString(); } }