CsCallLua.lua
function add(a,b)
return a + b , 66 , 77
end
C#
using System;
using System.Collections.Generic;
using UnityEngine;
using XLua;
public class CsCallLua : MonoBehaviour {
void Start () {
var luaenv = new XLua.LuaEnv();
luaenv.DoString("require 'CsCallLua'");
//带参数的
Add ac = luaenv.Global.Get<Add>("add");
int v,k;
print(ac(22, 99, out v,out k) + ":" + v + ":" + k);
ac = null;
luaenv.Dispose();
}
[CSharpCallLua]//告诉编辑器这个接口是Lua的一个接口
delegate int Add(int a, int b,out int v, out int k);
}