Debugging CSP for Unity
Note: This tutorial is for debugging the native CSP DLL. If you are trying to debug the C# wrapper code, you can do this directly from your Unity project’s generated Visual Studio project.
This guide assumes the developer is working on a Windows PC using Visual Studio.
If you haven’t already done so already, please follow the C# Build instructions to generate a locally debuggable version of the library.
Navigate to your local CSP repository.
Fetch the latest tags.
git fetch --all
Checkout the tag that matches your current CSP package version.
eg.
git checkout tags/v3.1.245 -b v3.1.245-branch
This is required as the source you use to debug must be the same as the source that was used to build the Unity package. Visual Studio’s debugger will load the required debug symbols from the PDB provided with the CSP package, so you do not need to build locally.
Run
generate_solution.bat
to generate the CSP project and solution files.You must re-run
generate_solution.bat
every time you pull latest, check out a different branch/tag, or make changes to the public headers.This will ensure that your project file is up-to-date in case any new files were added or old ones removed.
Open
ConnectedSpacesPlatform.sln
in Visual Studio, switch to theDebugDLL-CSharp
configuration, and make sure the target platform is x64 and not Android.Open your Unity project.
Hit Play in Unity to start the session.
In Visual Studio, press
Ctrl + Alt + P
to show theAttach to Process
window and attach toUnity.exe
.Set a breakpoint in some code you’d like to inspect in Visual Studio, then run your tests/press play in Unity.
Your breakpoint within the library will now be hit when the corresponding line of code is executed.