wiki.sine.space | sinespace

Scripting/SUIDropdown

From wiki.sine.space
Revision as of 05:58, 13 October 2021 by Voidtech (Talk | contribs)

Jump to: navigation, search

Members

AddOptions

void AddOptions (Table options)

Add multiple options to the options of the Dropdown.

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


ClearOptions

void ClearOptions ()

Clear the list of options in the Dropdown.

Space.Host.ExecutingObject.UIDropdown.ClearOptions()


Hide

void Hide ()

Hide the dropdown list.

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.

https://wiki.sine.space/index.php?title=Scripting/SUIDropdown


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.

Space.Host.ExecutingObject.UIDropdown.RefreshShownValue()


Show

void Show ()

Show the dropdown list.

Space.Host.ExecutingObject.UIDropdown.Show()



Properties

CaptionImage

SUIImage CaptionImage { get; set; }

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

captionImage = Space.Host.ExecutingObject.UIDropdown.CaptionImage


CaptionText

SUIText CaptionText { get; set; }

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

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


Interactable

bool Interactable { get; set; }

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)

ItemImage

SUIImage ItemImage { get; set; }

The Image component to hold the image of the item.

itemImage = Space.Host.ExecutingObject.UIDropdown.ItemImage


ItemText

SUIText ItemText { get; set; }

The Text component to hold the text of the item.

Space.Host.ExecutingObject.UIDropdown.ItemText.Text = "new text"


Template

SGameObject Template { get; set; }

The Rect Transform of the template for the dropdown list.

ddRect = Space.Host.ExecutingObject.UIDropdown.Template


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.

Space.Host.ExecutingObject.UIDropdown.Value= 2


OptionsAsSprites

[[Scripting/SResource[]|SResource[]]] OptionsAsSprites { get; }

The list of possible options. (Sprites)

optionsSprites = Space.Host.ExecutingObject.UIDropdown.OptionsAsSprites


OptionsAsText

[[Scripting/string[]|string[]]] OptionsAsText { get; }

The list of possible options. (Text)

optionsText = Space.Host.ExecutingObject.UIDropdown.OptionsAsText