如何写入统一游戏的控制台(构建后)?
How do I write to a unity game's console (after build)?
我正在 unity 中制作一个游戏服务器并且 运行 它在 -batchmode
中。我试过 Console.WriteLine
和 Debug.Log
但实际上都没有向控制台打印任何内容(我在 .bat
文件中 运行 )。我应该如何写入控制台?有没有一种简单的方法可以做到这一点,或者我还应该如何显示有关服务器的信息 运行?
搜索了一下。如果您使用 -batchmode
使用 -logFile
参数和 Debug.Log
.
似乎只能登录到文件
不过我确实设法找到了这个自定义控制台示例:
https://garry.tv/unity-batchmode-console 如果您想付出额外的努力才能写入控制台。
此处的类似问题可能对您有用
即使没有明确定义不同的日志位置,默认情况下 Unity 始终会生成以下日志输出(参见 Log Files)
PackageManager Log
Linux
~/.config/unity3d/upm.log
macOS
~/Library/Logs/Unity/upm.log
Windows
C:\Users\username\AppData\Local\Unity\Editor\upm.log
Editor Log
Linux
~/.config/unity3d/Editor.log
macOS
~/Library/Logs/Unity/Editor.log
Windows
C:\Users\username\AppData\Local\Unity\Editor\Editor.log
Player Log
Linux
~/.config/unity3d/CompanyName/ProductName/Player.log
macOS
~/Library/Logs/Company Name/Product Name/Player.log
Windows
C:\Users\username\AppData\LocalLow\CompanyName\ProductName\Player.log
所以在构建之后你会对最后一个感兴趣,即玩家日志。通常它是在您启动应用程序时创建的,但在应用程序完全关闭之前不会填充内容。
此处的例外是定义 -logFile -
,它直接将输出打印到 stdout
/终端 - 见下文。
如果您想要将日志输出重定向到不同的文件或command/stdout,您可以使用(参见Command Line Arguments)
-logFile <pathname>
Specify where Unity writes the Editor or Windows/Linux/OSX standalone log file. To output to the console, specify -
for the path name. On Windows, specify -
option to make the output go to stdout
, which is not the console by default.
并照常使用 Debug.Log
。
我正在 unity 中制作一个游戏服务器并且 运行 它在 -batchmode
中。我试过 Console.WriteLine
和 Debug.Log
但实际上都没有向控制台打印任何内容(我在 .bat
文件中 运行 )。我应该如何写入控制台?有没有一种简单的方法可以做到这一点,或者我还应该如何显示有关服务器的信息 运行?
搜索了一下。如果您使用 -batchmode
使用 -logFile
参数和 Debug.Log
.
不过我确实设法找到了这个自定义控制台示例: https://garry.tv/unity-batchmode-console 如果您想付出额外的努力才能写入控制台。
此处的类似问题可能对您有用
即使没有明确定义不同的日志位置,默认情况下 Unity 始终会生成以下日志输出(参见 Log Files)
PackageManager Log
Linux
~/.config/unity3d/upm.log
macOS
~/Library/Logs/Unity/upm.log
Windows
C:\Users\username\AppData\Local\Unity\Editor\upm.log
Editor Log
Linux
~/.config/unity3d/Editor.log
macOS
~/Library/Logs/Unity/Editor.log
Windows
C:\Users\username\AppData\Local\Unity\Editor\Editor.log
Player Log
Linux
~/.config/unity3d/CompanyName/ProductName/Player.log
macOS
~/Library/Logs/Company Name/Product Name/Player.log
Windows
C:\Users\username\AppData\LocalLow\CompanyName\ProductName\Player.log
所以在构建之后你会对最后一个感兴趣,即玩家日志。通常它是在您启动应用程序时创建的,但在应用程序完全关闭之前不会填充内容。
此处的例外是定义 -logFile -
,它直接将输出打印到 stdout
/终端 - 见下文。
如果您想要将日志输出重定向到不同的文件或command/stdout,您可以使用(参见Command Line Arguments)
-logFile <pathname>
Specify where Unity writes the Editor or Windows/Linux/OSX standalone log file. To output to the console, specify
-
for the path name. On Windows, specify-
option to make the output go tostdout
, which is not the console by default.
并照常使用 Debug.Log
。