未找到 Unity Webgl js 文件

Unity Webgl js File Not Found

我正在做一些 WebGL 项目,然后我将我的项目推送到一些网络服务器上。当我打开网站 (otom.playback.com.tr) 时,出现了一些错误,如下所示,

http://otom.playback.com.tr/Release/deneme.js Failed to load resource: the server responded with a status of 404 (Not Found)

http://otom.playback.com.tr/Release/deneme.jsgz Failed to load resource: the server responded with a status of 404 (Not Found)

UnityLoader.js:1 Uncaught incorrect header check

第一个错误说我 deneme.js 在网络服务器中找不到。但是unity不给我一个js文件。我将所有文件添加为 mime 类型,但仍然不起作用。

我必须为这个错误做什么。问候。

根据Unity的官方文档

The Development or Release folder contains the following files (the MyProject file name represents the name of your project). (Note that if you make a release build, files in this folder are compressed and have a .gz suffix. See the comments on Distribution size below.)

  • A MyProject.js JavaScript file containing the code for your player.
  • A MyProject.mem file containing a binary image to initialize the heap memory for your player.
  • A MyProject.data file containing the asset data and scenes.
  • A UnityLoader.js file containing the code needed to load up the Unity content in the web page.le containing the code needed to load up the Unity content in the web page.
  • 如果您的 JS 文件丢失,您应该重建项目并确保其构建时没有任何错误。
  • 确保您的主机允许访问 JS 文件
  • 在部署到网络之前设置一个本地网络服务器来测试您的项目easier/faster

可在此处找到更多信息:http://docs.unity3d.com/Manual/webgl-building.html

如果您可以直接访问您的网络服务器,您可能应该设置 MIME。在我的例子中,IIS 根本不知道如何处理 *.mem、*.data 和其他所有垃圾。

还有这个 - 在 5.3.4f1 上与 Edge。

我的解决方案 - 使用 7Zip,我将 jsgz 文件(和其他 gz 文件)提取到文件夹中,然后播放器开始工作。

我认为如果您使用像 Dropbox 这样蹩脚的东西,默认的压缩处理将不起作用 - 就像我一样:-)

我有同样的问题,我把这个 web.config 放在项目文件夹中,或者您可以在 IIS 中手动添加 mime。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".memgz" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".data" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".datagz" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".jsgz" mimeType="application/x-javascript; charset=UTF-8" />
        </staticContent>
    </system.webServer>
</configuration>