Skip to content

CustomLoader该如何支持异步呢?小游戏平台WebGL需要使用异步加载 #1197

@Zsnbda

Description

@Zsnbda
    public override void Initialize(GameObject eventSystem)
    {
        base.Initialize(eventSystem);
        luaEnv = new LuaEnv();

        LuaEnv.CustomLoader loader = CustomLoader;
        luaEnv.customLoaders.Clear();
        luaEnv.AddLoader(loader);
        luaEnv.AddBuildin("pb", XLua.LuaDLL.Lua.LoadLuaProfobuf);
        luaEnv.AddBuildin("rapidjson", XLua.LuaDLL.Lua.LoadRapidJson);
    }

    private byte[] CustomLoader(ref string filepath)
    {
        TextAsset asset = App.Loader.LoadAsset<TextAsset>(PATH + filepath + ".lua.txt");
        return asset.bytes;
    }

目前是先把所有的lua文件异步加载到内存中,CustomLoader从内存中获取, 有更好的方案支持CustomLoader直接使用async/await异步加载吗?或者是必须得修改xlua的源代码支持异步require呢?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions