1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using LuaInterface;
6
7 namespace LuaTest001
8 {
9 /// <summary>
10 /// 1.把LuaInterface.dll,Lua51.dll,luanet.dll放在exe文件里
11 /// 2.引用LuaInterface.dll类库
12 /// 3.在C#定义的函数和Lua同步的函数一定要注意命名,大小写和访问类型一定要一致,否则会出现报错(真的感觉坑爹)
13 /// 4.导出的Unity文件,需要把1中的dll放在同级,在editor中,直接放入assert下面,引用就可以。
14 /// </summary>
15 class Program
16 {
17
18 private static Lua m_lua =
new Lua();
19 public static void Init()
20 {
21 Program p =
new Program();
22 m_lua.RegisterFunction(
"Print_Lua", p, p.GetType().GetMethod(
"Print_Csharp"));
23 m_lua.DoFile(
@"C:\test.lua");
24 }
25
26 public void Print_Csharp(
string s)
27 {
28 Console.WriteLine(s);
29 }
30 static void Main(
string[] args)
31 {
32 Init();
33 m_lua.GetFunction(
"Show").Call();
34 }
35 }
36 }
转载请注明地址:http://www.cnblogs.com/Vincentblogs/p/4083028.html
QQ群:346738352 Unity技术交流群,讲纯粹的技术。
转载于:https://www.cnblogs.com/Vincentblogs/p/4083003.html