Hello!
I use the following products:
- Unity 2020.1.2f1
- Visual Studio 2019 16.7.2
- Visual Studio 2019 Tools for Unity 4.7.1.0
In Visual Studio, I create a blank solution and call it Base. Then I add a class library project and call it Base. For the project, I install .NET Standard 2.0 as the target platform. Debugging information is automatically set to Portable. I add class MyUtils to the project:
namespace Base
{
public static class MyUtils
{
public static int add(int a,int b)
{
return a+b;
}
}
}
Then I build the project and get three files:
- Base.dll
- Base.pdb
- Base.deps.json
Now I create a new Unity project and call it Test. I copy two files to the root of the project (to the Assets folder on the disk):
- Base.dll
- Base.pdb
Although I didn’t notice any difference from having the pdb file in the project. In the project settings I have installed:
However, the library itself says:
And this is a little scary since I installed .NET Standard 2.0. I add script Test to the project:
using UnityEngine;
public sealed class Test : MonoBehaviour
{
void Start()
{
int a=1;
int b=2;
int c=Base.MyUtils.add(a,b);
Debug.Log(c);
}
}
I place this script on the camera. I put a breakpoint on the line with the called function and start debugging from Visual Studio:
Switch Unity to debug mode and play. My breakpoint is triggered:
But after pressing Step Into (F11), I don’t go inside the function:
What actions do I need to do so that I can debug the code by going inside functions?
I was reading this documentation (section “Debug a DLL in your Unity project”). But something I still did not understand in which project where they add what and why the project file is added to the project in the screenshot, and the link that they provide tells about adding the project to the solution. So I tried it and it didn’t work.