////////////////////////////////////////////////////////////////////////// private void InitializeKeyboard(string prefilledText, EKeyboardMode keyboardMode = EKeyboardMode.Default, bool startCapitalized = true, bool alllowMultiline = false) { if (keyboardMode == EKeyboardMode.Password && startCapitalized) { Debug.LogWarning("[Accessibility] Password Input fields should not start capitalized. Ignoring parameter."); startCapitalized = false; } m_KeyboardMode = keyboardMode; m_StartCapitalized = startCapitalized; m_EditedText = prefilledText; m_OriginalText = prefilledText; m_CursorBlinkTimer = m_CursorBlinkDuration; m_AllowMutliLine = alllowMultiline; // Use system language if supported, or English as a fallback if (SupportsSystemLanguage()) { m_PreferredLanguage = Application.systemLanguage; } else { m_PreferredLanguage = SystemLanguage.English; } SetKeyboardLayoutForLanguage(m_PreferredLanguage); // Depending on whether this is multiline or not, change the description of the Return key m_ReturnKey.GetComponent <UAP_BaseElement>().SetCustomText(alllowMultiline ? UAP_AccessibilityManager.Localize_Internal("Keyboard_Return") : UAP_AccessibilityManager.Localize_Internal("Keyboard_Done")); // Start with shift pressed, but only when the AutoSetShiftMode(); // Make voice announcement 'keyboard visible' (localized) and whether shift key is on UAP_AccessibilityManager.Say(UAP_AccessibilityManager.Localize_Internal("Keyboard_Showing")); UAP_AccessibilityManager.Say(UAP_AccessibilityManager.Localize_Internal(m_ShiftModeActive ? "Keyboard_ShiftOn" : "Keyboard_ShiftOff")); // #UAP_Keyboard_Backlog Play proper incoming animation }
public static UAP_VirtualKeyboard ShowOnscreenKeyboard(string prefilledText = "", EKeyboardMode keyboardMode = EKeyboardMode.Default, bool startCapitalized = true, bool alllowMultiline = false) { // Force remove any previously existing keyboard if (Instance != null) { DestroyImmediate(Instance.gameObject); } // Clear any previous listeners ClearAllListeners(); // Instantiate the keyboard var newKeyboard = (Instantiate(Resources.Load(PrefabPath)) as GameObject).GetComponent <UAP_VirtualKeyboard>(); // Initialize with the given parameters newKeyboard.InitializeKeyboard(prefilledText, keyboardMode, startCapitalized, alllowMultiline); Instance = newKeyboard; return(newKeyboard); }