C#调用functionc返回值

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);
}

发布了205 篇原创文章 · 获赞 8 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/cuijiahao/article/details/103906300