NGUI OnChange event

Do these components have an Onchange?

The following components have an accident in oncore. When you click and shoot, you will fire it.


The related component in ngui

popup menu (menu menu)

heart (checkbox)

input (text field)

progress bar (progress bar)


Define an OnChange event

Listeventdelegate> UIToggle.onChange = new listeventdelegate> ()

EventDelegate.Add(checkStatus.onChange, OnCheckStatusChange),

Occurs on startup


An example when changing

//Найдите контроль
 var checkStatus = GetControl<UIToggle>("CheckStatus", trans); 
 //Выберите и отмените событие выбора для элементов управления
 EventDelegate.Add(checkStatus.onChange, OnCheckStatusChange);
/// <summary>
///  Событие по изменению состояния выбора флажки
/// </summary>
private void OnCheckStatusChange()
    bool check = UIToggle.current.value;//Выбрать ли
    //Uitoggle.current сам uitoggle
    UISprite markSprite = UIToggle.current.GetComponent<UISprite>();//Получите спрайт
    if (check)
        markSprite.spriteName = "checkbox_border";
        markSprite.spriteName = "checkbox_border_D";

This article was translated from a blog post on Zhao Qingqing’s blog.

Leave a Comment