Reputation: 13551
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"
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?
Upvotes: 9
Views: 13873
Reputation: 1
Moke sure in Navigate to build->configuration manager in Visual Studio, you only build the main project and not any other Projects that you have added from the project manager. Main names are Assemny-CSharp and Assemny-CSharp-Editor.
Upvotes: 0
Reputation: 1
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.
Upvotes: 0
Reputation: 1
So, i had these too The unity doesnt know which script tool you are using..
In Unity, do Edit -> Preferences.
In the Preferences window that opened, choose the External Tools tab.
Click on the External Script Editor dropdown.
Click on Browse.
Select Visual Studio 2017 if not already selected
GoodLuck (;
(:
Upvotes: 0
Reputation: 3708
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.
Upvotes: 1
Reputation: 2573
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.
Upvotes: 3
Reputation: 166
I spent enough time and found the solution. Go to Build-> Configuration Manager and change Active Solution Configuration to Debug.
Upvotes: 1
Reputation: 1
I found a solution (workaround). You need to add the attribute [InitializeOnLoad] to the class.
Upvotes: -3
Reputation: 1
I had the same issue. Following steps solved mine.
Navigate to build->configuration manager.
check for project configuration. If it is set to production, change this value to debug.
Upvotes: -2
Reputation: 125445
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.
Upvotes: 7