📜  unity set 下拉值 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:58.596000             🧑  作者: Mango

代码示例1
IndexOf:

// returns a list of the text properties of the options
var listAvailableStrings = dropdown.options.Select(option => option.text).ToList();

// returns the index of the given string
dropdown.value = listAvailableStrings.IndexOf("an Option");

FindIndex

dropdown.value = dropdown.options.FindIndex(option => option.text == "an Option");