Comments (9)
lua那直接return就可以相当于Yield break。
不用stopCoroutine,你不resume协程,然后引用也不指向它,自然它会被gc掉。
from xlua.
如果我想中断一个运行中的Coroutine(不通过内部return的方式),你的建议是什么呢?
from xlua.
在外部没有什么中断好说,lua是单线程的,当你在外部的时候,就代表这个协程不在运行,你不resume直接抛弃掉即可。
from xlua.
你是被Unity用genarator模拟的协程给误导了。Unity的模拟需要把一个genarator注册到协程调度里头,你在外部也要调用个Stop来反注册。
from xlua.
在06_Coroutine范例中我通过在coruntine_test.lua中使用CS.GameObject.Destroy(gameobject)来实现了
from xlua.
哦,我理解错了,你是要中断在和Unity协程配合时,怎么清理Unity协程的问题。。不好意思!
from xlua.
另外我想请教下,为了hotfix,我理论上是不是可以给所有自己的C#类打上HOTFIX_ENABLE,这样做有什么坏处么?
from xlua.
我在这里有分析overhead:https://www.zhihu.com/question/54344452,可以去看看
from xlua.
LuaException: xlua/util.lua:16: c# exception:Non-static method requires a target.,stack: at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000fe] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:236
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
at XLua.OverloadMethodWrap.Call (IntPtr L) [0x0021f] in C:\Users\Administrator.X9WRY5BD2TWFRD2\Desktop\mohe-unity-mahjong-client\Assets\ThirdParty\XLua\Src\MethodWarpsCache.cs:242
at XLua.MethodWrap.Call (IntPtr L) [0x00041] in C:\Users\Administrator.X9WRY5BD2TWFRD2\Desktop\mohe-unity-mahjong-client\Assets\ThirdParty\XLua\Src\MethodWarpsCache.cs:297
stack traceback:
[C]: in function 'assert'
xlua/util.lua:16: in function <xlua/util.lua:14>
XLua.LuaEnv.ThrowExceptionFromError (Int32 oldTop) (at Assets/ThirdParty/XLua/Src/LuaEnv.cs:430)
XLua.DelegateBridge.__Gen_Delegate_Imp0 () (at Assets/ThirdParty/XLua/Gen/DelegatesGensBridge.cs:34)
Coroutine_Runner+c__Iterator0.MoveNext () (at Assets/Scripts/Framework/Coroutine_Runner.cs:21)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
但是他报这个错啊,我啥都没管
`
local yield_return = (require 'cs_coroutine').yield_return
self.co = coroutine.create(function()
while true and not self.stop_coroutine do
for i,v in ipairs(self.all_item) do
if self.all_item[i].IsNull() then
end
self.all_item[i].anchoredPosition = Vector2(0, self.all_item[i].anchoredPosition.y + 1)
if self.all_item[i].anchoredPosition.y >= 90 then
self.all_item[i].anchoredPosition = Vector2(0,-(#self.all_item - 1) * (90 + 6))
end
end
if not self.stop_coroutine then
return
end
yield_return(CS.UnityEngine.WaitForSeconds(0.0001))
end
end)
coroutine.resume(self.co)
`
from xlua.
Related Issues (20)
- "SymbolsNotMatchingException" occurs when performing Obfuscator after HotFix Injection.
- 想编译Nintendo Switch平台用的XLua版本 HOT 1
- 鸿蒙平台导出包报错 HOT 2
- ps4平台编译xlua不通过 HOT 1
- 添加HOTFIX_ENABLE宏,在主线程中调用GC.WaitForPendingFinalizers导致死锁,有什么推荐修改方案吗? HOT 4
- 代码里using了UnityEngine.Purchasing.Security命名空间导致Android打包inject失败
- self.gameObject无法访问 HOT 2
- xLua适配 OpenHarmony 平台吗 HOT 1
- Unity2022.3.17发布WebGL后运行报错 HOT 1
- 使用ExampleConfig.cs中的热更新Delegate配置,会使C#方法通过反射调用
- webgl平台下如何自定义异步加载loader HOT 2
- webgl微信小程序打包出现错误,求帮助 HOT 1
- 集成第三方库,在webgl平台要怎么处理? HOT 1
- Xlua中非UnityObject对象销毁问题
- unity2022生成wrap代码时报错 HOT 1
- 无法在包含 IntPtr 的结构体上使用 GCOptimize
- unity2021正常,unity2022,new LuaEnv();就报错。 HOT 1
- 如何将枚举值转换为其基础类型? HOT 1
- 开启了热更新后,游戏内切场景时间多花了3秒,从12秒变成15秒,这个性能正常吗
- 如何在 Lua 中获取给定 Dictionary<,> 值的所有键?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlua.