SUIDropdown
| دالة | 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. |
| دالة | AddOptions | Add multiple options to the options of the Dropdown. |
| دالة | ClearOptions | Clear the list of options in the Dropdown. |
| دالة | Show | Show the dropdown list. |
| دالة | Hide | Hide the dropdown list. |
| دالة | OnValueChanged | Bind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list. |
| دالة | SetValueByText | Attempts to set the dropdown to the first option in the dropdown list that matches the inputted text. |
| خاصية | Interactable | Is this UIDropdown interactable? |
| خاصية | Template | The Rect Transform of the template for the dropdown list. |
| خاصية | CaptionText | The Text component to hold the text of the currently selected option. |
| خاصية | CaptionImage | The Image component to hold the image of the currently selected option. |
| خاصية | ItemText | The Text component to hold the text of the item. |
| خاصية | ItemImage | The Image component to hold the image of the item. |
| خاصية | OptionsAsText | The list of possible options. (Text) |
| خاصية | OptionsAsSprites | The list of possible options. (Sprites) |
| خاصية | Value | 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. |
| خاصية | NormalColor | – |
| خاصية | HighlightedColor | – |
| خاصية | PressedColor | – |
| خاصية | DisabledColor | – |
| خاصية | ColorMultiplier | – |
| خاصية | GameObject | – |
الدوال
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
مثال
Space.Host.ExecutingObject.UIDropdown.RefreshShownValue()
AddOptions
Add multiple options to the options of the Dropdown.
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| options | string[] | – |
| options | Table | – |
| optionsSprites | SResource[] | – |
القيم المرجعة
void
مثال
Space.Host.ExecutingObject.UIDropdown.AddOptions({"option1","option2","option3"})
ClearOptions
Clear the list of options in the Dropdown.
القيم المرجعة
void
مثال
Space.Host.ExecutingObject.UIDropdown.ClearOptions()
Show
Show the dropdown list.
القيم المرجعة
void
مثال
Space.Host.ExecutingObject.UIDropdown.Show()
Hide
Hide the dropdown list.
القيم المرجعة
void
مثال
Space.Host.ExecutingObject.UIDropdown.Hide()
OnValueChanged
Bind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| callback | Closure | – |
القيم المرجعة
void
مثال
function AFunction()
--
end
Space.Host.ExecutingObject.UIDropdown.OnValueChanged(AFunction)
SetValueByText
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.
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| text | string | – |
القيم المرجعة
bool
مثال
Space.Host.ExecutingObject.UIDropdown.SetValueByText("Value Text")
--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
Is this UIDropdown interactable?
مثال
Space.Host.ExecutingObject.UIDropdown.Interactable = true
--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
The Rect Transform of the template for the dropdown list.
مثال
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.Template = aReferenceToAGameObject
CaptionText
The Text component to hold the text of the currently selected option.
مثال
captionText = Space.Host.ExecutingObject.UIDropdown.CaptionText
captionText.Text = "new caption"
CaptionImage
The Image component to hold the image of the currently selected option.
مثال
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage
ItemText
The Text component to hold the text of the item.
مثال
aReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIText
ItemImage
The Image component to hold the image of the item.
مثال
iaReferenceToAGameObject = Space.Host.GetReference("reference name")
Space.Host.ExecutingObject.UIDropdown.CaptionImage = aReferenceToAGameObject.UIImage
OptionsAsTextللقراءة فقط
The list of possible options. (Text)
مثال
optionsText = Space.Host.ExecutingObject.UIDropdown.OptionsAsText
OptionsAsSpritesللقراءة فقط
The list of possible options. (Sprites)
مثال
optionsSprites = Space.Host.ExecutingObject.UIDropdown.OptionsAsSprites
Value
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.
مثال
Space.Host.ExecutingObject.UIDropdown.Value= 2
NormalColor
مثال
Space.Host.ExecutingObject.UIDropdown.NormalColor = Color.Red
HighlightedColor
مثال
Space.Host.ExecutingObject.UIDropdown.HighlightedColor = Color.Red
PressedColor
مثال
Space.Host.ExecutingObject.UIDropdown.PressedColor = Color.Red
DisabledColor
مثال
Space.Host.ExecutingObject.UIDropdown.DisabledColor = Color.Red
ColorMultiplier
مثال
Space.Host.ExecutingObject.UIDropdown.ColorMultiplier = Color.Red
GameObjectللقراءة فقط
مثال
Space.Host.ExecutingObject.UIDropdown.GameObject = Color.Red



