您的位置:首页 > 移动开发 > Unity3D

[Unity3D]手机3D游戏开发:如何实现最高分的存储与显示(八)----用TouchScreenKeyboard弹出键盘

2013-01-26 21:06 1091 查看
连接上安卓设备进行调试的时候会发现无法正常的输入数据因为没有键盘弹出,这时需要一个新的类:TouchScreenKeyboard来弹出键盘。

官网的说明文档:TouchScreenKeyboard

简单来说,是为了解决界面进入iPhone和Android的屏幕键盘键盘问题。

这个接口允许显示不同类型的键盘:ASCII,数字,URL,电子邮件,和其他。
因为键盘的外观有可能掩盖用户界面,用户界面是否被遮挡由你来设置。
TouchScreenKeyboard.visibleTouchScreenKeyboard.area应该用来确定键盘是否显示(激活),哪一部分的屏幕被使用。
苹果的API不允许显式地控制的方向键盘。

所以你可以定自己定义如果键盘需要自动旋转匹配到一个特定的定位装置。

相关变量:
textReturns the text displayed by the input field of the keyboard. This
activeSpecifies if the keyboard is visible or is sliding into the position on
doneSpecifies if input process was finished(Read Only)
wasCanceledSpecifies if input process was canceled(Read Only)
类变量:

hideInputSpecifies if text input field above the keyboard will be hidden when
autorotateToPortraitSpecifies whether the keyboard should be automatically rotated to
autorotateToPortraitUpsideDownSpecifies whether the keyboard should be automatically rotated to
autorotateToLandscapeLeftSpecifies whether the keyboard should be automatically rotated to
autorotateToLandscapeRightSpecifies whether the keyboard should be automatically rotated to
areaReturns portion of the screen which is covered by the keyboard. Returns
visibleReturns true whenever any keyboard is completely visible on the screen.



还有一个类方法:

Open:Opens the native keyboard provided by OS on the screen.

在上次的代码中稍作修改,添加一个变量判断是否需要输入名字,

private var keyboard : TouchScreenKeyboard ;
private var enterName : boolean = false;


同时调用TouchScreenKeyboard的Open方法打开键盘:

if (!enterName) {
keyboard = TouchScreenKeyboard.Open(newName);
enterName = true;
}

if (keyboard)
{
newName = keyboard.text;
}

这时便会发现可以实现安卓设备的输入了:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