【Unity3D】Debugging WebGL builds(nginx版)

目录

Debugging and troubleshooting WebGL builds

The browser’s JavaScript console

window nginx 


【官网地址】:https://docs.unity3d.com/cn/2020.1/Manual/webgl-debugging.html

Debugging and troubleshooting WebGL builds

Visual Studio does not support debugging Unity WebGL content. To help you to find out exactly what’s going on with your content, here are some tips on how to get information out of your build.

Visual Studio 不支持调试 Unity WebGL 内容。 为了帮助您准确了解您的内容发生了什么,这里有一些关于如何从您的构建中获取信息的提示。

The browser’s JavaScript console

Unity WebGL does not have access to your file system, so it does not write a log file like other platforms. However, it does write all logging information (such as Debug.LogConsole.WriteLine or Unity’s internal logging) to the browser’s JavaScript console.

Unity WebGL 无权访问您的文件系统,因此它不会像其他平台一样写入日志文件。 但是,它会将所有日志信息(例如 Debug.Log、Console.WriteLine 或 Unity 的内部日志)写入浏览器的 JavaScript 控制台。

官网信息已明确了不支持Visual Studio调试webGL内容,那如何调试呢?但是它会将日志信息输出到浏览器的Console控制台。

突发奇想后,直接双击编译文件夹下的index.html。结果如下:

 那如何调试?使用apache/nginx做容器去访问

以下已nginx为例

window nginx 

1  nginx: download   或者 nginx-1.21.4 下载适用版本(本例下载nginx-1.21.4),解压到D:\;

2 将unity打包后的文件放到D:\nginx-1.21.4\html下;

3 测试nginx是否可以访问(本地 cmd运行命令);

    3.1 C:\Users\xxxxxx>d:

    3.2 D:\nginx-1.21.4>start nginx

    3.3 浏览器输入 http://localhost:80/ 

     

4 设置路径指向:编辑D:\nginx-1.21.4\conf\nginx.conf,编辑之前可保存一个conf的副本。

   4.1设置静态文件路径指向:

      #静态文件指向
        location /t {
            alias   html/XXX;
            index  index.html index.htm;
        }

      /t:浏览器中的路径,例如http://localhost/t/

      XXX:unityBuild后的文件夹;里面包含index.html文件

      html/XXX:将unity Build后的文件夹放到D:\nginx-1.21.4\html文件夹内;

   4.2 设置接口指向:

      location /xxxx/ {
            proxy_pass http://IP地址:端口号/xxxx/;
        }

     /xxxx/:这个是示例的接口路径关键词,比如:http://localhost:80/test/1/2;test就是接口中的关键词,最好所有的接口中都含有该关键词;

 5 nginx 启停命令,更新设置命令(本地 cmd运行命令)

   5.1 切换到目录:

   

   5.2 启动命令

      D:\nginx-1.21.4>start nginx

  5.3 停止命令

     nginx启动后在任务管理器中会发现有两个进程 tasklist /fi "imagename eq nginx.exe"

使用命令taskkill /f /t /im nginx.exe 关闭nginx进程

   5.4 nginx 更新配置,可以不用重启nginx

       nginx -t 更新之前先检查

      nginx -s reload 更新设置

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhchyun2008

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值