最近,在学习过程中,用到一些下拉框Dropdown的功能,学习了解了一下,遂作此记录,以便之后查找使用。
获取当前选中的下拉框:
Dropdown dropdown = EventSystem.current.currentSelectedGameObject.transform.parent.transform.parent.transform.parent.transform.parent.gameObject.GetComponent();
下拉框所选的选项值:
transform.Find("missileStatusPanel").transform.Find("missileName").GetComponent().value
下拉框所选选项的内容:
transform.Find("startPointDropdown").GetComponent().options[0].text
为下拉框添加选项:
ListseaArea = new List ();//添加的内容只能为字符串列表 transform.Find("submarinePanel").transform.Find("seaAreaDropdown").GetComponent ().AddOptions(seaArea);
下拉框列表的长度:
transform.Find("startPointDropdown").GetComponent().options.Count
清空下拉框列表中的所有内容:
transform.Find("startPointDropdown").GetComponent().options.Clear()或者
transform.Find("startPointDropdown").GetComponent().ClearOptions()



