Breakroom is now Sinewave Campus. Book a meeting

SUIInputField

客户端组件
在此类中OnValueChanged
  1. 函数
  2. OnValueChanged
  3. OnEndEdit
  4. ActivateInputField
  5. DeactivateInputField
  6. Select
  7. 属性
  8. Text
  9. Enabled
  10. Interactable
  11. IsFocused
  12. CaretBlinkRate
  13. CaretWidth
  14. CharacterLimit
  15. ReadOnly
  16. MultiLine
  17. AsteriskChar
  18. CaretPosition
  19. SelectionAnchorPosition
  20. SelectionFocusPosition
  21. MinWidth
  22. PreferredWidth
  23. FlexibleWidth
  24. MinHeight
  25. PreferredHeight
  26. FlexibleHeight
  27. NormalColor
  28. HighlightedColor
  29. PressedColor
  30. DisabledColor
  31. ColorMultiplier
  32. GameObject
成员 30
函数OnValueChangedGiven function will be called when text in Input Field has changed
函数OnEndEditGiven function will be called when editing has ended
函数ActivateInputField–
函数DeactivateInputField–
函数Select–
属性TextThe current value of the input field.
属性EnabledWhether this Input Field component is Enabled
属性InteractableIs the Input Field interactable?
属性IsFocusedDoes the InputField currently have focus and is able to process events.
属性CaretBlinkRateThe blinking rate of the input caret, defined as the number of times the blink cycle occurs per second.
属性CaretWidthThe width of the caret in pixels.
属性CharacterLimit–
属性ReadOnly–
属性MultiLineIf the input field supports multiple lines.
属性AsteriskCharThe character used for password fields.
属性CaretPositionCurrent InputField caret position (also selection tail).
属性SelectionAnchorPositionThe beginning point of the selection.
属性SelectionFocusPositionThe end point of the selection.
属性MinWidthThe minimum width this UIInputField may be allocated. (Used by the Layout system).
属性PreferredWidthThe preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)
属性FlexibleWidthThe extra relative width this UIInputField should be allocated if there is additional available space. (Used by the Layout system)
属性MinHeightThe minimum height this UIInputField may be allocated.(Used by the Layout system).
属性PreferredHeightThe preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)
属性FlexibleHeightThe extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system)
属性NormalColorThe normal color.
属性HighlightedColorThe color of the control when it is highlighted.
属性PressedColorThe color of the control when it is pressed.
属性DisabledColorThe color of the control when it is disabled.
属性ColorMultiplierThis multiplies the tint color for each transition by its value.
属性GameObject–

函数​

OnValueChanged​

void OnValueChanged(Closure callback)

Given function will be called when text in Input Field has changed

参数

名称类型默认值
callbackClosure–

返回值

void

示例

Lua
function OVC()
--
end
Space.Host.ExecutingObject.UIInputField.OnValueChanged(OVC)
Lua
--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​

void OnEndEdit(Closure callback)

Given function will be called when editing has ended

参数

名称类型默认值
callbackClosure–

返回值

void

示例

Lua
function OEE()
--
end
Space.Host.ExecutingObject.UIInputField.OnEndEdit(OEE)
Lua
--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 ActivateInputField()

返回值

void

示例

Lua
Space.Host.ExecutingObject.UIInputField.ActivateInputField()

DeactivateInputField​

void DeactivateInputField()

返回值

void

示例

Lua
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()

Select​

void Select()

返回值

void

示例

Lua
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()

属性​

Text​

string Text {get; set; }

The current value of the input field.

示例

Lua
Space.Host.ExecutingObject.UIInputField.Text= "Hello"
Lua
--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​

bool Enabled {get; set; }

Whether this Input Field component is Enabled

示例

Lua
Space.Host.ExecutingObject.UIInputField.Enabled= true
Lua
--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​

bool Interactable {get; set; }

Is the Input Field interactable?

示例

Lua
Space.Host.ExecutingObject.UIInputField.Interactable= true
Lua
--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只读​

bool IsFocused {get; }

Does the InputField currently have focus and is able to process events.

示例

