UGUI_DropDown
public class L14 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//相关参数
//Caption Text 关联显示当前选择内容的文本组件
//Item Text 关联下拉列表用的文本控件
//Value 当前选项索引值
//代码控制
Dropdown dd = GetComponent<Dropdown>();
print(dd.value);
//dd.options是一个list,用索引值得到具体选项
print(dd.options[dd.value].text);
//代码添加选项
dd.options.Add(new Dropdown.OptionData("123"));
//监听事件的两种方式
//1.拖脚本
//2.代码添加(int)
dd.onValueChanged.AddListener((a) => { });
}
}

浙公网安备 33010602011771号