自分用めも

初心者ちっくなプログラムネタを中心に、自分用の覚え書きをメモっていくための場所です。

UnityのWebGLでUncaught unknown compression methodエラーになる場合の応急処置

Unity 5.3.2f1 (64-bit)。


apache
・mod_deflateは入れている
・にも関わらずchrome等のコンソールで下記エラーが出る

Failed to load resource: the server responded with a status of 404 (Not Found)
Invoking error handler due to
Uncaught unknown compression method

UnityのForum見たり自分でも投稿したり、色々ググったりして
.htaccessを書き換えるなどしましたが改善せず。

で、下記でやっと直りました。
すごく応急処置的で、多分正当な方法では無いと思います(´・ω・`)

Uncaught unknown compression method (ver5.3.1f1, chrome, firefox) | Unity Community

やり方は簡単で、WebGLビルドで出力されたindex.htmlを三行いじるだけです。

  var Module = {
    TOTAL_MEMORY: 134217728,
    errorhandler: null,            // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    compatibilitycheck: null,
    dataUrl: "Release/WebGL.datagz",  // ←ここ。拡張子に"gz"を付与する
    codeUrl: "Release/WebGL.jsgz",
    memUrl: "Release/WebGL.memgz",
  };

まあ動く方法わかったからとりあえず良かったかな…