NGUI-PopupList

public class L9 : MonoBehaviour
{
    public UIPopupList list;
    // Start is called before the first frame update
    void Start()
    {
        //PopupList-下拉列表

        //制作PopupList
        //1.一个Sprite做背景,一个Label做显示内容
        //2.添加PopupList脚本
        //3.添加碰撞器
        //4.在PopupList脚本的On Value Change选项下关联Label,并选择Label中的SetCurrentSelection函数

        //相关参数
        //Options - 下拉列表显示内容 换行表示增加一个选项
        //Position - 列表出现位置
        //Font - 字体,要设置了字体之后才会显示选项 Padding - 间隔距离
        //Open On - 下拉列表打开方式 (Manual - 手动,相当于关闭,自己用代码处理,一般不选择)
        //On Top - 始终显示在所有面板之前
        //Keep Value - 始终保持列表中的某个默认值

        //监听事件的两种方式
        //1.拖脚本
        //2.通过代码监听

        //通过代码动态添加选项
        list.items.Add("新增选项");
    }
}

posted @ 2025-03-23 16:29  cannedmint  阅读(18)  评论(0)    收藏  举报