Lua
hasFocus = Space.Host.ExecutingObject.UIInputField.IsFocused

CaretBlinkRate​

float CaretBlinkRate {get; set; }

The blinking rate of the input caret, defined as the number of times the blink cycle occurs per second.

示例

Lua
Space.Host.ExecutingObject.UIInputField.CaretBlinkRate= 3

CaretWidth​

int CaretWidth {get; set; }

The width of the caret in pixels.

示例

Lua
Space.Host.ExecutingObject.UIInputField.CaretWidth= 4

CharacterLimit​

int CharacterLimit {get; set; }

示例

Lua
Space.Host.ExecutingObject.UIInputField.CharacterLimit= 8

ReadOnly​

bool ReadOnly {get; set; }

示例

Lua
Is the InputField read only?
Lua
--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只读​

bool MultiLine {get; }

If the input field supports multiple lines.

示例

Lua
Space.Host.ExecutingObject.UIInputField.MultiLine = true

AsteriskChar​

char AsteriskChar {get; set; }

The character used for password fields.

示例

Lua
Space.Host.ExecutingObject.UIInputField.AsteriskChar= "%"

CaretPosition​

int CaretPosition {get; set; }

Current InputField caret position (also selection tail).

示例

Lua
Space.Host.ExecutingObject.UIInputField.CaretPosition= 3

SelectionAnchorPosition​

int SelectionAnchorPosition {get; set; }

The beginning point of the selection.

示例

Lua
Space.Host.ExecutingObject.UIInputField.SelectionAnchorPosition= 1

SelectionFocusPosition​

int SelectionFocusPosition {get; set; }

The end point of the selection.

示例

Lua
Space.Host.ExecutingObject.UIInputField.SelectionFocusPosition= 4

MinWidth只读​

float MinWidth {get; }

The minimum width this UIInputField may be allocated. (Used by the Layout system).

示例

Lua
minWidth = Space.Host.ExecutingObject.UIInputField.MinWidth

PreferredWidth只读​

float PreferredWidth {get; }

The preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)

示例

Lua
prefWidth = Space.Host.ExecutingObject.UIInputField.PreferredWidth

FlexibleWidth只读​

float FlexibleWidth {get; }

The extra relative width this UIInputField should be allocated if there is additional available space. (Used by the Layout system)

示例

Lua
flexWidth = Space.Host.ExecutingObject.UIInputField.FlexibleWidth

MinHeight只读​

float MinHeight {get; }

The minimum height this UIInputField may be allocated.(Used by the Layout system).

示例

Lua
minHeight = Space.Host.ExecutingObject.UIInputField.MinHeight

PreferredHeight只读​

float PreferredHeight {get; }

The preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)

示例

Lua
prefHeight = Space.Host.ExecutingObject.UIInputField.PreferredHeight

FlexibleHeight只读​

float FlexibleHeight {get; }

The extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system)

示例

Lua
flexHeight = Space.Host.ExecutingObject.UIInputField.FlexibleHeight

NormalColor​

SColor NormalColor {get; set; }

The normal color.

示例

Lua
Space.Host.ExecutingObject.UIInputField.NormalColor = Color.Red

HighlightedColor​

SColor HighlightedColor {get; set; }

The color of the control when it is highlighted.

示例

Lua
Space.Host.ExecutingObject.UIInputField.HighlightedColor = Color.Red

PressedColor​

SColor PressedColor {get; set; }

The color of the control when it is pressed.

示例

Lua
Space.Host.ExecutingObject.UIInputField.PressedColor = Color.Red

DisabledColor​

SColor DisabledColor {get; set; }

The color of the control when it is disabled.

示例

Lua
Space.Host.ExecutingObject.UIInputField.DisabledColor = Color.Red

ColorMultiplier​

float ColorMultiplier {get; set; }

This multiplies the tint color for each transition by its value.

示例

Lua
Space.Host.ExecutingObject.UIInputField.ColorMultiplier = Color.Red

GameObject只读​

SGameObject GameObject {get; }

示例

``` theGameObject = Space.Host.ExecutingObject.UIInputField.GameObject ```