javascript - Apache 未加载 WebGL 内容

标签 javascript apache unity-game-engine

我有一个在 Unity 中构建的 WebGL 游戏,可以在本地正常运行,但我想将其托管在我的新 Apache2.4 服务器上。我已将文件移至服务器,但是当我加载页面时,除了 WebGL 内容之外,所有内容都会加载(请参见下面的屏幕截图)。

开发工具告诉我,UnityProgress.js 和 UnityLoader.js 文件无法加载,并出现 404 错误代码。 Unity 生成的 index.html 中的 html 文件和文件夹名称区分大小写是正确的(如果不正确,我会感到惊讶)。我尝试将它们移出子文件夹并将它们放在我的 index.html 文件旁边并更新 html,但我仍然收到相同的消息。

我的 Apache 服务器上是否缺少用于加载 .js 文件的设置?

enter image description here

编辑:下面是index.html文件的内容。

<!doctype html>
<html lang="en-us">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Unity WebGL Player | WebGLClock</title>
    <link rel="stylesheet" href="style.css">
    <link rel="shortcut icon" href="favicon.ico" />
    <script src="UnityProgress.js"></script>
  </head>
  <body class="template">
    <p class="header"><span>Unity WebGL Player | </span>WebGLClock</p>
    <div class="template-wrap clear">
      <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" height="600px" width="960px"></canvas>
      <br>
      <div class="logo"></div>
      <div class="fullscreen"><img src="fullscreen.png" width="38" height="38" alt="Fullscreen" title="Fullscreen" onclick="SetFullscreen(1);" /></div>
      <div class="title">WebGLClock</div>
    </div>
    <p class="footer">&laquo; created with <a href="http://unity3d.com/" title="Go to unity3d.com">Unity</a> &raquo;</p>
    <script type='text/javascript'>
  var Module = {
    TOTAL_MEMORY: 268435456,
    errorhandler: null,         // arguments: err, url, line. This function must return 'true' if the error is handled, otherwise 'false'
    compatibilitycheck: null,
    dataUrl: "Bin WebGL.data",
    codeUrl: "Bin WebGL.js",
    memUrl: "Bin WebGL.mem",

  };
</script>
<script src="UnityLoader.js"></script>

  </body>
</html>

以及/var/www/html 中的文件夹结构图片。

enter image description here

最佳答案

我的 Linux 发行版附带 lighttpd。这是另一个网络服务器拦截了所有端口 80 流量。

运行以下命令修复了问题:

sudo apt-get remove lighttpd

关于javascript - Apache 未加载 WebGL 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40599374/

相关文章:

javascript - JavaScript 中的静态/共享属性和方法

regex - 如何将查询字符串变量与 mod_rewrite 匹配?

php - 不确定我的映射在 Elasticsearch 中是否有效

unity-game-engine - Unity 中可以存在这个着色器吗?

c# - Steam VR 场景在 Unity 中重新加载时停止响应

c# - 初始化的对象在 OnAwake 和 OnEnable() 之间变为 null

Javascript 书签不会更改图像的来源

javascript - 动态改变Jquery动画

javascript - 使用搜索查询过滤数据? WordPress JSON 对象 + VueJS2

java - 通过 Java 代码管理 Apache HTTP Server