/// <summary>Tells the UI a key was pressed.</summary> /// <param name="down">True if the key is now down.</param> /// <param name="keyCode">The keycode of the key</param> /// <param name="character">The character entered.</param> /// <returns>True if the UI consumed the keypress.</returns> public static bool OnKeyPress(bool down, char character, int keyCode) { UIEvent uiEvent = new UIEvent(keyCode, character, down); // Set the current event: uiEvent.unityEvent = Event.current; if (down) { if (UI.document.RunKeyDown(uiEvent)) { return(true); } } else { if (UI.document.RunKeyUp(uiEvent)) { return(true); } } if (Focused == null) { return(false); } if (!Focused.isRooted) { // It got removed. Focused.Unfocus(); return(false); } Focused.Handler.OnKeyPress(uiEvent); return(true); }