blog games developers documentation portfolio gallery

Documentation:

Script interface

Properties:


public int[] optionInts
Array of ints to be used as identifiers for the listbox options. These will not be displayed.

public string[] optionStrings;
Array of strings to be shown in Option/Text

public Sprite[] optionSprites;
Array of spites to be shown in Option/Image

public GameObject closedListBox;
Reference to the closed listbox. Will Be set active/inactive when the listbox opens/closes

public GameObject openedListBox;
Reference to the opened listbox. Will Be set active/inactive when the listbox opens/closes

public GameObject scrollableArea;
Reference to the opened listbox. Will be used to measure the dimensions of the content area

public GameObject optionTemplate;
Reference to the template for options. Will be instantiated the number of times needed to fill scrollableArea + 1

public GameObject highlightedOption;
Reference to highlighted option. Will be made active/inactive to show the selected value

public bool changeTitleToSelectedOption = true;
If set to true, the children of closedListBox named "Text" and "Image" will be set to match the selected option. If no option is selected, they will be set to the default string and default sprite (if set)

public int valueInt
Read the currently selected value.

public string valueString;
Read the currently selected value

public Sprite valueSprite;
Read the currently selected value

public ValueChangedMethod onValueChanged;
Set a delegate method to call when the selected option changes.
Method should look like: void ValueChangedMethod(ListBox aListBox). See Demo script for an example.

Methods


public void SetOptions(int[] ints, string[] strings, Sprite[] sprites)
Set the option values for the listbox. The parameters are optional, but you need to specify at least one of them.
Example:
myListBox.SetOptions(new string[4] {"Ketchup", "Mayo", "BBQ", "Curry"} );

public int GetSelectedIndex()
Find the index of the currently selected option. Returns -1 if no option is selected

public void SetSelectedIndex(int idx)
Set valueInt, valueString and valueSprite to match the index of a newly selected option. Will also trigger the onValueChanged delegate

public void OpenListBox()
Open the listbox programmatically

public void CloseListBox()
Close the listbox programmatically

public void SetTitle(string aTitle)
Set the default tiltle that will be shown on closedListbBox/Text when no option is selected or when changeTitleToSelectedOption == false

public void SetSprite(Sprite aSprite)
Set the default sprite that will be shown on closedListBox/Image when no option is selected or when changeTitleToSelectedOption == false

public void Reset()
Programmatically clear the option arrays and clear any selected values.







follow us