-
Notifications
You must be signed in to change notification settings - Fork 30
关于Action
woniupapa edited this page Nov 5, 2014
·
3 revisions
cslight脚本中使用Action注意事项(CSL表示cslight脚本) 1.下面介绍如何让它在脚本中正常使用 在c#那层注册一下Action
env.RegType(new CSLE.RegHelper_DeleAction(typeof(Action), "Action"));
// CSL脚本
Action myAction = MyActionFunc; // 声明个Action将方法传给它
private void MyActionFunc()
{
Debug.Log("MyActionFunc");
}
private void CallMyActionFunc(Action theFun)
{
if (theFun != null)
{
theFun();
}
}
//脚本内调用
CallMyActionFunc(myAction);
2.CSL脚本里面如何调用c#里面含有Action<UnityEngine.Object>参数的接口呢 在c#那层注册一下 Action<UnityEenv.RegType(new CSLE.RegHelper_DeleAction<UnityEngine.Object>(typeof(Action<UnityEngine.Object>), "Action"));
// c#代码
public class StaticAction
{
public static void MyStaticAction(Action<UnityEngine.Object> go)
{
Debug.Log("MyStaticAction");
}
}
// CSL代码
using Object = UnityEngine.Object;//如果发生名字冲突可以这样写
Action<Object> myAction = MyActionFuncWithGO; // 声明个Action将方法传给它
private void MyActionFuncWithGO(Object go)
{
Debug.Log("MyActionFuncWithGO");
}
// 调用c#接口
StaticAction.MyStaticAction(myAction);