[0]layaair 2.x版本微信小游戏加载ktx失败

已邀请:

1567600631用户

赞同来自:

            var img = new Laya.Image();
            // img.skin = "A0_Common_atlas0.png";
            console.error("Dddd")
            Laya.stage.addChild(img);
            Laya.loader.load("A0_Common_atlas0.ktx",new Laya.Handler(this,function(e){
              debugger
            }))
返回false 官网的例子也是这样加载的 但是在微信小游戏上失败了

小高

赞同来自:

好的已复现正在排查中

x_raizo

赞同来自:

这个问题修复了吗?目前也遇到这个问题,在laya.wxmini.js, 断到ktx文件下载是成功的,转存到本地后,通过_loadHttpRequest方法 加载wxfile:Xxxxxxx 这个地址,回调报Error 了

阿Ray

赞同来自:

就算加载的ktx也有颜色空间的问题

x_raizo

赞同来自:

自己动手修改了引擎,判断如果是写如磁盘的文件地址,就自己调用接口(Laya.MiniFileMgr.fs.readFile())加载接口,将arraybuffer传给onload方法。测试通过,目前没发现啥问题
public function _loadHttpRequest(url, contentType, onLoadCaller, onLoad, onProcessCaller, onProcess, onErrorCaller, onError){
            if(Laya.MiniFileMgr && Laya.MiniFileMgr.isFile(url)){
                //从磁盘读取缓存的文件
                Laya.MiniFileMgr.fs.readFile({
                    filePath: url,
                    success: function(params:*) {
                        // 将读取到的data传递给LayaAir引擎进行处理
                        if(params.errno == 0)
                        {
                            onLoad.call(onLoadCaller, params.data);
                        }else{
                            console.error('文件读取失败,MiniFileMgr.fs.readFile(error=1):', url, onLoadCaller.sourceUrl);
                        }
                    },
                    fail: function(res:*) {
                        console.error('文件读取失败,MiniFileMgr.fs.readFile(error=2):', res, url, onErrorCaller.sourceUrl);
                        onError.call(onErrorCaller, res);
                    }
                });
            }else{
                if (Browser.onVVMiniGame || Browser.onHWMiniGame) {
                    this["_http"] = new HttpRequest();
                }
                else {
                    if (!this["_http"])
                        this["_http"] = new HttpRequest();
                }
                onProcess && this._http.on(Event.PROGRESS, onProcessCaller, onProcess);
                onLoad && this._http.on(Event.COMPLETE, onLoadCaller, onLoad);
                this["_http"].on(Event.ERROR, onErrorCaller, onError);
                this["_http"].send(url, null, "get", contentType);
            }
        }

要回复问题请先

商务合作
商务合作