UGUI 学习笔记10 InputField

来源:互联网 发布:初学钢琴软件 编辑:程序博客网 时间:2024/06/05 09:27

Input Field

1.      属性详解

Property

Function

个人解释

Interactable

A Boolean that determines if the Input Field can be interacted with or not.

是否可用

Transition

Transitions are used to set how the input field transitions when NormalHighlighted,Pressed or Disabled.

状态变化(参考Button)

Navigation

Properties that determine the sequence of control. See Navigation Options.

热键关联

TextComponent

A reference to the Text element used as the contents of the Input Field.

文本组件

Text

Starting Value.The initial text placed in the field before editing begins.

默认文本

Character Limit

The value of the maximum number of characters that can be entered into the input field

字数限制

Content Type

Define the type(s) of characters that your input field accepts.

输入类型

 

Standard

Any charcter can be entered

可以输入任何字符

Autocorrected

The autocorrection determines whether the input tracks unknown words and suggests a more suitable replacement candidate to the user,replacing the typed text automatically unless the user explicitly overrides the action

自动修正( 可以出入任何字符)

Integer Number

Allow only whole numbers to be entered.

整数

Decimal Number

Allow only numbers and a single decimal point to be entered.

小数

Alphanumeric

Allow both letters and numbers.Symbols cannot be entered.

字母和数字

Name

Automatically Capitalises the first letter of each word.

名字(自动大写首字母,可以输入汉字)

Email Address

Allows you to enter an Alphanumeric string consisting of a maximum of one @sign.periods/baseline dots cannot be entered next to each other.

邮箱格式

Password

Conceals the characters inputed with an asterisk. Allows symbols.

密码(在输入时显示星号)

Pin

Conceals the characters inputed with an asterisk.Only allows only whole numbers to be entered.

Pin码(只能输入数字,并且输入时显示星号)

Custom

Allows you to customize the Line Type,Input Type,Keyboard Type and Character Validation.

自定义

Line Type 行类型

Input Type 输入类型

KeyBoard Type 键盘类型

Character Validation 字符限制

Line Type

Defines how test is formatted inside the text field.

行类型

Single Line

Only allows text to be on a single line.

单行

Multi Line Submit

Allows text to use multiple lines.Only uses a new line when needed.

多行(超出边界换行)

Multi Line Newline

Allows text to use multiple lines.User can use a newline by pressing the return key.

多行(超出边界换行和回车换行)

Placeholder

This is an optional’empty’Graphic to show that the Input Field is empty of text.Note that this ‘empty’ graphic still displays even when the Input Field is selected(that is;when there is focus on it).eg;”Enter text…”.

提示文字

Caret Blink Rate

Defines the blink rate for the mark placed on the line to indicate a proposed insertion of text.

光标闪动频率

Selection Color

The background color of the selected portion of text

选中颜色

Hide Mobile Input(IOS only)

Hides the native input field attached to the onscreen keyboard on mobile devices.Note that this only works on IOS devices.

隐藏输入键盘(IOS)

On Value Change

A UnityEvent that is invoked when the text content of the Input Field changes.The event can send the current text content as a string sypt dynamic argument.

正在收入时的监听事件

End Edit

A UnityEvent that is invoked then the user finishes editing the text content either by submitting or by clicking some where that removes the focus from the Input Field.The event can send the current text content as a string type dynamic argument.

完成编辑的监听事件(回车触发,或者点击输入框以外的区域)。

2.      InputField 控件组成

没有运行的组件由两个如图所示


Placeholder 是提示文字框

Text 是输入文字框

运行时的组件由三个如图所示


InputField Input Caret是光标,上面绑有组件LayoutElement,解释下 Layout Element

Property

Function

个人解释

Min Width

The minimum width this layout should have.

 

最小宽

Min Height

The minimum height this layout element should have.

最小高

Preferred Width

The preferred width this layout element should have before additional available width is allocated.

预设宽

Preferred Height

The preferred height this layout element should have before additional available height is allocated.

预设高

Flexible Width

The relative amount of additional available width this layout element should fill out relative to its siblings.

自适高

Flexible Height

The relative amount of additional available height this layout element should fill out relative to its siblings.

自适宽

3.      事件监听

代码写好对应事件的函数

给InputField对象绑定函数


最终效果


原创粉丝点击