- VisualStudio2022插件的安装及使用-编程手把手系列文章
- pprof-在现网场景怎么用
- C#实现的下拉多选框,下拉多选树,多级节点
- 【学习笔记】基础数据结构:猫树
lua中可以使用table作为class,因此对table中的函数访问调用是必要的根据前面对table访问和function的获取调用,这里尝试获取调用.
依然是如此,此种调用方式获取到的table中的函数是引用拷贝.
Main.lua脚本新增内容 。
CStudent = {
_name = "TonyChang",
_id = "202499990101",
_sex = "male",
CStudent = function()
print("table中的函数")
end
}
测试脚本中的调用内容:
//--------------------------------获取类类型table
LuaTable CStudent = CallLuaManager.Instance().LuaState.GetTable("CStudent");
//执行构造函数
CStudent.GetLuaFunction("CStudent").Call("TonyChang","男");
//打印结果
Debug.Log(CStudent["_name"]+" ," + CStudent["_id"] +" ," +CStudent["_sex"]);
lua中不支持协程,使用toLua中提供的协程方式来使用协程.
在使用协程之前,需要在管理类中添加LuaLooper组件,并将其LuaState与外部使用执行的LuaState虚拟机绑定.
LuaLooper luaLooper = gameObject.AddComponent<LuaLooper>();
// Debug.Log(gameObject.name);
luaLooper.luaState = _luaState;
Main.lua中的协程:
--使用toLua中提供的协程
--制作计时器
function Timer()
local t = 1
while t < 20 do
t = t + 1
coroutine.wait(1)
print(t)
end
StopTimer()
end
local coroutlineTimer = nil
function StartTimer()
print("run")
--开始协程时候传入类型为函数
coroutlineTimer = coroutine.start(Timer)
end
function StopTimer()
--传入要结束的协程
coroutine.stop(coroutlineTimer)
end
我们在C#测试脚本中开启协程:
//----------------------------------开始计时器
LuaFunction startTimer = CallLuaManager.Instance().LuaState.GetFunction("StartTimer");
startTimer.Call();
startTimer.Dispose();
当然也可以传入参数设置计时时长:
最后此篇关于Lua热更学习--使用toLua中的协程的文章就讲到这里了,如果你想了解更多关于Lua热更学习--使用toLua中的协程的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我想要类似于以下伪代码的东西: while input is not None and timer = 5: print "took too long" else: print inp
如何将 MainEngine Observable 转换为 Cold?来自这个例子: public IObservable MainEngine { get
自从手表被发明以来,表盘的方圆之争就始终没有停下来过,在漫长的岁月中,无论是方形还是圆形表盘,人们都为其寻找到足够多的设计元素,让其肆意成长,这种生机与活力后来也延续到了智能手表上,在2014年,这
我正在学习 CUDA,试图解决一些标准问题。例如,我正在使用以下代码求解二维扩散方程。但我的结果与标准结果不同,我无法弄清楚。 //kernel definition __global__ void
我的 Web 应用程序使用 native dll 来实现其部分功能(其位置在 PATH 中提供)。一切正常,直到我对 WAR 进行更改并且 JBoss 热部署此 WAR。此时dll已经找不到了,需要手
我看到这个问题here 。这是关于实现每个发出的项目的延迟。这是根据accepted answer如何实现的: Observable.zip(Observable.range(1, 5) .g
我最近一直在进行冷迁移...这意味着我无法在进行迁移时从应用程序级别读取/写入数据库(维护页面)。 这样就不会因为更改结构而发生错误,而且如果负载很大,我也不希望 mysql 在迁移过程中崩溃。 我的
我是一名优秀的程序员,十分优秀!