The breakpoint will not currently be hit. No symbols have been loaded for this document in Unity
Asked Answered
F

8

9

I am trying to debug a coroutine in Unity using VS2017.

When I attach VS to Unity and set a breakpoint inside the IEnumerator method I get the error "Breakpoint will not be hit"

enter image description here

It is discussed in depth here: How do I remedy the "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?

However none of those answers worked for me.

Do you know how to set a breakpoint inside an IEnumerator in VS2017?

Felten answered 13/10, 2017 at 0:8 Comment(0)
P
7

This is known bug in Unity. Here is how to fix this:

1.Go to File --> Build Settings... then select your platform.

2.Click on Player Settings --> Other Settings and change the API Compatibility Level to .NET 2.0.

If it is already set to .NET 2.0, change it to .NET 2.0 Subset then back to .NET 2.0.

3.Close and re-open Visual Studio. From Visual Studio, go to Build --> Clean Solution then Build --> Rebuild Solution.

Try debugging again and it should work.


If the steps above did not work, Go your Project's Library folder then deltete it. Restart both Unity and Visual Studio.

Purify answered 13/10, 2017 at 0:31 Comment(3)
Solid. This got it! Thanks for sharing some battle wisdom. I knew it was a quirk.Felten
What about .NET 4.x? Is that a source of issues, or did you mean to change to .NET 2.0 or above?Karie
Well my issue is that the debugger defaults to Native. Deb8ug -> Attach to Debugger -> Select type -> Choose Net 2.0 Then Select Unity Editor running it works and Visual Studio remembers the typePrescience
M
2

In my case, this happened when this script was not attached to anything in the scene, therefore, the breakpoint would never be hit... something unexpected from somebody who works in C++. This is a nice side effect, though.

Medea answered 28/11, 2018 at 15:50 Comment(1)
Wow, your answer was the only correct one for me, and actually Unity sucks because this code clearly can be reached after stepping through the other class's breakpoint (The one closer to the surface) but they only allowed me to put a breakpoint in that class as opposed to the deeper one.Chaker
V
1

I spent enough time and found the solution. Go to Build-> Configuration Manager and change Active Solution Configuration to Debug.

Venusberg answered 18/4, 2018 at 21:43 Comment(2)
There is no "Build" menu on Unity. There is no "Configuration Manager" menu on Visual Studio Community Edition.Karie
you do not see this menu item because this menu item is hide when project is run. try again without running.Ketone
M
1

In my case it was because I was using "Attach to process" instead of "Attach to Unity ...". The latter was not available, because the Unity addon for VS failed to install.

Modulator answered 14/2, 2019 at 7:38 Comment(2)
I think I have the exact same problem. I don't see any "Attach to Unity". How do you reinstall the addon?Gotha
They are the same thingPrescience
S
0

So, i had these too The unity doesnt know which script tool you are using..

  1. In Unity, do Edit -> Preferences.

  2. In the Preferences window that opened, choose the External Tools tab.

  3. Click on the External Script Editor dropdown.

  4. Click on Browse.

  5. Select Visual Studio 2017 if not already selected

GoodLuck (;

(:

Sosanna answered 12/11, 2020 at 12:14 Comment(0)
M
0

I tried different happy complicated solutions but the one that worked for me was as simple as solution>"Analyse and code cleanup">"run code cleanup (profile 1), and then rebuild. This made the project Unity-VS run as normal (i.e. breakpoints didn't show any errors and got caught as normal).

However, once I closed-opened VS, the same issue got back again. Later, I run the VS-Unity project from the admin session, which is not supported by Unity; I had to select "I run on my own risk" on a Unity's pop-up. The breakpoints got caught consistently as normal. Then, got back to user session and finally breakpoints got caught as normal even after VS relunch.

I wish I could have time to understand the reason why this "admin session" was the troubleshoot. But, it seems like the socket connections between Unity and VS needed some sort of permissions by Windows architecture; I am not sure.

Mercado answered 23/5, 2024 at 11:23 Comment(0)
M
-2

I had the same issue. Following steps solved mine.

  1. Navigate to build->configuration manager.

  2. check for project configuration. If it is set to production, change this value to debug.

Macaroni answered 19/2, 2018 at 10:42 Comment(2)
There is no "build" menu on Unity. There is no "configuration manager" menu on Visual Studio Community Edition.Karie
There is a confugration menu and drop down, choose itPrescience
C
-3

I found a solution (workaround). You need to add the attribute [InitializeOnLoad] to the class.

Cannot answered 16/4, 2018 at 11:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.