Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Remote script debugging not working

Discussion in 'Scripting' started by KMacro, Jun 25, 2019.

  1. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I am attempting to remotely debug my project and running into issues. To rule out any problems with my project specifically, I have created a very simple scene with a single cube with one script attached that rotates it in Update. I build with Development Build and Script Debugging selected.

    I load my build on my remote machine and use my IDE to connect to the Unity build using the port in Player.log. I then see a message in Player.log saying "PlayerConnection accepted from [my IP]" so I know I have connected.

    I have tried with both Visual Studio and Rider and these are the results I get:

    Visual Studio
    After I choose Attach to Unity, Visual Studio thinks for a bit, then I see an output in the Output window about my build succeeding. VS never actually enters debugging mode. I can add breakpoints but they are obviously not hit because the code isn't running.

    Rider:
    Rider seems to properly attach to my remote process but all added breakpoints have the error "Not found associated module for breakpoint".
    This page (https://docs.unity3d.com/Manual/ManagedCodeDebugging.html#ConfiguringTheCodeEditor) suggests that if the debugger attaches but breakpoints don't load there may be an issue with managed code in .dll's, but the only script in my build is the one MonoBehaviour I mentioned above that rotates the cube.

    I am properly setting the IDE I plan to use in my Editor Preferences (though I'm not sure if this actually affects anything in my build).

    I have tried remote debugging on both a Windows and Linux machine, and I see the behavior mentioned above on both.

    Any suggestions would be appreciated!

    EDIT: Forgot to mention, but I am using Unity 2019.1.0f2
     
    Last edited: Jun 25, 2019
  2. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    Bump. Does anyone have any experience to share with remote script debugging?
     
  3. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    Thanks for your suggestion, but I have the latest version of VS Tools for Unity installed. My Editor is targeting the proper VS version as well.
    Also, it may have not been obvious from my post, but I am attempting to remote debug a development build of my game on a separate machine, not in the Editor.
     
  4. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    I'm sorry, I somehow managed to post my response in completely the wrong thread, so it didn't make any sense here.
    In Build Settings, are you using the Copy PDB option? That might help by copying the debug symbols over.
     
  5. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I'm very surprised this option isn't mentioned in either the Unity or VS documentation on remote debugging.
    Unfortunately, I've just tried new builds with this option checked with both VS and Rider on my remote Windows machine, and I see the same results as I described in my first post.
     
  6. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    Hmm. In VS, under Debug->Attach Unity Debugger, do you see the right machine and port for the remote build?
     
    infulleffect likes this.
  7. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I need to manually input the IP and port of my remote machine. They don't just appear automatically.
    However, I know I am able to connect because the Player.log file of the build on my remote machine contains the line "PlayerConnection accepted from [my IP]" after I attempt to attach the debugger.

    I came across this page in my search as well:
    https://docs.unity3d.com/Manual/WindowsDebugging.html
    I've now added Unity's symbol server to my symbol file locations in VS, but I am still not able to remotely debug.

    Is there a specific location I should be placing the .pdb files I generate with my build?
     
  8. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    They should be in the same folder as the exe. In you use the Wait for Managed Debugger build option, how does the behave in your case?
     
  9. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I get a popup saying "You may attach a manged debugger now if you want" before my game launches. I see no difference in behavior when trying to attach to my build when it is in this state.

    Also, I edited my first post, but I should have specified sooner. I'm using Unity 2019.1.0f2
     
  10. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    One more thing to add: I have tried debugging with the same build locally and everything works as expected, so I know this is a remote debugging issue, not just a debugging issue.
     
  11. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
  12. KMacro

    KMacro

    Joined:
    Jan 7, 2019
    Posts:
    48
    I have now tried attaching to the remote Unity process on my Linux machine through SSH while running vsdbg just to see if it worked somehow. It did not.
     
  13. MoMonay

    MoMonay

    Joined:
    May 9, 2018
    Posts:
    19
    Hey guys for anyone seeing this;

    In my case this helped:

    Uninstall Rider.
    Install Rider.
    In the Unity Editor go to Build Settings and turn on Script Debugging
    In Rider go to Run > Attach to Unity Process
    Choose your project (Unity editor has to be open with your project)

    Then breakpoints worked for me.

    Also don't forget to start the game with "Attach to Unity Editor and Play" everytime you want to debug with break points.
    It doesn't work if you run the game through the Unity editor Play button or the regular Run button in Rider