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");
}
}
C#回调函数
最新推荐文章于 2024-02-19 10:09:28 发布