Skip to content

Debugging in Visual studio

DasSkelett edited this page Jul 12, 2021 · 21 revisions
Clone this wiki locally

First of all make sure that you've read the How to compile LMP chapter and be extra sure that you've adjusted the Scripts\SetDirectories.bat file

1- Make sure that the "Tools for Unity" is installed in your VS2017. You can do it by selecting the "Game development with Unity" node in the visual studio installer, also you can uncheck the "Unity XXXX 64-bit Editor" in the right panel to save some space.
For JetBrains Rider, install the "Unity Support" plugin, it is essentially the same as the above for VS.

2- Windows: Copy the files UnityPlayer.dll and WinPixEventRuntime.dll from the folder LunaMultiPlayer\External\DebugLMP to your root KSP directory, next to the KSP.exe. You also have a backup of the original UnityPlayer_ORIGINAL.dll in case you want to go back
Linux: Copy the file UnityPlayer.so from the folder LunaMultiPlayer\External\DebugLMP to your root KSP directory, next to the KSP.x86_64. You also have a backup of the original UnityPlayer_ORIGINAL.so in case you want to go back

3- Open the file boot.config inside the KSP_x64_Data (Windows) or KSP_Data (macOS/Linux) directory and add the following line at the bottom: player-connection-debug=1

4- Launch KSP

5- Attach to the correct Unity instance using the "Debug->Attach to unity debugger" option from Visual Studio or "Run->Attach to Unity Process" in Rider. If you don't know what instance you need to attach, check the status dialog or connection dialog as you will see there what debug port you should attach to.

Note: Remember that you must set the "Debugging information" to ´portable´ in the project settings if you want to be able to debug it.


Original link: http://forum.kerbalspaceprogram.com/index.php?/topic/102909-ksp-plugin-debugging-and-profiling-for-visual-studio-and-monodevelop-on-all-os/

Updated version: https://forum.kerbalspaceprogram.com/index.php?/topic/102909-ksp-plugin-debugging-and-profiling-for-visual-studio-and-monodevelop-on-all-os/page/7/&tab=comments#comment-3688332

Updated version for Linux: https://forum.kerbalspaceprogram.com/index.php?/topic/102909-ksp-plugin-debugging-and-profiling-for-visual-studio-and-monodevelop-on-all-os/&do=findComment&comment=3720877 and https://forum.kerbalspaceprogram.com/index.php?/topic/102909-ksp-plugin-debugging-and-profiling-for-visual-studio-and-monodevelop-on-all-os/&do=findComment&comment=3995970
To start the download copy the Unity Hub link and pass it as argument to the Unity Hub AppImage, e.g. ./UnityHub.AppImage unityhub://2019.4.18f1/3310a4d4f880

Version of unity for KSP 1.12: 2019.4.18f1 (https://unity3d.com/unity/whats-new/2019.4.18)

Analytics