diff --git a/getting_started/step_by_step/scripting_languages.rst b/getting_started/step_by_step/scripting_languages.rst index 4415b1a5cef..bfa72daa09c 100644 --- a/getting_started/step_by_step/scripting_languages.rst +++ b/getting_started/step_by_step/scripting_languages.rst @@ -133,6 +133,8 @@ officially supported .NET option. Android and iOS platform support is available as of Godot 4.2, but is experimental and :ref:`some limitations apply `. +.. seealso:: To learn more about C#, head to the :ref:`C# basics ` page. + C++ via GDExtension ~~~~~~~~~~~~~~~~~~~ diff --git a/tutorials/scripting/c_sharp/c_sharp_basics.rst b/tutorials/scripting/c_sharp/c_sharp_basics.rst index 306b732ea15..c11246eef1a 100644 --- a/tutorials/scripting/c_sharp/c_sharp_basics.rst +++ b/tutorials/scripting/c_sharp/c_sharp_basics.rst @@ -112,11 +112,52 @@ In Visual Studio Code: for the C# tools plugin to work. To configure a project for debugging, you need a ``tasks.json`` and ``launch.json`` file in -the ``.vscode`` folder with the necessary configuration. An example configuration can be -found `here `__ . -In the ``launch.json`` file, make sure the ``program`` parameter in the relevant configuration points to your Godot executable, either by -changing it to the path of the executable or by defining a ``GODOT4`` environment variable that points to the -executable. Now, when you start the debugger in Visual Studio Code, your Godot project will run. +the ``.vscode`` folder with the necessary configuration. + +Here is an example ``launch.json``: + +.. code-block:: json + + { + "version": "0.2.0", + "configurations": [ + { + "name": "Play", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${env:GODOT4}", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + } + ] + } + +For this launch configuration to work, you need to either setup a GODOT4 +environment variable that points to the Godot executable, or replace ``program`` +parameter with the path to the Godot executable. + +Here is an example ``tasks.json``: + +.. code-block:: json + + { + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build" + ], + "problemMatcher": "$msCompile" + } + ] + } + +Now, when you start the debugger in Visual Studio Code, your Godot project will run. Visual Studio (Windows only) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -143,6 +184,19 @@ In Godot's **Editor → Editor Settings** menu: the ``NuGet.Config`` file. When you build your Godot project again, the file will be automatically created with default values. +To debug your C# scripts using Visual Studio, open the .sln file that is generated +after opening the first C# script in the editor. In the **Debug** menu, go to the +**Debug Properties** menu item for your project. Click the **Create a new profile** +button and choose **Executable**. In the **Executable** field, browse to the path +of the C# version of the Godot editor, or type ``%GODOT4%`` if you have created an +environment variable for the Godot executable path. It must be the path to the main Godot +executable, not the 'console' version. For the **Working Directory**, type a single period, +``.``, meaning the current directory. Also check the **Enable native code debugging** +checkbox. You may now close this window, click downward arrow on the debug profile +dropdown, and select your new launch profile. Hit the green start button, and your +game will begin playing in debug mode. + + Creating a C# script --------------------