- 最后登录
- 2016-8-29
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 23585
  
- 纳金币
- 20645
- 精华
- 62
|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using LuaInterface;
- namespace LuaTest001
- {
- /// <summary>
- /// 1.把LuaInterface.dll,Lua51.dll,luanet.dll放在exe文件里
- /// 2.引用LuaInterface.dll类库
- /// 3.在C#定义的函数和Lua同步的函数一定要注意命名,大小写和访问类型一定要一致,否则会出现报错(真的感觉坑爹)
- /// 4.导出的Unity文件,需要把1中的dll放在同级,在editor中,直接放入assert下面,引用就可以。
- /// </summary>
- class Program
- {
- private static Lua m_lua = new Lua();
- public static void Init()
- {
- Program p = new Program();
- m_lua.RegisterFunction("Print_Lua", p, p.GetType().GetMethod("Print_Csharp"));
- m_lua.DoFile(@"C:\test.lua");
- }
- public void Print_Csharp(string s)
- {
- Console.WriteLine(s);
- }
- static void Main(string[] args)
- {
- Init();
- m_lua.GetFunction("Show").Call();
- }
- }
- }
复制代码 |
|