bool ShowTouchScreenKeyboard(GUIBase_Button inInput, E_KeyBoardMode inMode, KeyboardClose inCloseDelegate, string inText, string inPlaceholder, int inMaxTextLength) { if (m_ActiveInput != null || inInput == null || inCloseDelegate == null) { return(false); } /// setup arguments for Touch keyboard... TouchScreenKeyboardType keyboardType = inMode == E_KeyBoardMode.Email ? TouchScreenKeyboardType.EmailAddress : inMode == E_KeyBoardMode.Password ? TouchScreenKeyboardType.Default : TouchScreenKeyboardType.ASCIICapable; bool autocorrection = false; //inMode != E_KeyBoardMode.Password; bool secure = inMode == E_KeyBoardMode.Password; // open keyboard... TouchScreenKeyboard keyboard = TouchScreenKeyboard.Open(inText, keyboardType, autocorrection, false, secure, false, inPlaceholder); if (keyboard == null) { return(false); } m_ActiveInput = inInput; StartCoroutine(ProcessKeyboardInput(keyboard, inCloseDelegate, inText, inMaxTextLength)); return(true); }
public bool ShowKeyboard(GUIBase_Button inInput, E_KeyBoardMode inMode, KeyboardClose inCloseDelegate, string inText, int inMaxTextLength = -1) { return(ShowKeyboard(inInput, inMode, inCloseDelegate, inText, string.Empty, inMaxTextLength)); }
IEnumerator ProcessKeyboardInput(TouchScreenKeyboard inKeyboard, KeyboardClose inCloseDelegate, string inText, int inMaxTextLength) { //Debug.Log("ProcessKeyboardInput - Mark 1"); bool canceled = false; while (!inKeyboard.done) { if (inKeyboard.active == false) { canceled = true; break; } if (inMaxTextLength > 0 && inKeyboard.text.Length > inMaxTextLength) { inKeyboard.text = inKeyboard.text.Substring(0, inMaxTextLength); } //Debug.Log("ProcessKeyboardInput - Mark 2"); yield return(new WaitForEndOfFrame()); } string keyboardText = inKeyboard.text; //Debug.Log("ProcessKeyboardInput - Mark 4 " + keyboardText); if (canceled == true || inKeyboard.wasCanceled == true) { //Debug.Log("ProcessKeyboardInput - Mark 5 "); canceled = true; keyboardText = inText; } //Debug.Log("ProcessKeyboardInput - Mark 6 "); try { inCloseDelegate(m_ActiveInput, keyboardText, canceled); } catch (System.Exception e) { Debug.LogError("!!!! Exception during call inCloseDelegate: \n" + e.ToString()); } m_ActiveInput = null; //m_Keyboard = null; //Debug.Log("ProcessKeyboardInput - Mark 7 "); }
public bool ShowKeyboard(GUIBase_Button inInput, E_KeyBoardMode inMode, KeyboardClose inCloseDelegate, string inText, string inPlaceholder, int inMaxTextLength = -1) { #if UNITY_EDITOR m_ActiveInput = null; Debug.LogError("ShowKeyboard not implemented !!!"); return(false); #elif UNITY_IPHONE || UNITY_ANDROID return(ShowTouchScreenKeyboard(inInput, inMode, inCloseDelegate, inText, inPlaceholder, inMaxTextLength)); #else Debug.LogError("ShowKeyboard not implemented !!!"); return(false); #endif }