using BitStrap; using UnityEngine; using UnityEngine.UI; namespace VRKeyboard.Utils { public class KeyboardManager : MonoBehaviour { [Header("User defined")] [Tooltip("If the character is uppercase at the initialization")] public bool isUppercase; public int maxInputLength; [Header("UI Elements")] public Text inputText; public InputField inputField; [Header("Essentials")] public Transform keys; private Key[] keyList; private bool capslockFlag; [Header("ColorBlock")] public ColorBlock colorBlock = default(ColorBlock); public Font font; private string Input { get { return inputText.text; } set { inputText.text = value; } } private void Awake() { keyList = keys.GetComponentsInChildren(); } private void Start() { Key[] array = keyList; foreach (Key key in array) { key.OnKeyClicked += GenerateInput; } capslockFlag = isUppercase; CapsLock(); } public void Backspace() { if (Input.Length > 0) { Input = Input.Remove(Input.Length - 1); } } public void Clear() { Input = string.Empty; } public void CapsLock() { Key[] array = keyList; foreach (Key key in array) { if (key is Alphabet) { key.CapsLock(capslockFlag); } } capslockFlag = !capslockFlag; } public void Shift() { Key[] array = keyList; foreach (Key key in array) { if (key is Shift) { key.ShiftKey(); } } } public void GenerateInput(string s) { if (maxInputLength <= 0 || Input.Length < maxInputLength) { Input += s; } } public void ChangeInputField(InputField newInputField) { inputField = newInputField; if ((bool)inputField) { maxInputLength = inputField.characterLimit; Input = inputField.text; } } public void SendText() { if ((bool)inputField) { inputField.text = Input; } if ((bool)inputField && (bool)inputField.GetComponentInParent()) { HUDManager.Instance.hudMultiplayer.SendInputFieldMessage(); Clear(); } else { Close(); } } public void Close() { if ((bool)inputField && (bool)inputField.GetComponentInParent()) { GameController.Instance.fishingPlayer.EnterChat(false); HUDManager.Instance.hudMultiplayer.EnterInputMode(false); GameController.Instance.fishingPlayer.vrPlayertUIInput.TurnOnUIController(false); } VRManager.Instance.HideKeyboard(); } [Button] public void FixButtonsHover() { Key[] componentsInChildren = keys.GetComponentsInChildren(); Key[] array = componentsInChildren; foreach (Key key in array) { Button component = key.GetComponent