SUIInputField
在此类中OnValueChanged
- 函数
- On
Value Changed - On
End Edit - Activate
Input Field - Deactivate
Input Field - Select
- 属性
- Text
- Enabled
- Interactable
- Is
Focused - Caret
Blink Rate - Caret
Width - Character
Limit - Read
Only - Multi
Line - Asterisk
Char - Caret
Position - Selection
Anchor Position - Selection
Focus Position - Min
Width - Preferred
Width - Flexible
Width - Min
Height - Preferred
Height - Flexible
Height - Normal
Color - Highlighted
Color - Pressed
Color - Disabled
Color - Color
Multiplier - Game
Object
| 函数 | OnValueChanged | Given function will be called when text in Input Field has changed |
| 函数 | OnEndEdit | Given function will be called when editing has ended |
| 函数 | ActivateInputField | – |
| 函数 | DeactivateInputField | – |
| 函数 | Select | – |
| 属性 | Text | The current value of the input field. |
| 属性 | Enabled | Whether this Input Field component is Enabled |
| 属性 | Interactable | Is the Input Field interactable? |
| 属性 | IsFocused | Does the InputField currently have focus and is able to process events. |
| 属性 | CaretBlinkRate | The blinking rate of the input caret, defined as the number of times the blink cycle occurs per second. |
| 属性 | CaretWidth | The width of the caret in pixels. |
| 属性 | CharacterLimit | – |
| 属性 | ReadOnly | – |
| 属性 | MultiLine | If the input field supports multiple lines. |
| 属性 | AsteriskChar | The character used for password fields. |
| 属性 | CaretPosition | Current InputField caret position (also selection tail). |
| 属性 | SelectionAnchorPosition | The beginning point of the selection. |
| 属性 | SelectionFocusPosition | The end point of the selection. |
| 属性 | MinWidth | The minimum width this UIInputField may be allocated. (Used by the Layout system). |
| 属性 | PreferredWidth | The preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system) |
| 属性 | FlexibleWidth | The extra relative width this UIInputField should be allocated if there is additional available space. (Used by the Layout system) |
| 属性 | MinHeight | The minimum height this UIInputField may be allocated.(Used by the Layout system). |
| 属性 | PreferredHeight | The preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system) |
| 属性 | FlexibleHeight | The extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system) |
| 属性 | NormalColor | The normal color. |
| 属性 | HighlightedColor | The color of the control when it is highlighted. |
| 属性 | PressedColor | The color of the control when it is pressed. |
| 属性 | DisabledColor | The color of the control when it is disabled. |
| 属性 | ColorMultiplier | This multiplies the tint color for each transition by its value. |
| 属性 | GameObject | – |
函数
OnValueChanged
Given function will be called when text in Input Field has changed
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| callback | Closure | – |
返回值
void
示例
function OVC()
--
end
Space.Host.ExecutingObject.UIInputField.OnValueChanged(OVC)
--This script will make an input field update a text field
--with character count in real-time every time a character is typed/removed
--[Text field and Input fields need to be added as references (scripting runtime)]
thisObject = Space.Host.ExecutingObject
inputField = Space.Host.GetReference("The Input Field").UIInputField
textField = Space.Host.GetReference("The Text Field").UIText
OnValueChanged = function()
textField.Text = "Count= " .. string.len(inputField.Text)
end
thisObject.UIInputField.OnValueChanged(OnValueChanged)
OnEndEdit
Given function will be called when editing has ended
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| callback | Closure | – |
返回值
void
示例
function OEE()
--
end
Space.Host.ExecutingObject.UIInputField.OnEndEdit(OEE)
--This script will make an input field update a text field
--as soon as someone has finished typing in it
--Text field and Input fields need to be added as references (scripting runtime)
thisObject = Space.Host.ExecutingObject
inputField = Space.Host.GetReference("The Input Field").UIInputField
textField = Space.Host.GetReference("The Text Field").UIText
OnEndEdit = function()
textField.Text = inputField.Text
end
Space.Host.ExecutingObject.UIInputField.OnEndEdit(OnEndEdit)
ActivateInputField
返回值
void
示例
Space.Host.ExecutingObject.UIInputField.ActivateInputField()
DeactivateInputField
返回值
void
示例
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()
Select
返回值
void
示例
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()
属性
Text
The current value of the input field.
示例
Space.Host.ExecutingObject.UIInputField.Text= "Hello"
--the below script makes this object set Browser URL according to what's written in text field
--[Required: This object needs a Browser and InputField objects to be added as reference to references section in Scripting Runtime component]
thisGameObject = Space.Host.ExecutingObject
webBrowser = Space.Host.GetReference("Browser")
urlField = Space.Host.GetReference("URL Field")
OnClick = function()
webBrowser.Browser.SetURL = urlField.UIInputField.Text
end
urlField.UIInputField.Text = https://www.youtube.com
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to set URL"
thisGameObject.Clickable.OnClick(OnClick)
Enabled
Whether this Input Field component is Enabled
示例
Space.Host.ExecutingObject.UIInputField.Enabled= true
--clicking this object will toggle a UIInputField's Enabled status
thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField
--make sure to add this reference to the Scripting Runtime component
OnClick = function()
inputfield.Enabled = not inputfield.Enabled
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
Interactable
Is the Input Field interactable?
示例
Space.Host.ExecutingObject.UIInputField.Interactable= true
--clicking this object will toggle a UIInputField's interactable status
thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField
--make sure to add this reference to the Scripting Runtime component
OnClick = function()
inputfield.Interactable = not inputfield.Interactable
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
IsFocused只读
Does the InputField currently have focus and is able to process events.
示例
hasFocus = Space.Host.ExecutingObject.UIInputField.IsFocused
CaretBlinkRate
The blinking rate of the input caret, defined as the number of times the blink cycle occurs per second.
示例
Space.Host.ExecutingObject.UIInputField.CaretBlinkRate= 3
CaretWidth
The width of the caret in pixels.
示例
Space.Host.ExecutingObject.UIInputField.CaretWidth= 4
CharacterLimit
示例
Space.Host.ExecutingObject.UIInputField.CharacterLimit= 8
ReadOnly
示例
Is the InputField read only?
--clicking this object will toggle a UIInputField's ReadOnly status
thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField
--make sure to add this reference to the Scripting Runtime component
OnClick = function()
inputfield.ReadOnly = not inputfield.ReadOnly
end
thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
MultiLine只读
If the input field supports multiple lines.
示例
Space.Host.ExecutingObject.UIInputField.MultiLine = true
AsteriskChar
The character used for password fields.
示例
Space.Host.ExecutingObject.UIInputField.AsteriskChar= "%"
CaretPosition
Current InputField caret position (also selection tail).
示例
Space.Host.ExecutingObject.UIInputField.CaretPosition= 3
SelectionAnchorPosition
The beginning point of the selection.
示例
Space.Host.ExecutingObject.UIInputField.SelectionAnchorPosition= 1
SelectionFocusPosition
The end point of the selection.
示例
Space.Host.ExecutingObject.UIInputField.SelectionFocusPosition= 4
MinWidth只读
The minimum width this UIInputField may be allocated. (Used by the Layout system).
示例
minWidth = Space.Host.ExecutingObject.UIInputField.MinWidth
PreferredWidth只读
The preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)
示例
prefWidth = Space.Host.ExecutingObject.UIInputField.PreferredWidth
FlexibleWidth只读
The extra relative width this UIInputField should be allocated if there is additional available space. (Used by the Layout system)
示例
flexWidth = Space.Host.ExecutingObject.UIInputField.FlexibleWidth
MinHeight只读
The minimum height this UIInputField may be allocated.(Used by the Layout system).
示例
minHeight = Space.Host.ExecutingObject.UIInputField.MinHeight
PreferredHeight只读
The preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)
示例
prefHeight = Space.Host.ExecutingObject.UIInputField.PreferredHeight
FlexibleHeight只读
The extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system)
示例
flexHeight = Space.Host.ExecutingObject.UIInputField.FlexibleHeight
NormalColor
The normal color.
示例
Space.Host.ExecutingObject.UIInputField.NormalColor = Color.Red
HighlightedColor
The color of the control when it is highlighted.
示例
Space.Host.ExecutingObject.UIInputField.HighlightedColor = Color.Red
PressedColor
The color of the control when it is pressed.
示例
Space.Host.ExecutingObject.UIInputField.PressedColor = Color.Red
DisabledColor
The color of the control when it is disabled.
示例
Space.Host.ExecutingObject.UIInputField.DisabledColor = Color.Red
ColorMultiplier
This multiplies the tint color for each transition by its value.
示例
Space.Host.ExecutingObject.UIInputField.ColorMultiplier = Color.Red
GameObject只读
示例
``` theGameObject = Space.Host.ExecutingObject.UIInputField.GameObject ```



