Breakroom is now Sinewave Campus. Book a meeting

SUIDropdown

ClientComposants
Dans cette classeRefreshShownValue
  1. Fonctions
  2. RefreshShownValue
  3. AddOptions
  4. ClearOptions
  5. Show
  6. Hide
  7. OnValueChanged
  8. SetValueByText
  9. Propriétés
  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
Membres 22
FonctionRefreshShownValueRefreshes 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.
FonctionAddOptionsAdd multiple options to the options of the Dropdown.
FonctionClearOptionsClear the list of options in the Dropdown.
FonctionShowShow the dropdown list.
FonctionHideHide the dropdown list.
FonctionOnValueChangedBind a function to handle the event that is invoked when when a user has clicked one of the options in the dropdown list.
FonctionSetValueByTextAttempts to set the dropdown to the first option in the dropdown list that matches the inputted text.
PropriétéInteractableIs this UIDropdown interactable?
PropriétéTemplateThe Rect Transform of the template for the dropdown list.
PropriétéCaptionTextThe Text component to hold the text of the currently selected option.
PropriétéCaptionImageThe Image component to hold the image of the currently selected option.
PropriétéItemTextThe Text component to hold the text of the item.
PropriétéItemImageThe Image component to hold the image of the item.
PropriétéOptionsAsTextThe list of possible options. (Text)
PropriétéOptionsAsSpritesThe list of possible options. (Sprites)
Propriété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.
PropriétéNormalColor–
PropriétéHighlightedColor–
PropriétéPressedColor–
PropriétéDisabledColor–
PropriétéColorMultiplier–
PropriétéGameObject–

Fonctions​

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.

Valeurs de retour

void

Exemple

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.

Paramètres

NomTypeValeur par défaut
optionsstring[]–
optionsTable–
optionsSpritesSResource[]–

Valeurs de retour

void

Exemple

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

ClearOptions​

void ClearOptions()

Clear the list of options in the Dropdown.

Valeurs de retour

void

Exemple

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

Show​

void Show()

Show the dropdown list.

Valeurs de retour

void

Exemple

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

Hide​

void Hide()

Hide the dropdown list.

Valeurs de retour

void

Exemple

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.

Paramètres

NomTypeValeur par défaut
callbackClosure–

Valeurs de retour

void

Exemple

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.

Paramètres

NomTypeValeur par défaut
textstring–

Valeurs de retour

bool

Exemple

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")

Propriétés​

Interactable​

bool Interactable {get; set; }

Is this UIDropdown interactable?

Exemple

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.

Exemple

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.

Exemple

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.

Exemple

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.

Exemple

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.

Exemple

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

OptionsAsTextLecture seule​

string[] OptionsAsText {get; }

The list of possible options. (Text)

Exemple

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

OptionsAsSpritesLecture seule​

SResource[] OptionsAsSprites {get; }

The list of possible options. (Sprites)

Exemple

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.

Exemple

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

NormalColor​

SColor NormalColor {get; set; }

Exemple

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

HighlightedColor​

SColor HighlightedColor {get; set; }

Exemple

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

PressedColor​

SColor PressedColor {get; set; }

Exemple

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

DisabledColor​

SColor DisabledColor {get; set; }

Exemple

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

ColorMultiplier​

float ColorMultiplier {get; set; }

Exemple

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

GameObjectLecture seule​

SGameObject GameObject {get; }

Exemple

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