using UnityEngine;
using System.Collections;
using System;
public class Test : MonoBehaviour
{
private Action<string> callback;
// Use this for initialization
void Start ()
{
SetDestination(Vector2.one, delegate(string value)
{
//此处代码当Action调用的时候才会执行
Debug.Log(value);
});
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.Space))
{
callback(DateTime.Now.ToString());
}
}
public void SetDestination(Vector2 point, Action<string> callback)
{
Debug.Log(point);
this.callback = callback;
}
}
网友评论