using EasyTalk.Controller; using UnityEngine; #if ENABLE_INPUT_SYSTEM using UnityEngine.InputSystem; #endif namespace EasyTalk.Demo { /// /// Provides controls and functionality to allow the player to easily change languages in the EasyTalk Demo. /// public class LanguageControl : MonoBehaviour { /// /// The PlayerController used to control the player's position and camera. /// [SerializeField] private PlayerController playerController; /// /// The component which contains the buttons for changing languages. /// [SerializeField] private GameObject languageButtonContainer; #if ENABLE_INPUT_SYSTEM /// /// The input action asset in which the player controls are configured. /// [SerializeField] private InputActionAsset playerControlInputActions; #endif private void Awake() { #if ENABLE_INPUT_SYSTEM InputAction changeLanguageAction = playerControlInputActions.FindAction("ChangeLanguage"); if (changeLanguageAction != null) { changeLanguageAction.performed += delegate { playerController.DisableCameraRotation(); languageButtonContainer.SetActive(true); }; } #endif } private void Update() { #if !ENABLE_INPUT_SYSTEM if (Input.GetKeyDown(KeyCode.L)) { playerController.DisableCameraRotation(); languageButtonContainer.SetActive(true); } #endif } /// /// Changes the language being used by the dialogue system. /// /// The ISO-639 language code to switch to. public void SetLanguage(string languageCode) { EasyTalkGameState.Instance.Language = languageCode; } } }