Lua使用coroutine调用C#异步接口

This commit is contained in:
fatiao 2025-02-25 22:04:54 +08:00
parent 7ccd51e9a1
commit f9348288ce

View File

@ -113,4 +113,19 @@ function ResMgr:Destroy()
end
end
return ResMgr
___G_Coroutine_Id_Dict = {}
function ResMgr:LuaGetGoFromPool(path, asset)
local k = path.."/"..asset
local retgo = nil
___G_Coroutine_Id_Dict[k] = coroutine.create(function()
self:GetGoFromPoolAsync(path, asset, function(go)
retgo = go
coroutine.resume(___G_Coroutine_Id_Dict[k])
end)
coroutine.yield()
end)
coroutine.resume(___G_Coroutine_Id_Dict[k])
return retgo
end
return ResMgr