using UnityEngine;
using XLua;
[LuaCallCSharp]
public class SpecialParam
{
public void DefaultParam(int arg0, string arg1 = "1", int arg2 = 2)
{
Debug.Log("arg0:" + arg0);
Debug.Log("arg1:" + arg1);
Debug.Log("arg2:" + arg2);
}
public void VariableParam(int arg0, params string[] args)
{
Debug.Log("arg0:" + arg0);
Debug.Log("args.length:" + args.Length);
foreach (string arg in args)
{
Debug.Log("可变参数:" + arg);
}
}
}
print('启动了Lua')
function init()
print("执行了Lua的全局方法init")--无参数的方法
CreatUnityObj()
end
function CreatUnityObj()
local class= CS.SpecialParam()
print('--------默认参数调用-----------------')
class:DefaultParam(1)
class:DefaultParam(100,"我是谁")
print('--------可变参数调用-----------------')
class:VariableParam(200,'可变参数1','可变参数2','可变参数3')
end
|
请发表评论