Lua中调用ref和out修饰参数的函数/重载函数
1.Unity学习笔记--基础2.Unity学习笔记--入门3.Unity学习笔记--数据持久化之PlayerPrefs的使用4.Unity学习笔记--数据持久化XML文件(1)5.Unity学习笔记--数据持久化XML文件(2)6.Unity学习笔记--数据持久化Json7.NGUI学习笔记(1)8.NGUI学习笔记29.NGUI学习笔记3.510.NGUI学习笔记4.011.Unity 热更--AssetBundle学习笔记 0.712.Unity 热更--AssetBundle学习笔记 0.813.Unity 热更--AssetBundle学习笔记 1.0【AB包资源加载工具类的实现】14.[2]自定义Lua解析方式15.Unity热更学习toLua使用--[1]toLua的导入和默认加载执行lua脚本16.自定义Lua解析器管理器-------演化脚本V0.517.使用自定义委托来调用Lua中的多返回值和长参数类型函数18.使用自定义lua解析管理器调用lua脚本中的table19.Lua热更学习--使用toLua中的协程20.toLua中Lua调用C#中的类21.热更学习笔记10~11----lua调用C#中的List和Dictionary、拓展类中的方法
22.Lua中调用ref和out修饰参数的函数/重载函数
23.Unity 编辑器中获取选中的文件夹、文件路径[12] lua中调用ref 和 out 修饰参数的函数数值
public int RefCompute(int a, ref int b, ref int c, int d) { b += a; c += d; return b + c; } public int OutCompute(int a, out int b, out int c,int d) { b = a + 1; c = d + 2; return b + c; } public int RefOutCompute(int a, ref int b, out int c,int d) { a += b; c = d + 3; return a + c; }
lua脚本中进行调用
------------------lua中调用C#的ref 和 out方法 ---- lua调用ref参数的函数 ref修饰的参数会返回值形式返回 ---第一个返回值为函数返回会值 ---之后返回值为ref修饰的参数结果 local a,b,c = student:RefCompute(1,2,3,4) print("a=" .. a) -- 10 print("b=" .. b) -- 1+2 print("c=" .. c) -- 3+4 --与ref修饰参数一样 ---out修饰的参数也会随结果返回 local d,e,f = student:OutCompute(10,9,8,7) print("d=" .. d) -- 20 print("e=" .. e) -- 10 + 1 print("f=" .. f) --7 + 2 --调用参数类型含有ref和out修饰的函数 --会依次随着函数结果返回 local d,e,f = student:RefOutCompute(10,9,8,7) print("d=" .. d) -- 19 print("e=" .. e) -- 9 ref修饰参数返回值 参数数值未变 print("f=" .. f) --10+ 9+ 3 + 7 out修饰参数返回值
[13]Lua中调用C#的重载函数
几个简单的方法,注意有out修饰参数类型的重载函数.
lua脚本中调用:
运行结果:
本文作者:畅知
本文链接:https://www.cnblogs.com/TonyCode/p/18209616
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步