在开发过程中,有时可能需要从构建的独立平台播放器、目标设备或 Editor 的日志中获取信息。通常,在遇到问题时需要查看这些文件,以具体了解问题的发生位置。
在 macOS 上,可通过标准 Console.app 实用程序统一访问播放器和 Editor 的日志。
在 Windows 上,Editor 日志放置在默认情况下未在 Windows 资源管理器中显示的文件夹中。请参阅下文。
要查看 Editor 日志,请在 Unity 的 Console 窗口中选择 Open Editor Log。
操作系统 | 日志文件 |
---|---|
macOS | ~/Library/Logs/Unity/Editor.log |
Windows | C:\Users\username\AppData\Local\Unity\Editor\Editor.log |
在 macOS 上,可通过标准 Console.app 实用程序统一访问所有日志。
在 Windows 上,Editor 日志文件存储在本地应用程序数据文件夹 <LOCALAPPDATA>\Unity\Editor\Editor.log,其中的 <LOCALAPPDATA> 由 CSIDL_LOCAL_APPDATA 定义。
操作系统 | 日志文件 |
---|---|
macOS | ~/Library/Logs/Unity/Player.log |
Windows | C:\Users\username\AppData\LocalLow\CompanyName\ProductName\output_log.txt |
Linux | ~/.config/unity3d/CompanyName/ProductName/Player.log |
请注意,在 Windows 和 Linux 独立平台上,可以更改日志文件的位置(或禁止日志记录)。请参阅有关命令行参数的文档以了解更多详细信息。
通过 GDB 控制台或 Organizer Console 访问 XCode 中的设备日志。当应用程序未通过 XCode 调试器运行时,后一种控制台对于获取崩溃日志非常有用。
使用 logcat 控制台访问设备日志。为此,请使用 Android SDK/platform-tools 目录中的 adb 应用程序以及尾随的 logcat 参数:
$ adb logcat
检查 LogCat 的另一种方法是使用 Dalvik Debug Monitor Server (DDMS)。可从 Eclipse 启动或从 Android SDK/tools 内部启动 DDMS。DDMS 还提供了许多其他与调试相关的工具。
设备 | 日志文件 |
---|---|
桌面端 | %USERPROFILE%\AppData\Local\Packages<productname>\TempState\UnityPlayer.log |
Windows Phone | 可使用 Windows Phone Power Tools 进行检索。也可使用 Windows Phone IsoStoreSpy。 |
在 WebGL 上,日志输出将写入浏览器的 JavaScript 控制台。
在 Windows 上,日志文件存储在默认情况下为隐藏状态的位置。
在 Windows Vista/7 的 Windows 资源管理器中,请使用 Tools > Folder Options… > View(选项卡) 来显示 AppData 文件夹。默认情况下会隐藏 Tools 菜单;按一次 Alt 键即可显示。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.