c# – How to disable Unity code on Visual Studio

Have you tried to check Unity manual available at docs.unity3d.com/Manual/ManagedCodeDebugging.html

For example, following topics:

Attach your code editor to the Unity Player

To attach your code editor
to the Unity Player, in your code editor, select the IP address (or
machine name) and port of your Player. For an example of where to find
this in Visual Studio, see Attach Visual Studio to the Unity Editor.

Note: Your code editor will show all instances of Unity that are
available to debug. Make sure you attach the code editor to the
correct instance of the Unity Player, and not to the Unity Editor if
both are running.

When you have attached the debugger, you can begin debugging normally.
For instructions on how to attach the Unity Player to your specific
code editor, see Code editor external documentation. For an example of
how to attach a Unity Player that runs on a mobile device to Visual
Studio, see Debug Android and iOS devices with Visual Studio.

and

Attach Visual Studio to the Unity Editor

To attach the Unity Editor to your Visual Studio script, open Visual
Studio, go to Debug > Attach Unity Debugger and select the instance of
the Unity Editor you would like to debug.

In the following example image, there is one instance of Unity running
in the Editor and one instance of Unity running as an Android Player

Read more here: Source link