`
810364804
  • 浏览: 785365 次
文章分类
社区版块
存档分类
最新评论

C#回调函数

 
阅读更多


using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
        CallBack wd = new CallBack(WorkDoneHandler);
        StartCoroutine(Working(wd));
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    delegate void CallBack();

    //void Working(CallBack callBack)
    //{
    //    //Working code.
    //    //当工作完成的时候执行这个委托.
    //    callBack();
    //}

    IEnumerator Working(CallBack cb)
    {
        Debug.Log(Time.time);
        yield return new WaitForSeconds(3f);
        Debug.Log(Time.time);
        cb();
    }
    void WorkDoneHandler()
    {
        //Do something other.
        Debug.Log("test");
    }
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics