複数の ドロップダウンのイベントハンドラと同じメソッドを使用したいと思います。
あなたは、それは、インスタンスによって名前やこれまでのどのプロパティお好みでどちら比較delegate
の助けを借りて、パラメータとしてDropdown
インスタンスを渡すことができます。
public Dropdown dropdown;
Dropdown otherDropDown;
void OnEnable()
{
//Register to onValueChanged Events
dropdown.onValueChanged.AddListener(delegate { callBack(dropdown); });
}
void OnDisable()
{
//Un-Register from onValueChanged Events
dropdown.onValueChanged.RemoveAllListeners();
}
void callBack(Dropdown currentDropdown)
{
//Compare dropdown by instance?
if (currentDropdown == otherDropDown)
{
int value = currentDropdown.value;
}
//Compare dropdown by name
if (currentDropdown.name == "YourDPName")
{
int value = currentDropdown.value;
}
}