Breakroom is now Sinewave Campus. Book a meeting

SUIDropdown

العميلالمكونات
في هذا الصنفRefreshShownValue
  1. الدوال
  2. RefreshShownValue
  3. AddOptions
  4. ClearOptions
  5. Show
  6. Hide
  7. OnValueChanged
  8. SetValueByText
  9. الخصائص
  10. Interactable
  11. Template
  12. CaptionText
  13. CaptionImage
  14. ItemText
  15. ItemImage
  16. OptionsAsText
  17. OptionsAsSprites
  18. Value
  19. NormalColor
  20. HighlightedColor
  21. PressedColor
  22. DisabledColor
  23. ColorMultiplier
  24. GameObject
الأعضاء 22
دالةRefreshShownValueRefreshes the text and image (if available) of the currently selected option.If you have modified the list of options, you should call this method afterwards to ensure that the visual state of the dropdown corresponds to the updated options.
دالةAddOptionsAdd multiple options to the options of the Dropdown.
دالةClearOptionsClear the list of options in the Dropdown.
دالةShowShow the dropdown list.
دالةHideHide the dropdown list.
دالةOnValueChangedBind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.
دالةSetValueByTextAttempts to set the dropdown to the first option in the dropdown list that matches the inputted text.
خاصيةInteractableIs this UIDropdown interactable?
خاصيةTemplateThe Rect Transform of the template for the dropdown list.
خاصيةCaptionTextThe Text component to hold the text of the currently selected option.
خاصيةCaptionImageThe Image component to hold the image of the currently selected option.
خاصيةItemTextThe Text component to hold the text of the item.
خاصيةItemImageThe Image component to hold the image of the item.
خاصيةOptionsAsTextThe list of possible options. (Text)
خاصيةOptionsAsSpritesThe list of possible options. (Sprites)
خاصيةValueThe Value is the index number of the current selection in the Dropdown. 0 is the first option in the Dropdown, 1 is the second, and so on.
خاصيةNormalColor–
خاصيةHighlightedColor–
خاصيةPressedColor–
خاصيةDisabledColor–
خاصيةColorMultiplier–
خاصيةGameObject–

الدوال​

RefreshShownValue​

void RefreshShownValue()

Refreshes the text and image (if available) of the currently selected option.If you have modified the list of options, you should call this method afterwards to ensure that the visual state of the dropdown corresponds to the updated options.

القيم المرجعة

void

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.RefreshShownValue()

AddOptions​

void AddOptions(string[] options)
void AddOptions(Table options)
void AddOptions(SResource[] optionsSprites)

Add multiple options to the options of the Dropdown.

المعاملات

الاسمالنوعالقيمة الافتراضية
optionsstring[]–
optionsTable–
optionsSpritesSResource[]–

القيم المرجعة

void

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.AddOptions({"option1","option2","option3"})

ClearOptions​

void ClearOptions()

Clear the list of options in the Dropdown.

القيم المرجعة

void

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.ClearOptions()

Show​

void Show()

Show the dropdown list.

القيم المرجعة

void

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.Show()

Hide​

void Hide()

Hide the dropdown list.

القيم المرجعة

void

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.Hide()

OnValueChanged​

void OnValueChanged(Closure callback)

Bind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.

المعاملات

الاسمالنوعالقيمة الافتراضية
callbackClosure–

القيم المرجعة

void

مثال

Lua
function AFunction()
--
end

Space.Host.ExecutingObject.UIDropdown.OnValueChanged(AFunction)

SetValueByText​

bool SetValueByText(string text)

Attempts to set the dropdown to the first option in the dropdown list that matches the inputted text. Returns true if found, false if no matches found.

المعاملات

الاسمالنوعالقيمة الافتراضية
textstring–

القيم المرجعة

bool

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.SetValueByText("Value Text")
Lua
--Populating a UIDropdown and making a selection using value's text
dropDown=Space.Host.GetReference("DropDown").UIDropdown
options = {"Room 1", "Room 2", "Room 3", "Room 4"}
dropDown.AddOptions(options)
dropDown.SetValueByText("Room 3")

الخصائص​

Interactable​

bool Interactable {get; set; }

Is this UIDropdown interactable?

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.Interactable = true
Lua
--clicking this object will toggle a UIDropdown's interactable status

thisGameObject = Space.Host.ExecutingObject
dropdown = Space.Host.GetReference("dropdown").UIDropdown
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
dropdown.Interactable = not dropdown.Interactable
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

Template​

SGameObject Template {get; set; }

The Rect Transform of the template for the dropdown list.

مثال

Lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.Template = aReferenceToAGameObject

CaptionText​

SUIText CaptionText {get; set; }

The Text component to hold the text of the currently selected option.

مثال

Lua
captionText = Space.Host.ExecutingObject.UIDropdown.CaptionText
captionText.Text = "new caption"

CaptionImage​

SUIImage CaptionImage {get; set; }

The Image component to hold the image of the currently selected option.

مثال

Lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage

ItemText​

SUIText ItemText {get; set; }

The Text component to hold the text of the item.

مثال

Lua
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIText

ItemImage​

SUIImage ItemImage {get; set; }

The Image component to hold the image of the item.

مثال

Lua
iaReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage

OptionsAsTextللقراءة فقط​

string[] OptionsAsText {get; }

The list of possible options. (Text)

مثال

Lua
optionsText = Space.Host.ExecutingObject.UIDropdown.OptionsAsText

OptionsAsSpritesللقراءة فقط​

SResource[] OptionsAsSprites {get; }

The list of possible options. (Sprites)

مثال

Lua
optionsSprites = Space.Host.ExecutingObject.UIDropdown.OptionsAsSprites

Value​

int Value {get; set; }

The Value is the index number of the current selection in the Dropdown. 0 is the first option in the Dropdown, 1 is the second, and so on.

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.Value= 2

NormalColor​

SColor NormalColor {get; set; }

مثال

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

HighlightedColor​

SColor HighlightedColor {get; set; }

مثال

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

PressedColor​

SColor PressedColor {get; set; }

مثال

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

DisabledColor​

SColor DisabledColor {get; set; }

مثال

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

ColorMultiplier​

float ColorMultiplier {get; set; }

مثال

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

GameObjectللقراءة فقط​

SGameObject GameObject {get; }

مثال

Lua
Space.Host.ExecutingObject.UIDropdown.GameObject = Color.Red