/* * private IEnumerator MoveInputUp() * { * yield return new WaitForSeconds(0.1f); * * Debug.Log("moved: " + GetKeyboardHeight()); * inputField.anchoredPosition = new Vector2(inputField.localPosition.x, GetKeyboardHeight()); * } */ private void Update() { if (keyboardHeight > 0 && !isKeyboardOpen) { // StartCoroutine(MoveInputUp()); inputField.anchoredPosition = new Vector2(inputField.localPosition.x, keyboardHeight); isKeyboardOpen = true; } else if (keyboardHeight == 0 && isKeyboardOpen) { inputField.anchoredPosition = normalLocalPosition; isKeyboardOpen = false; } if (id == handler.get_currentField()) { if (text.text.Length <= 0 && !placeholder.IsActive()) { placeholder.gameObject.SetActive(true); text.gameObject.SetActive(false); } else if (text.text.Length > 0 && !text.IsActive()) { placeholder.gameObject.SetActive(false); text.gameObject.SetActive(true); } foreach (char c in Input.inputString) { if (c == '\b' && text.text.Length != 0) { // has backspace/delete been pressed? text.text = text.text.Substring(0, text.text.Length - 1); } else if ((c == '\n') || (c == '\r')) { // enter/return print("User entered their name: " + text.text); } else { text.text += c; } //Debug.Log (text); } } }
void Update() { if (id == handler.get_currentField()) { if (text.text.Length <= 0 && !placeholder.IsActive()) { placeholder.gameObject.SetActive(true); text.gameObject.SetActive(false); } else if (text.text.Length > 0 && !text.IsActive()) { placeholder.gameObject.SetActive(false); text.gameObject.SetActive(true); } foreach (char c in Input.inputString) { if (c == '\b') // has backspace/delete been pressed? { if (text.text.Length != 0) { text.text = text.text.Substring(0, text.text.Length - 1); } } /* * else if ((c == '\n') || (c == '\r')) * { // enter/return * print ("User entered their name: " + text.text); * } */ else { text.text += c; } Debug.Log(text); } } }