The keyboard will appear automatically when a user taps on editable GUI elements. Currently, GUI.TextField, GUI.TextArea andGUI.PasswordField will display the keyboard; see the GUI class documentation for further details.
当用户点击可编辑的GUI元素时键盘将自动出现。当前,GUI.TextField、GUI.TextArea和GUI.PasswordField会显示键盘;更多的细节请查看GUI类。
Use the iPhoneKeyboard.Open function to open the keyboard. Please see the iPhoneKeyboard scripting reference for the parameters that this function takes.
使用iPhoneKeyboard.Open方法来打开键盘。关于iPhoneKeyboard的详细参数请查看iPhoneKeyboard脚本参考。
The Keyboard supports the following types:
键盘支持以下几种类型:
By default, an edit box will be created and placed on top of the keyboard after it appears. This works as preview of the text that user is typing, so the text is always visible for the user. However, you can disable text preview by setting iPhoneKeyboard.hideInput to true. Note that this works only for certain keyboard types and input modes. For example, it will not work for phone keypads and multi-line text input. In such cases, the edit box will always appear. iPhoneKeyboard.hideInput is a global variable and will affect all keyboards.
默认情况下,编辑框将被创建并置于键盘的上方。这是作为用户输入的文本预览,因此对用户文本总是可见的。当然,你可以通过设置iPhoneKeyboard.hideInput=true来禁用文本预览。请注意,这仅适用于某些键盘类型和输入模式。例如:不能工作于拨号键盘以及多行文本输入。在这种情况下,编辑框将始终出现。iPhoneKeyboard.hideInput是一个全局变量,会影响所有的键盘。
By default, the keyboard automatically follows the device orientation. To disable or enable rotation to a certain orientation, use the following properties available in iPhoneKeyboard:
默认情况下,键盘将自动跟踪设备方向。要禁用或启用某个方向的旋转,可以设置iPhoneKeyboard一下属性。
There are three keyboard properties in iPhoneKeyboard that determine keyboard visibility status and size on the screen.
iPhoneKeyboard有三个参数设置键盘的在屏幕上的可见性以及大小属性。
Note that iPhoneKeyboard.area will return a rect with position and size set to 0 until the keyboard is fully visible on the screen. You should not query this value immediately after iPhoneKeyboard.Open. The sequence of keyboard events is as follows:
请注意:直到键盘完全显示在屏幕上之前,iPhoneKeyboard.area返回的位置和大小都将为0。你不能在设置iPhoneKeyboard.Open之后立即查询此值。键盘事件的顺序如下:
It is possible to configure the keyboard to hide symbols when typing. This is useful when users are required to enter sensitive information (such as passwords). To manually open keyboard with secure text input enabled, use the following code:
能够设置在键盘输入时隐藏字符。当用户输入敏感信息时这是非常有用的(如输入密码)。要手动打开文本输入的安全性设置,请使用下面的代码:
iPhoneKeyboard.Open("", iPhoneKeyboardType.Default, false, false, true);
Hiding text while typing 输入时隐藏文本
To display the keyboard with a black semi-transparent background instead of the classic opaque, call iPhoneKeyboard.Open as follows:
要显示一个黑色半透明的背景键盘而非经典的不透明键盘,调用iPhoneKeyboard.Open如下:
iPhoneKeyboard.Open("", iPhoneKeyboardType.Default, false, false, true, true);
Classic keyboard 经典键盘
Alert keyboard 警醒键盘
Unity Android reuses the iOS API to display system keyboard. Even though Unity Android supports most of the functionality of its iPhone counterpart, there are two aspects which are not supported:
Unity Android 在显示系统键盘方面重用了IOS的API,虽然Unity Android支持大部分的与IPhone对应的功能,但是有以下两点功能不支持:
Please also note that the layout of a iPhoneKeyboardType can differ somewhat between devices.
请注意:iPhoneKeyboardType 的样式在不同的设备上有所不同。