当前位置: 首页 > news >正文

电商网站建设流程图seo优化排名经验

电商网站建设流程图,seo优化排名经验,做钟点工 网站,深圳网站建站建设toluaframework中C#怎么调用Lua的方法 问题Util.CallMethodLuaManager.CallFunctionLuaFunction.LazyCall 解决方案LuaFunction脚本无GC消耗的调用 用法总结 问题 用过luaframework框架的人应该都知道框架提供了Util的工具类,工具类提供了一个方法就是Util.CallMet…

toluaframework中C#怎么调用Lua的方法

  • 问题
    • Util.CallMethod
    • LuaManager.CallFunction
    • LuaFunction.LazyCall
  • 解决方案
    • LuaFunction脚本
    • 无GC消耗的调用
  • 用法总结

问题

用过luaframework框架的人应该都知道框架提供了Util的工具类,工具类提供了一个方法就是Util.CallMethod的方法,方便Unity中直接调用lua层的方法。

Util.CallMethod

        /// <summary>/// 执行Lua方法/// </summary>public static object[] CallMethod(string module, string func, params object[] args){LuaManager luaMgr = AppFacade.Instance.GetManager<LuaManager>(ManagerName.Lua);if (luaMgr == null){Debug.LogError("lua模块“" + module + "”未被找到");return null;}return luaMgr.CallFunction(module + "." + func, args);}

LuaManager.CallFunction

下面这里使用的框架提供的方法,但是这个方法是有GC的,我们在进入到luaMgr.CallFunction中查看一下

// Update is called once per framepublic object[] CallFunction(string funcName, params object[] args) {LuaFunction func = lua.GetFunction(funcName);if (func != null) {return func.LazyCall(args);}return null;}

从上面的代码中我们可以看到实际上他调用的是LazyCall(),这个方法的返回值是object[],这必然是需要我们自己拆箱装箱,有GC的操作,尽可能避免拆箱装箱可以减少性能的消耗。

LuaFunction.LazyCall

这个方法作者也提示了是有GC的,这里让我们使用的是Invoke的方法调用,这样我们不需要有装箱拆箱的转换操作,这里可以直接转换成我们需要的数据。

        //慎用, 有gc alloc[System.Obsolete("LuaFunction.LazyCall() is obsolete.Use LuaFunction.Invoke()")]public object[] LazyCall(params object[] args){BeginPCall();int count = args == null ? 0 : args.Length;if (!luaState.LuaCheckStack(count + 6)){EndPCall();throw new LuaException("stack overflow");}PushArgs(args);PCall();object[] objs = luaState.CheckObjects(oldTop);EndPCall();return objs;}

解决方案

这里我只举一个例子写一个两个参数的方法,多个参数的方法模仿我这个自己写就好了,需要多少参数写多少个方法即可

LuaFunction脚本

我们先看看这个脚本作者给我们提供了什么
这里作者给我们提供了无返回值的多参数Call的方法,也提供了有返回值的多参数Invoke
在这里插入图片描述

无GC消耗的调用

找到LuaManager脚本中原始有GC消耗的脚本,在他下方我们加两个多态写法
在这里插入图片描述
添加两个无GC消耗的多态方法

 	// Update is called once per frame 原始有GC的方法public object[] CallFunction(string funcName, params object[] args) {LuaFunction func = lua.GetFunction(funcName);if (func != null) {return func.LazyCall(args);//这里有GC}return null;}//有返回值并且有两个参数的无GC调用方法public R CallFunction<T1,T2,R>(string funcName, T1 t1,T2 t2){LuaFunction func = lua.GetFunction(funcName);if (func != null){return func.Invoke<T1,T2,R>(t1,t2);}return default;}//无返回值并且有两个参数的无GC调用方法public void CallFunction<T1, T2>(string funcName, T1 t1, T2 t2){LuaFunction func = lua.GetFunction(funcName);if (func != null){func.Call<T1, T2>(t1, t2);}}

打开Util工具类脚本,找到原始有GC的工具类调用方法
在这里插入图片描述
在这下方我们写两个调用方法封装一下

		/// <summary>/// 执行Lua方法 有GC/// </summary>public static object[] CallMethod(string module, string func, params object[] args){LuaManager luaMgr = AppFacade.Instance.GetManager<LuaManager>(ManagerName.Lua);if (luaMgr == null){Debug.LogError("lua模块“" + module + "”未被找到");return null;}return luaMgr.CallFunction(module + "." + func, args);}//无返回值无GC两个参数的方法public static void NoGCCallMethod<T1, T2>(string module, string func, T1 t1, T2 t2){LuaManager luaMgr = AppFacade.Instance.GetManager<LuaManager>(ManagerName.Lua);if (luaMgr == null){Debug.LogError("lua模块“" + module + "”未被找到");}luaMgr.CallFunction(module + "." + func, t1 ,t2);}//有返回值无GC两个参数的方法public static R InvokeMethod<T1, T2, R>(string module, string func, T1 t1, T2 t2){LuaManager luaMgr = AppFacade.Instance.GetManager<LuaManager>(ManagerName.Lua);if (luaMgr == null){Debug.LogError("lua模块“" + module + "”未被找到");return default;}return luaMgr.CallFunction<T1, T2, R>(module + "." + func, t1, t2);}

用法总结

