本文整理汇总了C#中LuaInterface.LuaFunction.Call方法的典型用法代码示例。如果您正苦于以下问题:C# LuaFunction.Call方法的具体用法?C# LuaFunction.Call怎么用?C# LuaFunction.Call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LuaInterface.LuaFunction
的用法示例。
在下文中一共展示了LuaFunction.Call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreatePanel
IEnumerator OnCreatePanel(string name, LuaFunction func = null)
{
yield return StartCoroutine(Initialize());
string assetName = name + "Panel";
// Load asset from assetBundle.
string abName = name.ToLower() + AppConst.ExtName;
AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));
if (request == null) yield break;
yield return StartCoroutine(request);
// Get the asset.
GameObject prefab = request.GetAsset<GameObject>();
if (Parent.FindChild(name) != null || prefab == null) {
yield break;
}
GameObject go = Instantiate(prefab) as GameObject;
go.name = assetName;
go.layer = LayerMask.NameToLayer("Default");
go.transform.SetParent(Parent);
go.transform.localScale = Vector3.one;
go.transform.localPosition = Vector3.zero;
go.AddComponent<LuaBehaviour>();
if (func != null) func.Call(go);
Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
}
示例2: CreatePanel
/// <summary>
/// ������壬������Դ������
/// </summary>
/// <param name="type"></param>
public void CreatePanel(string name, LuaFunction func = null)
{
string assetName = name + "Panel";
string abName = name.ToLower() + AppConst.ExtName;
ResManager.LoadPrefab(abName, assetName, delegate(UnityEngine.Object[] objs) {
if (objs.Length == 0) return;
// Get the asset.
GameObject prefab = objs[0] as GameObject;
if (Parent.FindChild(name) != null || prefab == null) {
return;
}
GameObject go = Instantiate(prefab) as GameObject;
go.name = assetName;
go.layer = LayerMask.NameToLayer("Default");
go.transform.SetParent(Parent);
go.transform.localScale = Vector3.one;
go.transform.localPosition = Vector3.zero;
go.AddComponent<LuaBehaviour>();
if (func != null) func.Call(go);
Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
});
}
示例3: Start
void Start()
{
lua = new LuaState();
lua.Start();
lua.DoString(script, "AccessingArray.cs");
int[] array = { 1, 2, 3, 4, 5};
func = lua.GetFunction("TestArray");
func.BeginPCall();
func.Push(array);
func.PCall();
double arg1 = func.CheckNumber();
string arg2 = func.CheckString();
bool arg3 = func.CheckBoolean();
Debugger.Log("return is {0} {1} {2}", arg1, arg2, arg3);
func.EndPCall();
//转换一下类型,避免可变参数拆成多个参数传递
object[] objs = func.Call((object)array);
if (objs != null)
{
Debugger.Log("return is {0} {1} {2}", objs[0], objs[1], objs[2]);
}
lua.CheckTop();
}
示例4: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(GameObject go, LuaFunction luafunc) {
if (go == null) return;
UIEventListener.Get(go).onClick = delegate(GameObject o) {
luafunc.Call(go);
buttons.Add(luafunc);
};
}
示例5: UnityEngine_Events_UnityAction
public static Delegate UnityEngine_Events_UnityAction(LuaFunction func)
{
UnityEngine.Events.UnityAction d = () =>
{
func.Call();
};
return d;
}
示例6: Action
public static Delegate Action(LuaFunction func)
{
Action d = () =>
{
func.Call();
};
return d;
}
示例7: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(GameObject go, LuaFunction luafunc) {
if (go == null) return;
buttons.Add(luafunc);
go.GetComponent<Button>().onClick.AddListener(
delegate() {
luafunc.Call(go);
}
);
}
示例8: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(string button, LuaFunction luafunc) {
Transform to = trans.Find(button);
if (to == null) return;
GameObject go = to.gameObject;
UIEventListener.Get(go).onClick = delegate(GameObject o) {
luafunc.Call(go);
buttons.Add(luafunc);
};
}
示例9: ForeachChild
/// <summary>
///
/// </summary>
/// <param name="parent"></param>
/// <param name="eachFn"></param>
public static void ForeachChild(GameObject parent, LuaFunction eachFn)
{
Transform pr=parent.transform;
int count = pr.childCount;
Transform child = null;
for (int i = 0; i < count; i++)
{
child = pr.GetChild(i);
eachFn.Call(i, child.gameObject);
}
}
示例10: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(string button, LuaFunction luafunc)
{
Transform to = trans.Find(button);
if (to == null) return;
buttons.Add(luafunc);
GameObject go = to.gameObject;
go.GetComponent<Button>().onClick.AddListener(
delegate() {
luafunc.Call(go);
}
);
}
示例11: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(GameObject go, LuaFunction luafunc) {
if (go == null || luafunc == null) return;
if (buttons.ContainsKey (go.name)) {
Debug.LogWarning ("Already Registered :" + go.name + " click event");
RemoveClick (go);
}
buttons.Add(go.name, luafunc);
go.GetComponent<Button>().onClick.AddListener(
delegate() {
luafunc.Call(go);
}
);
}
示例12: CallLuaFunction
public void CallLuaFunction(LuaFunction func, Object[] args)
{
try
{
if (args != null)
{
func.Call(args);
}
else
{
func.Call();
}
m_luaState.DoString("io.flush()");
}
catch (LuaException e)
{
PrintError(e);
}
catch (Exception e)
{
PrintError(e);
}
}
示例13: OnLoadAsset
IEnumerator OnLoadAsset(string abname, string assetName, LuaFunction func) {
// Load asset from assetBundle.
string abName = abname.ToLower() + AppConst.ExtName;
AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));
if (request == null) yield break;
yield return StartCoroutine(request);
// Get the asset.
GameObject prefab = request.GetAsset<GameObject>();
if (func != null) {
func.Call(prefab);
func.Dispose();
func = null;
}
}
示例14: OnComplete
public static void OnComplete(Tweener tweener, LuaFunction func)
{
tweener.OnComplete(() =>
{
try
{
func.Call();
}
catch (Exception e)
{
Debug.LogError(e);
}
func.Dispose();
func = null;
});
}
示例15: Start
// Use this for initialization
void Start () {
LuaScriptMgr mgr = new LuaScriptMgr();
mgr.DoString(script);
// Get the function object
func = mgr.GetLuaFunction("luaFunc");
//有gc alloc
object[] r = func.Call(123456);
print(r[0]);
// no gc alloc
int num = CallFunc();
print(num);
}