vovgou / loxodon-framework

An MVVM & Databinding framework that can use C# and Lua to develop games
MIT License
1.86k stars 363 forks source link

在lua代码中调用IUIViewLocator的LoadWindowAsync异步加载函数报错 #15

Closed ezergame closed 4 years ago

ezergame commented 4 years ago

lua代码如下:

require("framework.System")

local WindowContainer = CS.Loxodon.Framework.Views.WindowContainer
local Context = CS.Loxodon.Framework.Contexts.Context

function launch()
    print("lua launching...")
    local context = Context.GetApplicationContext()
    local locator = context:GetService("AddressableUIViewLocator")
    local winContainer = WindowContainer.Create("MAIN")
    locator:LoadWindowAsync(winContainer, "HotUpdate/Startup/Startup"):OnPostExecute(
        function(window)
            window:Create()
            local transition = window:Show()
            transition:OnStateChanged(
                function(w, state)
                    print("Window:" .. w.Name .. " State:" .. state:ToString())
                end
            )
            transition:OnFinish(
                function()
                    print("OnFinished")
                end
            )
        end
    )
end

我写了一个新的IUIViewLocator接口实现——AddressableUIViewLocator,用于Addressable资源的加载,所以需要使用异步方式。 错误提示说参数无效:

LuaException: invalid arguments to LoadWindowAsync
stack traceback:
    [C]: in method 'LoadWindowAsync'
    [string "chunk"]:35: in function 'launch'
    [string "chunk"]:54: in main chunk
XLua.LuaEnv.ThrowExceptionFromError (System.Int32 oldTop) (at Assets/XLua/Src/LuaEnv.cs:443)
XLua.LuaEnv.DoString (System.Byte[] chunk, System.String chunkName, XLua.LuaTable env) (at Assets/XLua/Src/LuaEnv.cs:276)
XLua.LuaEnv.DoString (System.String chunk, System.String chunkName, XLua.LuaTable env) (at Assets/XLua/Src/LuaEnv.cs:290)

请教一下,应该如何调用才能争取的呢?