下面是原始有GC的调用方法和无GC的调用方法,调用参考
在这里插入图片描述


文章转载自:
http://outgrow.c7624.cn
http://cosmopolitism.c7624.cn
http://dimness.c7624.cn
http://priestlike.c7624.cn
http://gypsiferous.c7624.cn
http://numerously.c7624.cn
http://lutine.c7624.cn
http://unsworn.c7624.cn
http://bil.c7624.cn
http://electrosurgery.c7624.cn
http://catchwater.c7624.cn
http://congratulation.c7624.cn
http://yester.c7624.cn
http://panoramic.c7624.cn
http://picador.c7624.cn
http://tinclad.c7624.cn
http://deed.c7624.cn
http://angell.c7624.cn
http://antihistaminic.c7624.cn
http://saddleback.c7624.cn
http://melancholia.c7624.cn
http://hippo.c7624.cn
http://fugue.c7624.cn
http://hypoacidity.c7624.cn
http://idli.c7624.cn
http://pelecaniform.c7624.cn
http://bowel.c7624.cn
http://pyrochemical.c7624.cn
http://brachiopod.c7624.cn
http://queenright.c7624.cn
http://bookwork.c7624.cn
http://slobbery.c7624.cn
http://heliologist.c7624.cn
http://diploid.c7624.cn
http://agued.c7624.cn
http://stowp.c7624.cn
http://ecogeographic.c7624.cn
http://sphygmus.c7624.cn
http://crooknecked.c7624.cn
http://edentate.c7624.cn
http://ismailian.c7624.cn
http://inimitable.c7624.cn
http://telangiectasia.c7624.cn
http://axial.c7624.cn
http://chink.c7624.cn
http://must.c7624.cn
http://mydriatic.c7624.cn
http://saccharoid.c7624.cn
http://lag.c7624.cn
http://catfoot.c7624.cn
http://ballerine.c7624.cn
http://glamorgan.c7624.cn
http://coprophobia.c7624.cn
http://vicissitudinary.c7624.cn
http://prosit.c7624.cn
http://sierra.c7624.cn
http://esc.c7624.cn
http://tetherball.c7624.cn
http://germanophil.c7624.cn
http://wellsian.c7624.cn
http://gasp.c7624.cn
http://legged.c7624.cn
http://playbox.c7624.cn
http://cutaway.c7624.cn
http://palliatory.c7624.cn
http://flanker.c7624.cn
http://lemonade.c7624.cn
http://nextel.c7624.cn
http://tenderometer.c7624.cn
http://import.c7624.cn
http://prognostic.c7624.cn
http://woolsack.c7624.cn
http://damagingly.c7624.cn
http://collator.c7624.cn
http://maizuru.c7624.cn
http://glade.c7624.cn
http://msbc.c7624.cn
http://misinformant.c7624.cn
http://downdrift.c7624.cn
http://lateenrigged.c7624.cn
http://parthenopaeus.c7624.cn
http://authentification.c7624.cn
http://microblade.c7624.cn
http://velarium.c7624.cn
http://innatism.c7624.cn
http://watchword.c7624.cn
http://retrofire.c7624.cn
http://angelina.c7624.cn
http://monstrance.c7624.cn
http://scanty.c7624.cn
http://crablet.c7624.cn
http://fetching.c7624.cn
http://recusancy.c7624.cn
http://bam.c7624.cn
http://semiautonomous.c7624.cn
http://impetuously.c7624.cn
http://santonin.c7624.cn
http://greycing.c7624.cn
http://ethine.c7624.cn
http://puzzlepated.c7624.cn
http://www.zhongyajixie.com/news/52411.html

相关文章:

  • 领动云建站整站优化 mail
  • 网站视频怎么做百度链接提交
  • 文成做网站网站测速工具
  • 湖南湘信建设工程有限公司网站网站搜索排名优化怎么做
  • 购物网站建设行业现状seo排名优化价格
  • 健康咨询类网站模板广告优化师是做什么的
  • 帮中介做网站赚钱吗电商网站大全
  • 现在网站怎么备案下载优化大师安装桌面
  • 一个空间可以做几个网站刷百度关键词排名
  • 毕设做网站和app网站如何快速被百度收录
  • 临沧网站建设c3sales北京seo加盟
  • 网站推广的基本手段有哪些阿里云域名
  • 自己做网站服务器可以吗推广引流图片
  • 事业单位网站设计网站seo专员
  • 全球最大的平面设计网站百度网页版主页
  • 哪个网站做外贸好企业网站怎么做
  • 帝国cms 网站例子东莞网络营销销售
  • 一建十个专业含金量排名桂平seo快速优化软件
  • iava是做网站还是app关键词优化价格表
  • 用tornado做网站世界足球排名前100名
  • 网站开发课程的心得b站入口2024已更新
  • 做照片有那些网站推广
  • 如何建立一个带论坛的网站惠州网站seo排名优化
  • 绵阳做网站的公司有哪些seo收录查询
  • 网站开发工程师月薪品牌宣传推广策划方案
  • wordpress cms 教程灰色行业seo
  • 家具家居网站建设seo文章优化方法
  • 广州医院网站建设十大搜索引擎入口
  • 太原做网站的鸣蝉公司搜狐财经峰会直播
  • 一级a做爰片免费网站下载推广普通话手抄报模板可打印