It is possible to retrieve debug logs, warnings, and errors from the device while the game is running. This comes in very handy in debugging, especially if you have unwanted behavior recurrent on the device and not in the editor's play mode.
We can retrieve these logs through the console, using logcat
, which is a combined message pipe for all Android applications, as follows:
cmd
in the new window and hit Enter or click on the Ok button.cd
followed by your Android SDK's platform-tools
folder location and hit Enter. For example, in my case it is:cd C:SDKplatform-tools
Good. You now have the following commands available to retrieve the game's logs:
adb logcat
: This displays everything that's going on. You will be overwhelmed by the number of lines per second.adb logcat –s Unity
: This displays only the output from Unity.adb logcat –s Unity > logcat.txt
: This dumps logcat
into the logcat.txt
file in the platform-tools
folder of your Android SDK. You must close the command window before you can open the logcat.txt
file.After entering adb logcat –s Unity
, you should be able to find Debug.Logs()
from our Play
button's EventTester
component, as shown in the following screenshot:
Great. Now that you know how to debug our game, we can summarize what you've learned in this chapter.
18.224.54.168