1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| public delegate void OnestringParams(string name);
public delegate string OnestringReturn();
public delegate void TransSelf(LuaTable table); [CSharpCallLua] public delegate void TransMy(LuaCore table); ;
[GCOptimize] public struct LuaCore { public int ID; public string Name; public bool IsWoman; public OnestringParams Func1; public OnestringReturn Func2; public TransMy Func3; public TransMy Func4; }
public class CsharpCallTable : MonoBehaviour { void Start() { xLuaEnv.Instance.DoString("return require('L2C/CsharpCallTable')");
} public void UseLuaTable() { LuaTable g = xLuaEnv.Instance.Global; LuaTable core = g.Get<LuaTable>("Core"); Debug.Log(core.Get<string>("Name"));
core.Set<string,string>("Name","admin");
OnestringParams osp = core.Get<OneStringParams>("Func1"); osp("admin");
TransSelf ts = core.Get<TransSelf>("Func4"); ts(core); } public void Usestruct() { LuaTable g = xLuaEnv.Instance.Global; Luacore core = g.Get<Luacore>("Core"); Debug.Log(core.Name); core.Func4(core); }
}
|