C#调用Lua函数

作者:追风剑情 发布于:2018-3-7 16:22 分类:Lua

示例

配置CodeGenConfig.cs

22222.jpg


using UnityEngine;
using System;
using System.Collections;
using XLua;

public class CSharpCallLuaTest : MonoBehaviour {

    private string luascript = @"
        function LuaGFun1(p1)
	        print('LuaGFun1()', p1)
        end";

    private LuaEnv luaenv;

    void Awake()
    {
        luaenv = new LuaEnv();
    }

    void Start () {
        luaenv.DoString(luascript);
        Action<string> luaFun = luaenv.Global.GetInPath<Action<string>>("LuaGFun1");
        luaFun("this is param1");
    }
}


运行测试

11111.jpg

标签: xLua

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号