EZGUI的Value Changed Delegates文档翻译

当值改变时,EZGUI允许通过AddValueChangedDelegate()方法控制事件的逻辑处理。

代码:

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour
{
    // The below references should be populated
    // by dragging the desired controls from
    // scene hierarchy onto these variables in
    // the inspector:

    // Reference to a slider
    public UISlider slider;

    // Reference to a radio button
    public UIRadioBtn radioBtn;

    void Start()
    {
        // Register our delegate with both controls:
        slider.AddValueChangedDelegate(MyDelegate);
        radioBtn.AddValueChangedDelegate(MyDelegate);
    }

    // The delegate itself
    void MyDelegate(IUIObject obj)
    {
        if(obj == slider)
            Debug.Log("The slider's value is: " + slider.Value);
        else if(obj == radioBtn)
            Debug.Log("The radio button's value is: " + radioBtn.Value);
    }
}
posted @ 2012-08-20 16:58  Marble  阅读(153)  评论(0编辑  收藏