DataInputDropdown - ORF-4450/PitScouting GitHub Wiki

Variables

ds

DataStorage

Reference to Programmer-made script "DataStorage"

dropdown

Dropdown

Reference to Unity-made script "Dropdown"

Functions

changeData()

changeData(object)

if the object argument is not a string, nothing happens. Otherwise, everything else below happens

it goes with a for loop dependent on how many options dropdown contains. Everything below is in this for

it creates a new Dropdown.OptionData variable called option for every position in the for, and sets it's value to its relative position in dropdown.options. This is done so you only need to write "option" instead of dropdown.options[i] which increases readability and makes it faster to type.

if the object converted to a string has the same text as the text of option, it sets the dropdown value to i (or the current index in the for) and refreshes shown values

clearData()

clearData()

overrides clearData from DataInput

sets value of dropdown to 0

refreshes the shown value of dropdown

Start()

Start()

sets dropdown to the Dropdown component on the gameObject that has this script

FixedUpdate()

FixedUpdate()

Every frame it calls addData in DataStorage with

key: name of the gameObject this script is on

value: the text of the caption of dropdown

overwrite: always true

DI: the object calling it