---
title: 在 Development 中调试 Web 构建
product: Unity Editor
version: '6000.0'
latest_version: '7000.0'
status: This page documents version 6000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/zh-cn/engine/6000.0/manual/platform-specific/webgl/develop/debugging/web-debugging-development
latest_url: https://docs.unity.com/zh-cn/engine/7000.0/manual/platform-specific/webgl/develop/debugging/web-debugging-development.md
last_updated: 2026-10-30
generated_at: 2026-11-16T07:39:07.330Z
locale: zh-cn
---

# 在 Development 中调试 Web 构建

> 检查日志、使用 Development 构建和配置异常 Support 可在 Development 期间诊断问题。

检查日志、使用 Development 构建和配置异常 Support 可在 Development 期间诊断问题。

## 在浏览器的 Javascript 控制台调试版本##debug-your-build-in-a-browser's-javascript-console

Unity Web 平台无法访问文件System，因此不会像Other平台一样写入日志文件。但是，它会将所有日志记录信息（例如 `Debug.Log`、`Console.WriteLine` 或 Unity 的内部日志记录）写入浏览器的 Javascript 控制台。

Open Javascript 控制台：

| **OS**  | **浏览器**        | **说明**                                                   |
| ------- | -------------- | -------------------------------------------------------- |
| Windows | Firefox        | 按 **Ctrl**+**Shift**+**K**。                              |
| Windows | Chrome         | 按 **Ctrl**+**Shift**+**J**。                              |
| Windows | Microsoft 边缘   | 按 **F12**。                                               |
| Windows | Internet 资源管理器 | 按 **F12**。                                               |
| Mac     | Firefox        | 按 **Command**+**选项**+**K**。                              |
| Mac     | Chrome         | 按 **Command**+**选项**+**J**。                              |
| Mac     | 野生动物园          | 转到**偏好**设置 > **高级** > **开发**。按 **Command**+**选项**+**C**。 |

## 创建要调试的开发版##create-a-development-build-to-debug

您可能希望在 Unity 中make开发版版本以调试代码。要make开发版：

1. Open the [Build Profiles 窗口](/engine/6000.0/manual/publishing-builds.md)。

2. 启用

Development版允许您连接性能性能分析器。Unity 不会[Minify](https://en.wikipedia.org/wiki/Minification_%28programming%29)代码，因此发出的 Javascript 代码仍然包含可读、[C++ 混合](https://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B)的函数名称。

如果运行遇到浏览器报错、使用 `Debug.LogError` 时或发生异常并禁用异常 Support 时，浏览器会使用这些堆栈跟踪。与具有完全异常SupportWhen发生的Managed堆栈跟踪不同，这些堆栈跟踪的名称错误，并包含Managed代码和内部 Unity 引擎代码。

## 异常 Support##exception-support

Web 具有不同级别的异常 Support，但默认情况下，Unity Web 仅支持显式抛出异常。有关更多信息，请参阅 [Web Player Settings](/engine/6000.0/manual/platform-specific/webgl/develop/class-player-settings-web-gl.md#wasm-language-features)。您可以启用 **Full** 异常 Support，在 IL2CPP 生成的代码中发出额外的检查，从而捕获对 Managed 代码中的 null 引用和边界外 Array 元素的访问。这些额外的检查会显著影响性性能并增加代码大小和加载时间，因此只能将其使用于调试。

完全异常Support还会发出函数名称来为Managed代码Generate堆栈跟踪。因此，对于未捕获的异常和 `Debug.Log` 语句，控制台中会显示堆栈跟踪。使用 `System.Environment.StackTrace` 获取 stack trace 字符串。

## 其他资源##additional-resources

* [Web 构建的调试和 Troubleshoot](/engine/6000.0/manual/platform-specific/webgl/develop/debugging.md)
* [调试生产 Web 构建](/engine/6000.0/manual/platform-specific/webgl/develop/debugging/web-debugging-production.md)
* [Troubleshoot 常见 Web 版本错误](/engine/6000.0/manual/platform-specific/webgl/develop/debugging/web-debugging-troubleshooting.md)
