首页 > 代码库 > NGUI OnChange Event

NGUI OnChange Event

控件

这些常见的控件都有OnChange事件

imageimagecontrol

PopupList (下拉列表)

Toggle (复选框)

Input (文本框)

ProgressBar(进度条)

Widget

OnChange()定义

List<EventDelegate> UIToggle.onChange = new List<EventDelegate>()

EventDelegate.Add(checkStatus.onChange, OnCheckStatusChange);

使用

imageimage

//找到控件 var checkStatus = GetControl<UIToggle>("CheckStatus", trans);  //给控件绑定选择及取消选择事件 EventDelegate.Add(checkStatus.onChange, OnCheckStatusChange); /// <summary>/// CheckBox选择状态改变事件/// </summary>private void OnCheckStatusChange(){    bool check = UIToggle.current.value;//是否选中    //UIToggle.current 是UIToggle自己    UISprite markSprite = UIToggle.current.GetComponent<UISprite>();//获取Sprite    if (check)    {        markSprite.spriteName = "checkbox_border";    }    else    {        markSprite.spriteName = "checkbox_border_D";    }    markSprite.MakePixelPerfect();}

NGUI OnChange Event