Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see Debug.Log output in MonoDevelop Unity when connected to a device?

When debugging in Unity Editor I can see the Debug.Log() output in the Console, which is great. However, when connecting MonoDevelop to a device I don't know where to find this output. It is not in the "Application Output" window. Breakpoints, variables, stack - all works fine. Is there a way to see the debug output in MonoDevelop?

Is there anything better then this answer suggests? Debug/Trace output in MonoDevelop

like image 507
Grandika Avatar asked Aug 02 '15 22:08

Grandika


People also ask

What does debug log do in unity?

Use Debug. Log to print informational messages that help you debug your application. For example, you could print a message containing a GameObject.name and information about the object's current state.

How do I open debug in unity?

Enable script debugging in a Unity player In Unity, open the Build Settings by selecting File > Build Settings. In the Build Settings window, mark the Development Build and Script Debugging checkboxes.

How do you debug an app in unity?

To debug a Unity application on a local computer Make sure the project you want to debug is opened in the Unity editor. In JetBrains Rider, open the corresponding Unity project solution. Set breakpoints by clicking the gutter next to a required line of code. Select the Attach to Unity Editor & Play run configuration.


1 Answers

1) Enable "USB debugging" on your device and connect the device to your development machine via USB cable. Ensure your device is on the same subnet mask and gateway as your development machine. Also, make sure there are no other active network connections on the device (i.e. disable data access over mobile/cellular network).

2) On your development machine, open up your terminal/cmd and navigate to the location of the ADB. You can find the ADB tool in /platform-tools/

3) Restart host ADB in TCP/IP mode with the following command: adb tcpip 5555

This should produce the following output: restarting in TCP mode port: 5555

This will have enabled ADB over TCP/IP using port 5555. If port 5555 is unavailable, you should use a different port. (See http://developer.android.com/tools/help/adb.html)

4) Find out the IP address of your Android device (Settings -> About -> Status) and input the following command: adb connect DEVICEIPADDRESS (DEVICEIPADDRESS is the actual IP address of your Android device)

This should produce the following output: connected to DEVICEIPADDRESS:5555

5) Ensure that your device is recognised by inputting the following command: adb devices

This should produce the following output: List of devices attached DEVICEIPADDRESS:5555 device

6) Build and run your Unity application to the device. Ensure you build your application with Development Build flag enabled and Script Debugging turned on.

7) The device no longer needs to be connected to your development machine via USB.

8) Finally, while the application is running on your device, open your script in MonoDevelop, add a breakpoint, select "Run" -> "Attach to Process" and select your device from the list. (Note that it might take a few seconds for the device to appear in the list. It may not appear in the list if the application is not running or if the device's display goes to sleep).

For some more details and for troubleshooting, see the Wireless Usage section in the Android developers guide for the ADB: http://developer.android.com/tools/help/adb.html#wireless

NB: The device sends multicast messages and the editor and MonoDevelop subscribe/listen for them. For this to work, your network will need to be setup correctly for Multicasting.

Taken From here

There are other ways also to debug your application in terminal

******************* On MacOS ***************************

Start Terminal from launchpad

First Method

  1. Turn USB Debugging on, on your android device

  2. Connect the android device through usb cable

  3. Go to “platform-tools” folder in Adroid sdk folder by using “cd” command

  4. Connect the android device through usb cable

  5. type “adb devices” in terminal it will print the list of devices attached

  6. type “adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG” to see logcat of only unity related stuffs

Second Method

creating an environment variable to access ADB directly

  1. Go to your home directory by typing “cd ~”

  2. Type touch .profile this will create a hidden file named profile

  3. Type open -e .profile this will open the file you just created in TextEdit

  4. In the file, type export PATH=${PATH}:/AndroidSdkPath/android-sdk-mac_86/platform-tools

  5. Save file, close TextEdit, Quit Terminal, and Relaunch Terminal

  6. Turn USB Debugging on, on your android device

  7. Connect the android device through usb cable

  8. type “adb devices” in terminal it will print the list of devices attached

  9. type “adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG” to see logcat of only unity related stuffs

Now you can start your app/game on the target device and Terminal will log all the activities of your app.

like image 50
Neeraj Kumar Avatar answered Nov 10 '22 15:11

Neeraj Kumar