Zeronev
1
Im very familiar with the unity 5 UI, especially with buttons, the way buttons work are calling a method… But I don’t seem to find nor have any idea how to call a Method when clicking a certain option in the dropdown.
I have my own method called UseItem() and needs to be used when the first option in the dropdown is clicked. How can I achieve this?
An example code or a reference would be great!
Thanks, in advance 
Kwarts
3
Here’s a quick example in C#
using UnityEngine;
using UnityEngine.UI;
public Dropdown myDropdown;
void Start() {
myDropdown.onValueChanged.AddListener(delegate {
myDropdownValueChangedHandler(myDropdown);
});
}
void Destroy() {
myDropdown.onValueChanged.RemoveAllListeners();
}
private void myDropdownValueChangedHandler(Dropdown target) {
Debug.Log("selected: "+target.value);
}
public void SetDropdownIndex(int index) {
myDropdown.value = index;
}
Look here: Redirect to... title of new-page
You have to set a callback for the “OnValueChanged” event. That function will get an int as a parameter, which is the index of the selected item in the Dropdown.